# resourceschedule_device_usage_statistics **Repository Path**: qian-li1126/resourceschedule_device_usage_statistics ## Basic Information - **Project Name**: resourceschedule_device_usage_statistics - **Description**: 设备使用信息统计,包括app usage/notification usage/system usage等使用统计。例如应用使用信息统计,用于保存和查询应用使用详情(app usage)、事件日志数据(event log)、应用分组(bundle group)情况。 部件缓存的应用记录(使用历史统计和使用事件记录)会在事件上报后30分钟内刷新到数据库持久化保存。 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 169 - **Created**: 2022-03-08 - **Last Updated**: 2022-03-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Device usage statistics - [Introduction](#section11660541593) - [Directory Structure](#section161941989596) - [Instruction](#section1312121216216) - [Available APIs](#section1551164914237) - [Usage Guidelines](#section129654513264) - [Repositories Involved](#section1371113476307) ## Introduction The **device usage statistics** includes app usage, notification usage, system usage and other usage statistics. For example, application usage statistics is used to save and query application usage details, event log data and application grouping.The application records (usage history statistics and usage event records) cached by the component will be periodically refreshed to the database for persistent storage. ## Directory Structure ``` /foundation/resourceschedule/device_usage_statistics ├── ohos.build # Compilation script ├── BUILD.gn # Module compilation script ├── interfaces │ ├── innerkits # Internal interface directory │ └── kits # External interface directory ├── services # Service layer directory ├── frameworks │ ├── JS # External JS interface implementation directory │ └── native # External native interface implementation directory ├── adapter # Adaptation directory └── test # Testing case directory ``` ## Instruction ### Available APIs Device usage statistics interfaces include app usage, notification usage, system usage and other interfaces. Taking app usage interface as an example, the main exposed interfaces are as follows.

API name

API description

queryBundleActiveStates(begin::number, end::number, callback:AsyncCallback<Array<BundleActiveState>>):void

Queries the event collection of all applications through time interval.

queryBundleStateInfos(begin::number, end::number, callback:AsyncCallback<BundleStateInfoResponse>):void

Uses the start and end time to query the application usage time statistics.

queryCurrentBundleActiveStates(begin::number, end::number, callback:AsyncCallback<Array<BundleActiveState>>):void

Queries the event collection of the current application through the time interval.

queryBundleStateInfoByInterval(byInterval:intervalType, begin::number, end::number, callback:AsyncCallback<Array<BundleStateInfo>>):void

Queries application usage duration statistics by time interval.

queryAppUsagePriorityGroup(callback:AsyncCallback<number>):void

Queries (returns) the priority group used by the current caller application.

isIdleState(bundleName:string, callback:AsyncCallback<boolean>):void

Judges whether the application of the specified bundle name is currently idle.

### Usage Guidelines There are many interfaces for device usage statistics. Take app usage interface as an example to introduce the interface logic. - **running process**:The device usage statistics service starts and runs in the foundation process. - **device usage statistics saving time**: >1. refreshing is triggered every 30 minutes; >2. refreshing is triggered when system time changes; >3. refreshing is triggered from the next day; - **app querying interface**: >1. Query the event collection of all applications according to the start and end time; >2. Query the usage duration of the application according to the start and end time; >3. Query the event collection of the current application according to the start and end time; >4. Query the usage duration of the application according to the type of interval (day, week, month, year) and the start and end time; >5. Query the priority group of the caller application; >6. Judge whether the specified application is currently idle; ## Repositories Involved resource schedule subsystem **device\_usage\_statistics** resource_schedule_service appexecfwk_standard native_appdatamgr