public final class BundleActiveInfosMgr extends Object
You can use the methods defined in this class to query
the usage history and states of bundles in a specified period.
The system stores the query result in a BundleActiveInfos or BundleActiveStates instance and
then returns it to you.
SystemCapability.ResourceSchedule#BUNDLE_ACTIVE| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static int |
BY_ANNUALLY |
Indicates the annually interval.
|
static int |
BY_DAILY |
Indicates the daily interval.
|
static int |
BY_MONTHLY |
Indicates the monthly interval.
|
static int |
BY_OPTIMIZED |
Indicates the interval type that will determine the optimal interval based on the start and end time.
|
static int |
BY_WEEKLY |
Indicates the weekly interval.
|
static int |
USAGE_PRIORITY_GROUP_ALIVE |
Indicates that the application was used recently, is being used, or will be used soon.
|
static int |
USAGE_PRIORITY_GROUP_NEVER |
Indicates that the application has never been used.
|
static int |
USAGE_PRIORITY_GROUP_OFTEN |
Indicates that the application was used in the last few days and may be used in the next few days,
but it is not in the active state right now.
|
static int |
USAGE_PRIORITY_GROUP_PREFERENCE |
Indicates that the application was used recently and may be used in the next few hours,
but it is not in the active state right now.
|
static int |
USAGE_PRIORITY_GROUP_PRIVILEGE |
Indicates that the application is in the privileged priority group.
|
static int |
USAGE_PRIORITY_GROUP_SELDOM |
Indicates that the application has not been used in the past few days
and is unlikely to be used in the next few days.
|
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
boolean |
isIdleState(String bundleName) |
Checks whether the application with a specified bundle name is in the idle state.
|
static BundleActiveInfosMgr |
newInstance(Context context) |
A static factory method used to create a
BundleActiveInfosMgr instance based on a specified context. |
int |
queryAppUsagePriorityGroup() |
Queries the usage priority group of the calling application.
|
Map<String,BundleActiveInfos> |
queryBundleActiveInfos(long begin,
long end) |
Queries usage information about each bundle within a specified period.
|
List<BundleActiveInfos> |
queryBundleActiveInfosByInterval(int byInterval,
long begin,
long end) |
Queries usage information about each bundle within a specified period at a specified interval.
|
BundleActiveStates |
queryBundleActiveStates(long begin,
long end) |
Queries state data of all bundles within a specified period identified by the start and end time.
|
BundleActiveStates |
queryCurrentBundleActiveStates(long begin,
long end) |
Queries state data of the current bundle within a specified period.
|
public static final int BY_ANNUALLY
queryBundleActiveInfosByInterval(int, long, long)public static final int BY_DAILY
queryBundleActiveInfosByInterval(int, long, long)public static final int BY_MONTHLY
queryBundleActiveInfosByInterval(int, long, long)public static final int BY_OPTIMIZED
queryBundleActiveInfosByInterval(int, long, long)public static final int BY_WEEKLY
queryBundleActiveInfosByInterval(int, long, long)public static final int USAGE_PRIORITY_GROUP_ALIVE
For an application in this priority group, the system does not restrict its resource usage, including background tasks and alarms.
queryAppUsagePriorityGroup()public static final int USAGE_PRIORITY_GROUP_NEVER
queryAppUsagePriorityGroup()public static final int USAGE_PRIORITY_GROUP_OFTEN
For an application in this priority group, the system restricts some of its resource usage. For example, the system may postpone its background tasks and alarms more extensively.
queryAppUsagePriorityGroup()public static final int USAGE_PRIORITY_GROUP_PREFERENCE
For an application in this priority group, the system restricts a small amount of its resource usage. For example, the system may postpone its background tasks and alarms.
queryAppUsagePriorityGroup()public static final int USAGE_PRIORITY_GROUP_PRIVILEGE
When the application is in the allowlist or for some reason, its privileged priority will not be changed.
queryAppUsagePriorityGroup()public static final int USAGE_PRIORITY_GROUP_SELDOM
For an application in this priority group, the system restricts most of its resource usage, including the network usage.
queryAppUsagePriorityGroup()public static BundleActiveInfosMgr newInstance(Context context)
BundleActiveInfosMgr instance based on a specified context.context - Indicates the application context.BundleActiveInfosMgr instance created if the operation is successful;
returns null if the context is null.public List<BundleActiveInfos> queryBundleActiveInfosByInterval(int byInterval, long begin, long end)
Permissions: SystemPermission.BUNDLE_ACTIVE_INFO
byInterval - Indicates the interval at which the usage statistics are queried.
The value can be BY_OPTIMIZED, BY_DAILY,
BY_WEEKLY, BY_MONTHLY, or BY_ANNUALLY.begin - Indicates the start time of the query period,
in System.currentTimeMillis() format.end - Indicates the end time of the query period,
in System.currentTimeMillis() format.BundleActiveInfos objects containing the usage information about each bundle.queryBundleActiveInfos(long, long)public Map<String,BundleActiveInfos> queryBundleActiveInfos(long begin, long end)
This method queries usage information at the BY_OPTIMIZED interval by default.
Permissions: SystemPermission.BUNDLE_ACTIVE_INFO
begin - Indicates the start time of the query period, in System.currentTimeMillis() format.end - Indicates the end time of the query period, in System.currentTimeMillis() format.BundleActiveInfos objects containing the usage information about each bundle.
The key value in the Map object indicates the bundle name.queryBundleActiveInfosByInterval(int, long, long)public BundleActiveStates queryBundleActiveStates(long begin, long end)
Permissions: SystemPermission.BUNDLE_ACTIVE_INFO
begin - Indicates the start time of the query period, in System.currentTimeMillis() format.end - Indicates the end time of the query period, in System.currentTimeMillis() format.BundleActiveStates object containing the state data of all bundles.public BundleActiveStates queryCurrentBundleActiveStates(long begin, long end)
begin - Indicates the start time of the query period, in System.currentTimeMillis() format.end - Indicates the end time of the query period, in System.currentTimeMillis() format.BundleActiveStates object containing the state data of the current bundle.queryBundleActiveStates(long, long)public boolean isIdleState(String bundleName)
bundleName - Indicates the bundle name of the application to query.true if the application is idle in a particular period;
returns false otherwise. The time range of the particular period is defined by the system,
which may be hours or days.public int queryAppUsagePriorityGroup()
The priority defined in a priority group restricts the resource usage of an application, for example, restricting the running of background tasks.
USAGE_PRIORITY_GROUP_PRIVILEGE,
USAGE_PRIORITY_GROUP_ALIVE,
USAGE_PRIORITY_GROUP_PREFERENCE,
USAGE_PRIORITY_GROUP_OFTEN,
USAGE_PRIORITY_GROUP_SELDOM,
USAGE_PRIORITY_GROUP_NEVER