Device Usage Statistics Overview
With device usage statistics APIs, you can have a better understanding of the application, notification, and system usage. In application usage statistics, you can query the application usage, event log, and bundle group. The application records (usage history statistics and event records) cached by components are updated to the database for persistent storage within 30 minutes after an event is reported.
Introduction
Currently you can have access to statistics on the application usage, and the notification and system usage statistics feature will be available for use in later versions.
-
The application usage statistics is updated:
- Every 30 minutes
- Upon system time change
- Upon start of a new day
-
The application usage statistics can include the following:
- Events of all applications based on the specified start time and end time
- Application usage duration statistics based on the specified start time and end time
- Events of the current application based on the specified start time and end time
- Application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually)
- Priority group of the current invoker application
- Whether a specific application is in the idle state
- Number of FA usage records specified by maxNum, sorted by time (most recent first). If maxNum is not specified, the default value 1000 will be used.
- Number of notifications from applications based on the specified start time and end time
- Statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time
- Priority group of the invoker application or a specified application
-
The setters can be used to:
Set the group for the application specified by bundleName.
-
The registration APIs can be used to:
Register a callback for application group changes. When an application group of the user changes, the change is returned to all applications that have registered the callback.
-
The deregistration APIs can be used to:
Deregister the callback for application group changes.
Required Permissions
- Before calling the following system APIs, you must request the ohos.permission.BUNDLE_ACTIVE_INFO permission: isIdleState, queryBundleEvents, queryBundleStatsInfos, queryBundleStatsInfoByInterval, queryDeviceEventStats, queryNotificationEventStats, queryAppGroup(bundleName), setAppGroup, registerAppGroupCallBack, unregisterAppGroupCallBack, queryModuleUsageRecords, and queryModuleUsageRecords(maxnum).
- You do not need to request this permission before calling queryCurrentBundleEvents and queryAppGroup(), which are third-party APIs.