Sequenceablepublic final class WorkInfo extends Object implements Sequenceable
WorkInfo is set by Particle Ability and used in WorkScheduler and WorkSchedulerService.
You can use the methods provided by WorkInfo to query the configured triggering conditions.
SystemCapability.ResourceSchedule#WORK_SCHEDULER| 限定符和类型 | 类 | 说明 |
|---|---|---|
static class |
WorkInfo.Builder |
Represents the builder class of
WorkInfo objects that specify triggering conditions of a work. |
Sequenceable.Producer<T>| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
BATTERY_LEVEL_LOW |
Indicates the work is triggered when a low battery level alarm is reported.
|
static int |
BATTERY_LEVEL_LOW_OR_OKAY |
Indicates the work is triggered when a low battery level alarm is reported or when the battery is restored
from a low battery level.
|
static int |
BATTERY_LEVEL_OKAY |
Indicates the work is triggered when the battery is restored from a low battery level.
|
static int |
CHARGING_PLUGGED_AC |
Indicates the work is triggered when a DC charger is connected.
|
static int |
CHARGING_PLUGGED_ANY |
Indicates the work is triggered when any charger is connected.
|
static int |
CHARGING_PLUGGED_USB |
Indicates the work is triggered when a USB charger is connected.
|
static int |
CHARGING_PLUGGED_WIRELESS |
Indicates the work is triggered when a wireless charger is connected.
|
static int |
MAX_BATTERY_LEVEL |
Indicates the maximum battery level for triggering the work when no charger is connected.
|
static int |
MAX_IDLE_WAIT_TIME_MS |
Indicates the maximum wait time for triggering the work after the device enters the idle state.
|
static int |
MAX_REPEAT_DELAY_TIME_MS |
Indicates the maximum delay for triggering the work that is supposed to repeat at the specified interval.
|
static int |
MIN_BATTERY_LEVEL |
Indicates the minimum battery level for triggering the work when no charger is connected.
|
static int |
MIN_IDLE_WAIT_TIME_MS |
Indicates the minimum wait time for triggering the work after the device enters the idle state.
|
static int |
MIN_REPEAT_COUNTER |
Indicates the minimum number of times the work is triggered.
|
static int |
MIN_REPEAT_CYCLE_TIME_MS |
Indicates the minimum interval at which the work is triggered.
|
static int |
NETWORK_TYPE_ANY |
Indicates the work is triggered when any network connection is available.
|
static int |
NETWORK_TYPE_BLUETOOTH |
Indicates the work is triggered when a Bluetooth connection is available.
|
static int |
NETWORK_TYPE_ETHERNET |
Indicates the work is triggered when a wire network connection is available.
|
static int |
NETWORK_TYPE_MOBILE |
Indicates the work is triggered when a mobile network connection is available.
|
static int |
NETWORK_TYPE_WIFI |
Indicates the work is triggered when a WiFi network connection is available.
|
static int |
NETWORK_TYPE_WIFI_P2P |
Indicates the work is triggered when a WiFi P2P connection is available.
|
static int |
STORAGE_LEVEL_LOW |
Indicates the work is triggered when the remaining storage space is insufficient.
|
static int |
STORAGE_LEVEL_LOW_OR_OKAY |
Indicates the work is triggered when the remaining storage is insufficient or when the remaining storage
is restored from insufficient space.
|
static int |
STORAGE_LEVEL_OKAY |
Indicates the work is triggered when the remaining storage is restored from insufficient space.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
String |
getAbilityName() |
Obtains the ability name of the work.
|
String |
getBundleName() |
Obtains the bundle name of the work.
|
int |
getCurrentWorkID() |
Obtains the
workID in the current WorkInfo object. |
ElementName |
getElementInfo() |
Obtains the
ElementName in the current WorkInfo object. |
PacMap |
getPacMaps() |
Obtains the extra parameters associated with this piece of work.
|
int |
getRepeatCounter() |
Obtains the number of times set for repeating the work.
|
long |
getRepeatCycleTime() |
Obtains the interval at which the work is repeated.
|
int |
getRequestBatteryLevel() |
Obtains the battery level based on which the work is triggered.
|
int |
getRequestBatteryStatus() |
Obtains the battery state based on which the work is triggered.
|
int |
getRequestChargeType() |
Obtains the charger type based on which the work is triggered.
|
int |
getRequestIdleWaitTime() |
Obtains the idle wait time based on which the work is triggered.
|
int |
getRequestNetworkType() |
Obtains the network type based on which the work is triggered.
|
int |
getRequestStorageType() |
Obtains the storage state based on which the work is triggered.
|
boolean |
isRequestBattery() |
Checks whether a battery state has been set for triggering the work.
|
boolean |
isRequestCharging() |
Checks whether a charging state has been set for triggering the work.
|
boolean |
isRequestDeepIdle() |
Checks whether the device deep idle state has been set for triggering the work.
|
boolean |
isRequestDelay() |
Checks whether a delay duration has been set for triggering the work.
|
boolean |
isRequestNetwork() |
Checks whether a network type has been set for triggering the work.
|
boolean |
isRequestPersisted() |
Checks whether the save function has been enabled for the current work.
|
boolean |
isRequestRepeat() |
Checks whether the work has been set to repeat at the specified interval.
|
boolean |
isRequestStorage() |
Checks whether a storage state has been set for triggering the work.
|
boolean |
isWorkInfoValid() |
Checks whether a
WorkInfo object is valid. |
boolean |
marshalling(Parcel out) |
marshalling the WorkInfo
|
boolean |
unmarshalling(Parcel in) |
unmarshalling the WorkInfo
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waithasFileDescriptorpublic static final int BATTERY_LEVEL_LOW
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int BATTERY_LEVEL_LOW_OR_OKAY
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int BATTERY_LEVEL_OKAY
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int CHARGING_PLUGGED_AC
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int CHARGING_PLUGGED_ANY
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int CHARGING_PLUGGED_USB
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int CHARGING_PLUGGED_WIRELESS
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int MAX_BATTERY_LEVEL
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int MAX_IDLE_WAIT_TIME_MS
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int MAX_REPEAT_DELAY_TIME_MS
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int MIN_BATTERY_LEVEL
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int MIN_IDLE_WAIT_TIME_MS
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int MIN_REPEAT_COUNTER
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int MIN_REPEAT_CYCLE_TIME_MS
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int NETWORK_TYPE_ANY
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int NETWORK_TYPE_BLUETOOTH
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int NETWORK_TYPE_ETHERNET
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int NETWORK_TYPE_MOBILE
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int NETWORK_TYPE_WIFI
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int NETWORK_TYPE_WIFI_P2P
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int STORAGE_LEVEL_LOW
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int STORAGE_LEVEL_LOW_OR_OKAY
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public static final int STORAGE_LEVEL_OKAY
When WorkScheduler detects that the triggering condition is met, it starts the Particle Ability for
which the work is set.
public boolean marshalling(Parcel out)
marshalling 在接口中 Sequenceableout - writes a Sequenceable object into thispublic boolean unmarshalling(Parcel in)
unmarshalling 在接口中 Sequenceablein - Restores a Sequenceable object from this.public boolean isWorkInfoValid()
WorkInfo object is valid.true if the WorkInfo object is valid; returns false otherwise.
A WorkInfo object is valid only if ElementName is set to a valid value.
A WorkInfo object is invalid if ElementName is not set. In this case, a failure occurs
when calling methods such as WorkScheduler#startWork.public ElementName getElementInfo()
ElementName in the current WorkInfo object.ElementName. If no ElementName has been set, null may be returned.public int getCurrentWorkID()
workID in the current WorkInfo object.workID in the current WorkInfo object.public String getBundleName()
public String getAbilityName()
public boolean isRequestNetwork()
true if a network type has been set for triggering the work; returns false
otherwise.public int getRequestNetworkType()
public boolean isRequestBattery()
true if a battery state has been set for triggering the work; returns false
otherwise.public int getRequestBatteryStatus()
public int getRequestBatteryLevel()
0.public boolean isRequestCharging()
true if a charging state has been set for triggering the work; returns false
otherwise.public int getRequestChargeType()
public boolean isRequestStorage()
true if a storage state has been set for triggering the work; returns false
otherwise.public int getRequestStorageType()
public boolean isRequestDeepIdle()
WorkInfo.Builder#requestDeviceIdleType.true if the device deep idle state has been set for triggering the work; returns
false otherwise.public int getRequestIdleWaitTime()
0.public boolean isRequestPersisted()
true if the save function has been enabled for the current work; returns false
otherwise.public boolean isRequestRepeat()
true if the work has been set to repeat at the specified interval; returns false
otherwise.public int getRepeatCounter()
public long getRepeatCycleTime()
0.public boolean isRequestDelay()
true if a delay duration has been set for triggering the work; returns false
otherwise.