提交 18e0d04c 编写于 作者: H hehongyang9

Merge branch 'master' of gitee.com:openharmony/docs into dev

Change-Id: I51bc7f583eab2d36bebbff36099b9af1659dac3e
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
## When to Use ## When to Use
With device usage statistics APIs, you can have a better understanding of the application, notification, and system usage. For example, in application usage statistics, you can query the application usage, event log, and bundle group. With device usage statistics APIs, you can have a better understanding of the application, notification, and system usage. For example, 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. 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.
## Available APIs ## Available APIs
...@@ -19,9 +20,20 @@ import stats from '@ohos.bundleState'; ...@@ -19,9 +20,20 @@ import stats from '@ohos.bundleState';
| function queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback<BundleActiveInfoResponse>): void | Queries the application usage duration statistics based on the specified start time and end time.| | function queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback<BundleActiveInfoResponse>): void | Queries the application usage duration statistics based on the specified start time and end time.|
| function queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveState>>): void | Queries events of this application based on the specified start time and end time.| | function queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveState>>): void | Queries events of this application based on the specified start time and end time.|
| function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback<Array<BundleStateInfo>>): void | Queries the application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually).| | function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback<Array<BundleStateInfo>>): void | Queries the application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually).|
| function queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void | Queries the priority group of the current invoker application.| | function queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void | Queries the priority group of this application. This API uses an asynchronous callback to return the result.|
| function queryAppUsagePriorityGroup(): Promise<number>; | Queries the priority group of this application. This API uses a promise to return the result.|
| function isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void | Checks whether the application specified by **bundleName** is in the idle state. | | function isIdleState(bundleName: string, callback: AsyncCallback<boolean>): void | Checks whether the application specified by **bundleName** is in the idle state. |
| function getRecentlyUsedModules(maxNum: number, callback: AsyncCallback<BundleActiveModuleInfo>): void | Obtains the number of FA usage records specified by **maxNum**.| | function getRecentlyUsedModules(maxNum: number, callback: AsyncCallback<BundleActiveModuleInfo>): void | Obtains the number of FA usage records specified by **maxNum**.|
| function queryAppNotificationNumber(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveEventState>>): void | Queries the number of notifications from all applications based on the specified start time and end time.|
| function queryBundleActiveEventStates(begin: number, end: number, callback: AsyncCallback<Array<BundleActiveEventState>>): void | Queries statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time.|
| function queryAppUsagePriorityGroup(bundleName? : string, callback: AsyncCallback<number>): void | Queries the priority group of the application specified by **bundleName**. If **bundleName** is not specified, the priority group of the current application is queried. This API uses an asynchronous callback to return the result.|
| function queryAppUsagePriorityGroup(bundleName? : string): Promise<number>; | Queries the priority group of the application specified by **bundleName**. If **bundleName** is not specified, the priority group of the current application is queried. This API uses a promise to return the result.|
| function setBundleGroup(bundleName : string, newGroup: GroupType, callback: AsyncCallback>boolean>): void | Sets the group for the application specified by **bundleName**. This API uses an asynchronous callback to return the result.|
| function setBundleGroup(bundleName : string, newGroup : GroupType): Promise>boolean>; | Sets the group for the application specified by **bundleName**. This API uses a promise to return the result.|
| function registerGroupCallBack(callback: Callback>BundleActiveGroupCallbackInfo>, callback: AsyncCallback>boolean>): void | Registers 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. This API uses an asynchronous callback to return the result.|
| function registerGroupCallBack(callback: Callback>BundleActiveGroupCallbackInfo>): Promise>boolean>; | Registers 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. This API uses a promise to return the result.|
| function unRegisterGroupCallBack(callback: AsyncCallback>boolean>): void | Deregisters the callback for application group changes. This API uses an asynchronous callback to return the result.|
| function unRegisterGroupCallBack(): Promise>boolean>; | Deregisters the callback for application group changes. This API uses a promise to return the result.|
## How to Develop ## How to Develop
...@@ -44,7 +56,7 @@ import stats from '@ohos.bundleState'; ...@@ -44,7 +56,7 @@ import stats from '@ohos.bundleState';
```js ```js
import stats from '@ohos.bundleState' import stats from '@ohos.bundleState'
// Use a promise to return the result. // Promise mode
stats.queryBundleActiveStates(0, 20000000000000).then( res => { stats.queryBundleActiveStates(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.'); console.log('BUNDLE_ACTIVE queryBundleActiveStates promise success.');
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
...@@ -55,7 +67,7 @@ import stats from '@ohos.bundleState'; ...@@ -55,7 +67,7 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE queryBundleActiveStates promise failed, because: ' + err.code); console.log('BUNDLE_ACTIVE queryBundleActiveStates promise failed, because: ' + err.code);
}); });
// Use an asynchronous callback to return the result. // Asynchronous callback mode
stats.queryBundleActiveStates(0, 20000000000000, (err, res) => { stats.queryBundleActiveStates(0, 20000000000000, (err, res) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE queryBundleActiveStates callback failed, because: ' + err.code);
...@@ -74,7 +86,7 @@ import stats from '@ohos.bundleState'; ...@@ -74,7 +86,7 @@ import stats from '@ohos.bundleState';
```js ```js
import stats from '@ohos.bundleState' import stats from '@ohos.bundleState'
// Use a promise to return the result. // Promise mode
stats.queryBundleStateInfos(0, 20000000000000).then( res => { stats.queryBundleStateInfos(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.'); console.log('BUNDLE_ACTIVE queryBundleStateInfos promise success.');
let i = 1; let i = 1;
...@@ -87,7 +99,7 @@ import stats from '@ohos.bundleState'; ...@@ -87,7 +99,7 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE queryBundleStateInfos promise failed, because: ' + err.code); console.log('BUNDLE_ACTIVE queryBundleStateInfos promise failed, because: ' + err.code);
}); });
// Use an asynchronous callback to return the result. // Asynchronous callback mode
stats.queryBundleStateInfos(0, 20000000000000, (err, res) => { stats.queryBundleStateInfos(0, 20000000000000, (err, res) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE queryBundleStateInfos callback failed, because: ' + err.code);
...@@ -108,7 +120,7 @@ import stats from '@ohos.bundleState'; ...@@ -108,7 +120,7 @@ import stats from '@ohos.bundleState';
```js ```js
import stats from '@ohos.bundleState' import stats from '@ohos.bundleState'
// Use a promise to return the result. // Promise mode
stats.queryCurrentBundleActiveStates(0, 20000000000000).then( res => { stats.queryCurrentBundleActiveStates(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.'); console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise success.');
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
...@@ -119,7 +131,7 @@ import stats from '@ohos.bundleState'; ...@@ -119,7 +131,7 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise failed, because: ' + err.code); console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates promise failed, because: ' + err.code);
}); });
// Use an asynchronous callback to return the result. // Asynchronous callback mode
stats.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => { stats.queryCurrentBundleActiveStates(0, 20000000000000, (err, res) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE queryCurrentBundleActiveStates callback failed, because: ' + err.code);
...@@ -138,7 +150,7 @@ import stats from '@ohos.bundleState'; ...@@ -138,7 +150,7 @@ import stats from '@ohos.bundleState';
```js ```js
import stats from '@ohos.bundleState' import stats from '@ohos.bundleState'
// Use a promise to return the result. // Promise mode
stats.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => { stats.queryBundleStateInfoByInterval(0, 0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.'); console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise success.');
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
...@@ -149,7 +161,7 @@ import stats from '@ohos.bundleState'; ...@@ -149,7 +161,7 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise failed, because: ' + err.code); console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval promise failed, because: ' + err.code);
}); });
// Use an asynchronous callback to return the result. // Asynchronous callback mode
stats.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => { stats.queryBundleStateInfoByInterval(0, 0, 20000000000000, (err, res) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE queryBundleStateInfoByInterval callback failed, because: ' + err.code);
...@@ -163,19 +175,19 @@ import stats from '@ohos.bundleState'; ...@@ -163,19 +175,19 @@ import stats from '@ohos.bundleState';
}); });
``` ```
6. Query the priority group of the current invoker application. This requires no permission to be configured in the **config.json** file. 6. Query the priority group of the current application. This requires no permission to be configured in the **config.json** file.
```js ```js
import stats from '@ohos.bundleState' import stats from '@ohos.bundleState'
// Use a promise to return the result. // Promise mode
stats.queryAppUsagePriorityGroup().then( res => { stats.queryAppUsagePriorityGroup().then( res => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch( err => { }).catch( err => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code); console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code);
}); });
// Use an asynchronous callback to return the result. // Callback mode
stats.queryAppUsagePriorityGroup((err, res) => { stats.queryAppUsagePriorityGroup((err, res) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code); console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
...@@ -185,19 +197,19 @@ import stats from '@ohos.bundleState'; ...@@ -185,19 +197,19 @@ import stats from '@ohos.bundleState';
}); });
``` ```
7. Check whether the application specified by **bundleName** is in the idle state. This requires no permission to be configured in the **config.json** file. 7. Check whether the application specified by **bundleName** is in the idle state. This requires no permission to be configured in the **config.json** file. A third-party application can only check the idle status of itself.
```js ```js
import stats from '@ohos.bundleState' import stats from '@ohos.bundleState'
// Use a promise to return the result. // Promise mode
stats.isIdleState("com.ohos.camera").then( res => { stats.isIdleState("com.ohos.camera").then( res => {
console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res)); console.log('BUNDLE_ACTIVE isIdleState promise succeeded, result: ' + JSON.stringify(res));
}).catch( err => { }).catch( err => {
console.log('BUNDLE_ACTIVE isIdleState promise failed, because: ' + err.code); console.log('BUNDLE_ACTIVE isIdleState promise failed, because: ' + err.code);
}); });
// Use an asynchronous callback to return the result. // Asynchronous callback mode
stats.isIdleState("com.ohos.camera", (err, res) => { stats.isIdleState("com.ohos.camera", (err, res) => {
if (err) { if (err) {
console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE isIdleState callback failed, because: ' + err.code);
...@@ -212,7 +224,7 @@ import stats from '@ohos.bundleState'; ...@@ -212,7 +224,7 @@ import stats from '@ohos.bundleState';
```js ```js
import stats from '@ohos.bundleState' import stats from '@ohos.bundleState'
// Use a promise to return the result. // Promise mode
stats.getRecentlyUsedModules(1000).then( res => { stats.getRecentlyUsedModules(1000).then( res => {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded'); console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded');
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
...@@ -223,7 +235,7 @@ import stats from '@ohos.bundleState'; ...@@ -223,7 +235,7 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code); console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code);
}); });
// Use a promise to return the result when maxNum is not specified. // Promise mode when maxNum is not specified
stats.getRecentlyUsedModules().then( res => { stats.getRecentlyUsedModules().then( res => {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded'); console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded');
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
...@@ -234,7 +246,7 @@ import stats from '@ohos.bundleState'; ...@@ -234,7 +246,7 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code); console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code);
}); });
// Use an asynchronous callback to return the result. // Asynchronous callback mode
stats.getRecentlyUsedModules(1000,(err, res) => { stats.getRecentlyUsedModules(1000,(err, res) => {
if(err) { if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
...@@ -247,7 +259,7 @@ import stats from '@ohos.bundleState'; ...@@ -247,7 +259,7 @@ import stats from '@ohos.bundleState';
} }
}); });
// Use an asynchronous callback to return the result when maxNum is not specified. // Asynchronous callback mode when maxNum is not specified
stats.getRecentlyUsedModules((err, res) => { stats.getRecentlyUsedModules((err, res) => {
if(err) { if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
...@@ -260,3 +272,168 @@ import stats from '@ohos.bundleState'; ...@@ -260,3 +272,168 @@ import stats from '@ohos.bundleState';
} }
}); });
``` ```
9. Query the number of notifications from all applications based on the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file.
```js
import stats from '@ohos.bundleState'
// Promise mode
stats.queryAppNotificationNumber(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise success.');
console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise result ' + JSON.stringify(res));
}).catch( err => {
console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise failed, because: ' + err.code);
});
// Asynchronous callback mode
stats.queryAppNotificationNumber(0, 20000000000000, (err, res) => {
if (err) {
console.log('BUNDLE_ACTIVE queryAppNotificationNumber callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryAppNotificationNumber callback success.');
console.log('BUNDLE_ACTIVE queryAppNotificationNumber callback result ' + JSON.stringify(res));
}
});
```
10. Query statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file.
```js
import stats from '@ohos.bundleState'
// Promise mode
stats.queryBundleActiveEventStates(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise success.');
console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise result ' + JSON.stringify(res));
}).catch( err => {
console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise failed, because: ' + err.code);
});
// Asynchronous callback mode
stats.queryBundleActiveEventStates(0, 20000000000000, (err, res) => {
if (err) {
console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback success.');
console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback result ' + JSON.stringify(res));
}
});
```
11. Query the priority group of the current application. This requires no permission to be configured in the **config.json** file. Query the priority group of a specified application. This requires the **ohos.permission.BUNDLE_ACTIVE_INFO** permission to be configured in the **config.json** file.
```js
import stats from '@ohos.bundleState'
// Promise mode without parameters
stats.queryAppUsagePriorityGroup().then( res => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch( err => {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code);
});
// Asynchronous callback mode without parameters
stats.queryAppUsagePriorityGroup((err, res) => {
if (err) {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res));
}
});
// Promise mode with parameters
stats.queryAppUsagePriorityGroup(this.bundleName).then( res => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch( err => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code);
});
// Asynchronous callback mode with parameters
stats.queryAppUsagePriorityGroup(this.bundleName, (err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE QueryPackageGroup callback succeeded. result: ' + JSON.stringify(res));
}
});
```
11. Set the group for the application specified by **bundleName**.
```javascript
import stats from '@ohos.bundleState'
// Promise mode
stats.setBundleGroup(this.bundleName, this.newGroup).then( () => {
console.log('BUNDLE_ACTIVE SetBundleGroup promise succeeded.');
}).catch( err => {
console.log('BUNDLE_ACTIVE SetBundleGroup promise failed. because: ' + err.code);
});
// Asynchronous callback mode
stats.setBundleGroup(this.bundleName, this.newGroup, (err) => {
if(err) {
console.log('BUNDLE_ACTIVE SetBundleGroup callback failed. because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE SetBundleGroup callback succeeded.');
}
});
```
12. 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.
```javascript
import stats from '@ohos.bundleState'
// Promise mode
let onBundleGroupChanged = (err,res) =>{
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.');
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result oldGroup is : ' + res.oldGroup);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result newGroup is : ' + res.newGroup);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result changeReason is : ' + res.newGroup);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result userId is : ' + res.userId);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result bundleName is : ' + res.bundleName);
};
stats.registerGroupCallBack(onBundleGroupChanged).then( () => {
console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise succeeded.');
}).catch( err => {
console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise failed. because: ' + err.code);
});
// Asynchronous callback mode
let onBundleGroupChanged = (err,res) =>{
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.');
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's oldGroup is : ' + res.oldGroup);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's newGroup is : ' + res.newGroup);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's changeReason is : ' + res.newGroup);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's userId is : ' + res.userId);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's bundleName is : ' + res.bundleName);
};
stats.registerGroupCallBack(onBundleGroupChanged, (err)=>{
if(err) {
console.log('BUNDLE_ACTIVE RegisterGroupCallBack callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE RegisterGroupCallBack callback success.');
}
});
```
13. Deregister the callback for application group changes.
```javascript
import stats from '@ohos.bundleState'
//promise
stats.unRegisterGroupCallBack().then( () => {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise succeeded.');
}).catch( err => {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise failed. because: ' + err.code);
});
//callback
stats.unRegisterGroupCallBack((err)=>{
if(err) {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback success.');
}
});
```
...@@ -13,21 +13,28 @@ Currently you can have access to statistics on the application usage, and notifi ...@@ -13,21 +13,28 @@ Currently you can have access to statistics on the application usage, and notifi
- **The application usage statistics can include the following**: - **The application usage statistics can include the following**:
1. Events of all applications based on the specified start time and end time 1. Events of all applications based on the specified start time and end time
2. Application usage duration statistics based on the specified start time and end time 2. Application usage duration statistics based on the specified start time and end time
3. Events of the current application based on the specified start time and end time 3. Events of the current application based on the specified start time and end time
4. Application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually) 4. Application usage duration statistics in the specified time frame at the specified interval (daily, weekly, monthly, or annually)
5. Priority group of the current invoker application 5. Priority group of the current invoker application
6. Whether a specific application is in the idle state 6. Whether a specific application is in the idle state
7. 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.
8. Number of notifications from applications based on the specified start time and end time
9. Statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time
9. 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.
7. The number of FA usage records specified by **maxNum**, sorted by time (most recent first) - **The deregistration APIs can be used to:**
If **maxNum** is not specified, the default value **1000** will be used. Deregister the callback for application group changes.
### Required Permissions ### Required Permissions
- The **queryBundleActiveStates**, **queryBundleStateInfos**, and **queryBundleStateInfoByInterval** APIs used for device usage statistics are system APIs. Before calling these APIs, you need to apply for the **ohos.permission.BUNDLE_ACTIVE_INFO** permission. - Before calling the following system APIs, you need to apply for the **ohos.permission.BUNDLE_ACTIVE_INFO** permission: **queryBundleActiveStates**, **queryBundleStateInfos**, **queryBundleStateInfoByInterval**, **queryBundleActiveEventStates**, **queryAppNotificationNumber**, **queryAppUsagePriorityGroup(bundleName?)**, **setBundleGroup**, **registerGroupCallBack**, and **unRegisterGroupCallBack**.
- This permission is not required for calling **queryCurrentBundleActiveStates**, **queryAppUsagePriorityGroup**, and **isIdleState**, which are third-party APIs. - This permission is not required for calling third-party APIs: **queryCurrentBundleActiveStates**, **queryAppUsagePriorityGroup()**, and **isIdleState**.
...@@ -123,7 +123,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column ...@@ -123,7 +123,7 @@ Add **Column**, **Text**, and **Button** components to the first page. A column
## Implementing Page Redirection ## Implementing Page Redirection
You can implement page redirection through the page router, which finds the target page based on the page URI. Import the **router** module and then perform the steps below: You can implement page redirection through the page router, which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page. 1. Implement redirection from the first page to the second page.
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
- **src &gt; main &gt; ets &gt; MainAbility &gt; app.ets**: ability lifecycle file. - **src &gt; main &gt; ets &gt; MainAbility &gt; app.ets**: ability lifecycle file.
- **src &gt; main &gt; resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. - **src &gt; main &gt; resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files.
- **src &gt; main &gt; config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. - **src &gt; main &gt; config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file.
- **build-profile.json5**: current module information and build configuration options, including **buildOption target**. - **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**.
- **hvigorfile.js**: module-level compilation and build task script. You can customize related tasks and code implementation. - **hvigorfile.js**: module-level compilation and build task script. You can customize related tasks and code implementation.
- **build-profile.json5**: application-level configuration information, including the signature and product configuration. - **build-profile.json5**: application-level configuration information, including the signature and product configuration.
- **hvigorfile.js**: application-level compilation and build task script. - **hvigorfile.js**: application-level compilation and build task script.
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
## Implementing Page Redirection ## Implementing Page Redirection
You can implement page redirection through the page router, which finds the target page based on the page URI. Import the **router** module and then perform the steps below: You can implement page redirection through the page router, which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page. 1. Implement redirection from the first page to the second page.
......
...@@ -109,7 +109,7 @@ Open the index.visual file, right-click the existing template components on the ...@@ -109,7 +109,7 @@ Open the index.visual file, right-click the existing template components on the
## Implementing Page Redirection ## Implementing Page Redirection
You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URI. Import the **router** module and then perform the steps below: You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page. 1. Implement redirection from the first page to the second page.
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
- **src &gt; main &gt; js &gt; MainAbility &gt; app.js**: ability lifecycle file. - **src &gt; main &gt; js &gt; MainAbility &gt; app.js**: ability lifecycle file.
- **src &gt; main &gt; resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files. - **src &gt; main &gt; resources**: a collection of resource files used by your application/service, such as graphics, multimedia, character strings, and layout files.
- **src &gt; main &gt; config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file. - **src &gt; main &gt; config.json**: module configuration file. This file describes the global configuration information of the application/service, the device-specific configuration information, and the configuration information of the HAP file.
- **build-profile.json5**: current module information and build configuration options, including **buildOption target**. - **build-profile.json5**: current module information and build configuration options, including **buildOption** and **targets**.
- **hvigorfile.js**: module-level compilation and build task script. You can customize related tasks and code implementation. - **hvigorfile.js**: module-level compilation and build task script. You can customize related tasks and code implementation.
- **build-profile.json5**: application-level configuration information, including the signature and product configuration. - **build-profile.json5**: application-level configuration information, including the signature and product configuration.
- **hvigorfile.js**: application-level compilation and build task script. - **hvigorfile.js**: application-level compilation and build task script.
...@@ -168,7 +168,7 @@ ...@@ -168,7 +168,7 @@
## Implementing Page Redirection ## Implementing Page Redirection
You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URI. Import the **router** module and then perform the steps below: You can implement page redirection through the [page router](../ui/ui-js-building-ui-routes.md), which finds the target page based on the page URL. Import the **router** module and then perform the steps below:
1. Implement redirection from the first page to the second page. 1. Implement redirection from the first page to the second page.
......
# Device Usage Statistics # Device Usage Statistics
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > **NOTE**<br>
> > The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import ## Modules to Import
...@@ -14,16 +14,16 @@ import bundleState from '@ohos.bundleState' ...@@ -14,16 +14,16 @@ import bundleState from '@ohos.bundleState'
isIdleState(bundleName: string, callback: AsyncCallback&lt;boolean&gt;): void isIdleState(bundleName: string, callback: AsyncCallback&lt;boolean&gt;): void
Checks whether the application specified by **bundleName** is in the idle state. This API uses an asynchronous callback to return the result. Checks whether the application specified by **bundleName** is in the idle state. This API uses an asynchronous callback to return the result. A third-party application can only check the idle status of itself.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---------- | ---------------------------- | ---- | ---------------------------------------- |
| bundleName | string | Yes| Bundle name of an application.| | bundleName | string | Yes | Bundle name of an application. |
| callback | AsyncCallback&lt;boolean&gt; | Yes| Callback used to return the result. Returns whether the application specified by **bundleName** is in the idle state if the value of **bundleName** is valid; returns **null** otherwise.| | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. If the value of **bundleName** is valid, **null** will be returned.|
**Example** **Example**
...@@ -41,21 +41,21 @@ Checks whether the application specified by **bundleName** is in the idle state. ...@@ -41,21 +41,21 @@ Checks whether the application specified by **bundleName** is in the idle state.
isIdleState(bundleName: string): Promise&lt;boolean&gt; isIdleState(bundleName: string): Promise&lt;boolean&gt;
Checks whether the application specified by **bundleName** is in the idle state. This API uses a promise to return the result. Checks whether the application specified by **bundleName** is in the idle state. This API uses a promise to return the result. A third-party application can only check the idle status of itself.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---------- | ------ | ---- | -------------- |
| bundleName | string | Yes| Bundle name of an application.| | bundleName | string | Yes | Bundle name of an application.|
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ---------------------- | ---------------------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result. Returns whether the application specified by **bundleName** is in the idle state if the value of **bundleName** is valid; returns **null** otherwise.| | Promise&lt;boolean&gt; | Promise used to return the result. If the value of **bundleName** is valid, **null** will be returned.|
**Example** **Example**
...@@ -69,53 +69,62 @@ Checks whether the application specified by **bundleName** is in the idle state. ...@@ -69,53 +69,62 @@ Checks whether the application specified by **bundleName** is in the idle state.
## bundleState.queryAppUsagePriorityGroup ## bundleState.queryAppUsagePriorityGroup
queryAppUsagePriorityGroup(callback: AsyncCallback&lt;number&gt;): void queryAppUsagePriorityGroup(): Promise\<number>
Queries the priority group of the current invoker application. This API uses an asynchronous callback to return the result. Queries the priority group of this application. This API uses a promise to return the result.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**Parameters** **Return value**
| Name| Type| Mandatory| Description| | Type | Description |
| -------- | -------- | -------- | -------- | | --------------- | --------------------------- |
| callback | AsyncCallback&lt;number&gt; | Yes| Callback used to return the result.| | Promise\<number> | Promise used to return the result.|
**Example** **Example**
```js ```javascript
bundleState.queryAppUsagePriorityGroup((err, res) => { bundleState.queryAppUsagePriorityGroup().then( res => {
if (err) { console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback failed. because: ' + err.code); }).catch( err => {
} else { console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code);
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup callback succeeded. result: ' + JSON.stringify(res)); });
} ```
});
```
## bundleState.queryAppUsagePriorityGroup ## bundleState.queryAppUsagePriorityGroup
queryAppUsagePriorityGroup(): Promise&lt;number&gt; queryAppUsagePriorityGroup(callback: AsyncCallback\<number>): void
Queries the priority group of the current invoker application. This API uses a promise to return the result. Queries the priority group of this application. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**Return value** **Parameters**
| Type| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | | -------- | --------------------- | ---- | -------------------------- |
| Promise&lt;number&gt; | Promise used to return the result.| | callback | AsyncCallback\<number> | Yes | Callback used to return the result.|
**Example** **Example**
```js ```javascript
bundleState.queryAppUsagePriorityGroup().then( res => { // Callback with bundleName
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise succeeded. result: ' + JSON.stringify(res)); bundleState.queryAppUsagePriorityGroup(this.bundleName, (err, res) => {
}).catch( err => { if(err) {
console.log('BUNDLE_ACTIVE queryAppUsagePriorityGroup promise failed. because: ' + err.code); console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code);
}); } else {
``` console.log('BUNDLE_ACTIVE QueryPackageGroup callback succeeded. result: ' + JSON.stringify(res));
}
});
// Callback without bundleName
bundleState.queryAppUsagePriorityGroup((err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE QueryPackageGroup callback succeeded. result: ' + JSON.stringify(res));
}
});
```
## bundleState.queryBundleStateInfos ## bundleState.queryBundleStateInfos
...@@ -127,13 +136,15 @@ Queries the application usage duration statistics based on the specified start t ...@@ -127,13 +136,15 @@ Queries the application usage duration statistics based on the specified start t
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | --------------------------------------- |
| begin | number | Yes| Start time.| | begin | number | Yes | Start time. |
| end | number | Yes| End time.| | end | number | Yes | End time. |
| callback | AsyncCallback&lt;[BundleActiveInfoResponse](#bundleactiveinforesponse)&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;[BundleActiveInfoResponse](#bundleactiveinforesponse)&gt; | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -163,17 +174,19 @@ Queries the application usage duration statistics based on the specified start t ...@@ -163,17 +174,19 @@ Queries the application usage duration statistics based on the specified start t
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ----- |
| begin | number | Yes| Start time.| | begin | number | Yes | Start time.|
| end | number | Yes| End time.| | end | number | Yes | End time.|
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ---------------------------------------- | -------------------------------------- |
| Promise&lt;[BundleActiveInfoResponse](#bundleactiveinforesponse)&gt; | Promise used to return the result.| | Promise&lt;[BundleActiveInfoResponse](#bundleactiveinforesponse)&gt; | Promise used to return the result.|
**Example** **Example**
...@@ -202,14 +215,16 @@ Queries the application usage duration statistics in the specified time frame at ...@@ -202,14 +215,16 @@ Queries the application usage duration statistics in the specified time frame at
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---------- | ---------------------------------------- | ---- | ---------------------------------------- |
| byInterval | [IntervalType](#intervaltype) | Yes| Interval type.| | byInterval | [IntervalType](#intervaltype) | Yes | Type of information to be queried. |
| begin | number | Yes| Start time.| | begin | number | Yes | Start time. |
| end | number | Yes| End time.| | end | number | Yes | End time. |
| callback | AsyncCallback&lt;Array&lt;[BundleStateInfo](#bundlestateinfo)&gt;&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;Array&lt;[BundleStateInfo](#bundlestateinfo)&gt;&gt; | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -237,18 +252,20 @@ Queries the application usage duration statistics in the specified time frame at ...@@ -237,18 +252,20 @@ Queries the application usage duration statistics in the specified time frame at
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---------- | ----------------------------- | ---- | ----- |
| byInterval | [IntervalType](#intervaltype) | Yes| Interval type.| | byInterval | [IntervalType](#intervaltype) | Yes | Type of information to be queried.|
| begin | number | Yes| Start time.| | begin | number | Yes | Start time.|
| end | number | Yes| End time.| | end | number | Yes | End time.|
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ---------------------------------------- | ---------------------------------------- |
| Promise&lt;Array&lt;[BundleStateInfo](#bundlestateinfo)&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;[BundleStateInfo](#bundlestateinfo)&gt;&gt; | Promise used to return the result.|
**Example** **Example**
...@@ -275,13 +292,15 @@ Queries events of all applications based on the specified start time and end tim ...@@ -275,13 +292,15 @@ Queries events of all applications based on the specified start time and end tim
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | --------------------------------------- |
| begin | number | Yes| Start time.| | begin | number | Yes | Start time. |
| end | number | Yes| End time.| | end | number | Yes | End time. |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -309,17 +328,19 @@ Queries events of all applications based on the specified start time and end tim ...@@ -309,17 +328,19 @@ Queries events of all applications based on the specified start time and end tim
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ----- |
| begin | number | Yes| Start time.| | begin | number | Yes | Start time.|
| end | number | Yes| End time.| | end | number | Yes | End time.|
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ---------------------------------------- | -------------------------------------- |
| Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result.|
**Example** **Example**
...@@ -346,11 +367,11 @@ Queries events of this application based on the specified start time and end tim ...@@ -346,11 +367,11 @@ Queries events of this application based on the specified start time and end tim
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | --------------------------------------- |
| begin | number | Yes| Start time.| | begin | number | Yes | Start time. |
| end | number | Yes| End time.| | end | number | Yes | End time. |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -378,15 +399,15 @@ Queries events of this application based on the specified start time and end tim ...@@ -378,15 +399,15 @@ Queries events of this application based on the specified start time and end tim
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ----- | ------ | ---- | ----- |
| begin | number | Yes| Start time.| | begin | number | Yes | Start time.|
| end | number | Yes| End time.| | end | number | Yes | End time.|
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ---------------------------------------- | -------------------------------------- |
| Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;[BundleActiveState](#bundleactivestate)&gt;&gt; | Promise used to return the result.|
**Example** **Example**
...@@ -413,22 +434,24 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses a ...@@ -413,22 +434,24 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses a
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------ | ------ | ---- | ---------------------------------- |
| maxNum | number | No| Maximum number of returned records. The maximum and default value is **1000**. If this parameter is not specified, **1000** is used.| | maxNum | number | No | Maximum number of returned records. The maximum and default value is **1000**. If this parameter is not specified, **1000** is used.|
**Return value** **Return value**
| Type| Description| | Type | Description |
| -------- | -------- | | ---------------------------------------- | ---------------------------------- |
| Promise&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Promise used to return the result.| | Promise&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Promise used to return the result.|
**Example** **Example**
```js ```js
bundleState.getRecentlyUsedModules(this.maxNum).then( res => { bundleState.getRecentlyUsedModules(1000).then( res => {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded'); console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded');
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise number : ' + (i + 1)); console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise number : ' + (i + 1));
...@@ -460,17 +483,19 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses an ...@@ -460,17 +483,19 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses an
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | ---------------------------------------- | ---- | ----------------------------------- |
| maxNum | number | No| Maximum number of returned records. The maximum and default value is **1000**. If this parameter is not specified, **1000** is used.| | maxNum | number | No | Maximum number of returned records. The maximum and default value is **1000**. If this parameter is not specified, **1000** is used. |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Yes| Callback used to return the result.| | callback | AsyncCallback&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivemoduleinfo9)&gt;&gt; | Yes | Callback used to return the result.|
**Example** **Example**
```js ```js
bundleState.getRecentlyUsedModules(this.maxNum,(err, res) => { bundleState.getRecentlyUsedModules(1000,(err, res) => {
if(err) { if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
} else { } else {
...@@ -483,7 +508,7 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses an ...@@ -483,7 +508,7 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses an
}); });
// Invocation when maxNum is not passed // Invocation when maxNum is not passed
stats.getRecentlyUsedModules((err, res) => { bundleState.getRecentlyUsedModules((err, res) => {
if(err) { if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code); console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
} else { } else {
...@@ -496,59 +521,507 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses an ...@@ -496,59 +521,507 @@ Obtains the number of FA usage records specified by **maxNum**. This API uses an
}); });
``` ```
## bundleState.queryAppUsagePriorityGroup<sup>9+</sup>
queryAppUsagePriorityGroup(bundleName? : string): Promise<number>
Queries the priority group of the application specified by **bundleName**. If **bundleName** is not specified, the priority group of the current application is queried. This API uses a promise to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
| ---------- | ------ | ---- | ---------------------------------------- |
| bundleName | string | No | Bundle name of the target application. If this parameter is not specified, the priority group of the current application is queried.|
**Return value**
| Type | Description |
| --------------- | --------------------------- |
| Promise\<number> | Promise used to return the result.|
**Example**
```javascript
// Promise with bundleName
bundleState.queryAppUsagePriorityGroup(this.bundleName).then( res => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch( err => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code);
});
// Promise without bundleName
bundleState.queryAppUsagePriorityGroup().then( res => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise succeeded. result: ' + JSON.stringify(res));
}).catch( err => {
console.log('BUNDLE_ACTIVE QueryPackageGroup promise failed. because: ' + err.code);
});
```
## bundleState.queryAppUsagePriorityGroup<sup>9+</sup>
queryAppUsagePriorityGroup(bundleName? : string, callback: AsyncCallback\<number>): void
Queries the priority group of the application specified by **bundleName**. If **bundleName** is not specified, the priority group of the current application is queried. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
| ---------- | --------------------- | ---- | ---------------------------------------- |
| bundleName | string | No | Bundle name of the target application. If this parameter is not specified, the priority group of the current application is queried.|
| callback | AsyncCallback\<number> | Yes | Callback used to return the result. |
**Example**
```javascript
// Callback with bundleName
bundleState.queryAppUsagePriorityGroup(this.bundleName, (err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE QueryPackageGroup callback succeeded. result: ' + JSON.stringify(res));
}
});
// Callback without bundleName
bundleState.queryAppUsagePriorityGroup((err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE QueryPackageGroup callback failed. because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE QueryPackageGroup callback succeeded. result: ' + JSON.stringify(res));
}
});
```
## bundleState.setBundleGroup<sup>9+</sup>
setBundleGroup(bundleName: string, newGroup: GroupType): Promise\<void>
Sets the group for the application specified by **bundleName**. This API uses a promise to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
| ---------- | --------- | ---- | ---- |
| bundleName | string | Yes | Bundle name of the target application.|
| newGroup | GroupType | Yes | Application group.|
**Return value**
| Type | Description |
| ------------- | ------------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```javascript
this.bundleName = "com.example.deviceUsageStatistics";
this.newGroup = stats.GroupType.ACTIVE_GROUP_DAILY;
bundleState.setBundleGroup(this.bundleName, this.newGroup).then( () => {
console.log('BUNDLE_ACTIVE SetBundleGroup promise succeeded.');
}).catch( err => {
console.log('BUNDLE_ACTIVE SetBundleGroup promise failed. because: ' + err.code);
});
```
## bundleState.setBundleGroup<sup>9+</sup>
setBundleGroup(bundleName: string, newGroup: GroupType, callback: AsyncCallback\<void>): void
Sets the group for the application specified by **bundleName**. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
| ---------- | ------------------- | ---- | ------------------------- |
| bundleName | string | Yes | Bundle name of the target application. |
| newGroup | GroupType | Yes | Application group. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```javascript
this.bundleName = "com.example.deviceUsageStatistics";
this.newGroup = stats.GroupType.ACTIVE_GROUP_DAILY;
bundleState.setBundleGroup(this.bundleName, this.newGroup, (err) => {
if(err) {
console.log('BUNDLE_ACTIVE SetBundleGroup callback failed. because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE SetBundleGroup callback succeeded.');
}
});
```
## bundleState.registerGroupCallBack<sup>9+</sup>
registerGroupCallBack(callback: Callback\<BundleActiveGroupCallbackInfo>): Promise\<void>
Registers a callback for application group changes. When an application group of the user changes, **BundleActiveGroupCallbackInfo** is returned to all applications that have registered the callback. This API uses a promise to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | --------------------------------------- | ---- | ----------- |
| callback | Callback\<BundleActiveGroupCallbackInfo> | Yes | Callback for application group changes.|
**Return value**
| Type | Description |
| ------------- | ----------------------- |
| Promise\<void> | Promise used to return the result.|
**Example**
```javascript
let onBundleGroupChanged = (err,res) =>{
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.');
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result oldGroup is : ' + res.oldGroup);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result newGroup is : ' + res.newGroup);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result changeReason is : ' + res.newGroup);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result userId is : ' + res.userId);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result bundleName is : ' + res.bundleName);
};
bundleState.registerGroupCallBack(onBundleGroupChanged).then( () => {
console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise succeeded.');
}).catch( err => {
console.log('BUNDLE_ACTIVE RegisterGroupCallBack promise failed. because: ' + err.code);
});
```
## bundleState.registerGroupCallBack<sup>9+</sup>
registerGroupCallBack(callback: Callback\<BundleActiveGroupCallbackInfo>, callback: AsyncCallback\<void>): void
Registers a callback for application group changes. When an application group of the user changes, **BundleActiveGroupCallbackInfo** is returned to all applications that have registered the callback. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | --------------------------------------- | ---- | ------------- |
| callback | Callback\<BundleActiveGroupCallbackInfo> | Yes | Callback for application group changes. |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```javascript
let onBundleGroupChanged = (err,res) =>{
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack callback success.');
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's oldGroup is : ' + res.oldGroup);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's newGroup is : ' + res.newGroup);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's changeReason is : ' + res.newGroup);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's userId is : ' + res.userId);
console.log('BUNDLE_ACTIVE onBundleGroupChanged RegisterGroupCallBack result's bundleName is : ' + res.bundleName);
};
bundleState.registerGroupCallBack(onBundleGroupChanged, (err)=>{
if(err) {
console.log('BUNDLE_ACTIVE RegisterGroupCallBack callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE RegisterGroupCallBack callback success.');
}
});
```
## bundleState.unRegisterGroupCallBack<sup>9+</sup>
unRegisterGroupCallBack(): Promise\<void>
Deregisters the callback for application group changes. This API uses a promise to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**: none
**Return value**
| Type | Description |
| ------------- | ------------------------ |
| Promise\<void> | Promise used to return the result.|
**Example**
```javascript
bundleState.unRegisterGroupCallBack().then( () => {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise succeeded.');
}).catch( err => {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack promise failed. because: ' + err.code);
});
```
## bundleState.unRegisterGroupCallBack<sup>9+</sup>
unRegisterGroupCallBack(callback: AsyncCallback\<void>): void;
Deregisters the callback for application group changes. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ------------------- | ---- | -------------- |
| callback | AsyncCallback\<void> | Yes | Callback used to return the result.|
**Example**
```javascript
bundleState.unRegisterGroupCallBack((err)=>{
if(err) {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE UnRegisterGroupCallBack callback success.');
}
});
```
## bundleState.queryBundleActiveEventStates<sup>9+</sup>
queryBundleActiveEventStates(begin: number, end: number): Promise&lt;Array&lt;BundleActiveEventState&gt;&gt;
Queries statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time. This API uses a promise to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ----- |
| begin | number | Yes | Start time.|
| end | number | Yes | End time.|
**Return value**
| Type | Description |
| ---------------------------------------- | ---------------------------------------- |
| Promise&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Promise used to return the result.|
**Example**
```js
bundleState.queryBundleActiveEventStates(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise success.');
console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise result ' + JSON.stringify(res));
}).catch( err=> {
console.log('BUNDLE_ACTIVE queryBundleActiveEventStates promise failed, because: ' + err.code);
});
```
## bundleState.queryBundleActiveEventStates<sup>9+</sup>
queryBundleActiveEventStates(begin: number, end: number, callback: AsyncCallback&lt;Array&lt;BundleActiveEventState&gt;&gt;): void
Queries statistics about system events (hibernation, wakeup, unlocking, and screen locking) that occur between the specified start time and end time. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| begin | number | Yes | Start time. |
| end | number | Yes | End time. |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Yes | Promise used to return the result.|
**Example**
```js
bundleState.queryBundleActiveEventStates(0, 20000000000000, (err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback success.');
console.log('BUNDLE_ACTIVE queryBundleActiveEventStates callback result ' + JSON.stringify(res));
}
});
```
## bundleState.queryAppNotificationNumber<sup>9+</sup>
queryAppNotificationNumber(begin: number, end: number): Promise&lt;Array&lt;BundleActiveEventState&gt;&gt;
Queries the number of notifications from all applications based on the specified start time and end time. This API uses a promise to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
| ----- | ------ | ---- | ----- |
| begin | number | Yes | Start time.|
| end | number | Yes | End time.|
**Return value**
| Type | Description |
| ---------------------------------------- | ---------------------------------------- |
| Promise&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Promise used to return the result.|
**Example**
```js
bundleState.queryAppNotificationNumber(0, 20000000000000).then( res => {
console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise success.');
console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise result ' + JSON.stringify(res));
}).catch( err=> {
console.log('BUNDLE_ACTIVE queryAppNotificationNumber promise failed, because: ' + err.code);
});
```
## bundleState.queryAppNotificationNumber<sup>9+</sup>
queryAppNotificationNumber(begin: number, end: number, callback: AsyncCallback&lt;Array&lt;BundleActiveEventState&gt;&gt;): void
Queries the number of notifications from all applications based on the specified start time and end time. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.BUNDLE_ACTIVE_INFO
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| begin | number | Yes | Start time. |
| end | number | Yes | End time. |
| callback | AsyncCallback&lt;Array&lt;[BundleActiveEventState](#bundleactiveeventstate9)&gt;&gt; | Yes | Callback used to return the result.|
**Example**
```js
bundleState.queryAppNotificationNumber(0, 20000000000000, (err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE queryAppNotificationNumberCallBack callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE queryAppNotificationNumberCallBack callback success.');
console.log('BUNDLE_ACTIVE queryAppNotificationNumberCallBack callback result ' + JSON.stringify(res));
}
});
```
## BundleActiveModuleInfo<sup>9+</sup> ## BundleActiveModuleInfo<sup>9+</sup>
Provides the information about the FA usage. Provides the information about the FA usage.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------------------- | ---------------------------------------- | ---- | ----------------------------- |
| deviceId | string | No| ID of the device to which the FA belongs.| | deviceId | string | No | ID of the device to which the FA belongs. |
| bundleName | string | Yes| Name of the application bundle to which the FA belongs.| | bundleName | string | Yes | Name of the application bundle to which the FA belongs. |
| moduleName | string | Yes| Name of the module to which the FA belongs.| | moduleName | string | Yes | Name of the module to which the FA belongs. |
| abilityName | string | No| **MainAbility** name of the FA.| | abilityName | string | No | **MainAbility** name of the FA. |
| appLabelId | number | No| Application label ID of the FA.| | appLabelId | number | No | Application label ID of the FA. |
| labelId | number | No| Label ID of the module to which the FA belongs.| | labelId | number | No | Label ID of the module to which the FA belongs. |
| descriptionId | number | No| Description ID of the application to which the FA belongs.| | descriptionId | number | No | Description ID of the application to which the FA belongs. |
| abilityLableId | number | No| **MainAbility** label ID of the FA.| | abilityLableId | number | No | **MainAbility** label ID of the FA. |
| abilityDescriptionId | number | No| **MainAbility** description ID of the FA.| | abilityDescriptionId | number | No | **MainAbility** description ID of the FA.|
| abilityIconId | number | No| **MainAbility** icon ID of the FA.| | abilityIconId | number | No | **MainAbility** icon ID of the FA. |
| launchedCount | number | Yes| Number of FA startup times.| | launchedCount | number | Yes | Number of FA startup times. |
| lastModuleUsedTime | number | Yes| Last time when the FA is used.| | lastModuleUsedTime | number | Yes | Last time when the FA was used. |
| formRecords | Array&lt;[BundleActiveFormInfo](#bundleactiveforminfo9)&gt; | Yes| Array of widget usage records in the FA.| | formRecords | Array&lt;[BundleActiveFormInfo](#bundleactiveforminfo9)&gt; | Yes | Array of widget usage records in the FA. |
## BundleActiveFormInfo<sup>9+</sup> ## BundleActiveFormInfo<sup>9+</sup>
Provides the FA widget usage information. Provides the FA widget usage information.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ---------------- | ------ | ---- | ----------- |
| formName | number | Yes| Widget name.| | formName | number | Yes | Widget name. |
| formDimension | number | Yes| Widget dimensions.| | formDimension | number | Yes | Widget dimensions. |
| formId | number | Yes| Widget ID.| | formId | number | Yes | Widget ID. |
| formLastUsedTime | number | Yes| Last time when the widget was clicked.| | formLastUsedTime | number | Yes | Last time when the widget was clicked.|
| count | number | Yes| Number of clicks on the widget.| | count | number | Yes | Number of clicks on the widget. |
## BundleActiveGroupCallbackInfo<sup>9+</sup>
Provides the application group changes returned through a callback.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
| Name | Type | Mandatory | Description |
| ---------------- | ------ | ---- | -------- |
| appUsageOldGroup | number | Yes | Application group before the change.|
| appUsageNewGroup | number | Yes | Application group after the change.|
| useId | number | Yes | User ID. |
| changeReason | number | Yes | Reason for the group change. |
| bundleName | string | Yes | Bundle name of an application. |
## BundleStateInfo ## BundleStateInfo
Provides the usage duration information of an application.
Provides the usage duration information of applications.
### Attributes ### Attributes
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------------------------ | ------ | ---- | ---------------------------------------- |
| bundleName | string | Yes| Application bundle name.| | bundleName | string | Yes | Bundle name of the application. |
| abilityPrevAccessTime | number | Yes| Last time when the application was used.| | abilityPrevAccessTime | number | Yes | Last time when the application was used. |
| abilityInFgTotalTime | number | Yes| Total time that the application runs in the foreground.| | abilityInFgTotalTime | number | Yes | Total time that the application runs in the foreground. |
| id | number | No| User ID.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| | id | number | No | User ID.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| abilityPrevSeenTime | number | No| Last time when the application was visible in the foreground.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| | abilityPrevSeenTime | number | No | Last time when the application was visible in the foreground.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| abilitySeenTotalTime | number | No| Total time when the application is visible in the foreground.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| | abilitySeenTotalTime | number | No | Total time that the application is visible in the foreground.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| fgAbilityAccessTotalTime | number | No| Total time that the application accesses the foreground.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| | fgAbilityAccessTotalTime | number | No | Total time that the application accesses the foreground.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| fgAbilityPrevAccessTime | number | No| Last time when the application accessed the foreground.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| | fgAbilityPrevAccessTime | number | No | Last time when the application accessed the foreground.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| infosBeginTime | number | No| Time logged in the first application usage record in the **BundleActiveInfo** object.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| | infosBeginTime | number | No | Time logged in the first application usage record in the **BundleActiveInfo** object.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| infosEndTime | number | No| Time logged in the last application usage record in the **BundleActiveInfo** object.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| | infosEndTime | number | No | Time logged in the last application usage record in the **BundleActiveInfo** object.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
### merge ### merge
...@@ -562,9 +1035,9 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a ...@@ -562,9 +1035,9 @@ This API is defined but not implemented in OpenHarmony 3.1 Release. It will be a
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------- | ----------------------------------- | ---- | -------------- |
| toMerge | [BundleStateInfo](#bundlestateinfo) | Yes| Application usage information to merge.| | toMerge | [BundleStateInfo](#bundlestateinfo) | Yes | Application usage information to merge.|
## BundleActiveState ## BundleActiveState
...@@ -572,14 +1045,14 @@ Provides information about an application event. ...@@ -572,14 +1045,14 @@ Provides information about an application event.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | --------------------- | ------ | ---- | ---------------------------------------- |
| bundleName | string | Yes| Application bundle name.| | bundleName | string | Yes | Bundle name of the application. |
| stateType | number | Yes| Application event type.| | stateType | number | Yes | Application event type. |
| stateOccurredTime | number | Yes| Timestamp when the application event occurs.| | stateOccurredTime | number | Yes | Timestamp when the application event occurs. |
| appUsagePriorityGroup | number | No| Usage priority group of the application.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| | appUsagePriorityGroup | number | No | Usage priority group of the application.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| indexOfLink | string | No| Shortcut ID.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| | indexOfLink | string | No | Shortcut ID.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
| nameOfClass | string | No| Class name.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.| | nameOfClass | string | No | Class name.<br>This API is defined but not implemented in OpenHarmony 3.1 Release. It will be available for use in OpenHarmony 3.1 MR.|
## BundleActiveInfoResponse ## BundleActiveInfoResponse
...@@ -587,9 +1060,23 @@ Provides the usage duration information of applications. ...@@ -587,9 +1060,23 @@ Provides the usage duration information of applications.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
| Name| Type| Mandatory| Description| | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | ------------------------------ | ---------------------------------------- | ---- | -------------- |
| [key: string]: BundleStateInfo | [key: string]: [BundleStateInfo](#bundlestateinfo) | Yes| Usage duration information by application.| | [key: string]: BundleStateInfo | [key: string]: [BundleStateInfo](#bundlestateinfo) | Yes | Usage duration information by application.|
## BundleActiveEventState<sup>9+</sup>
Provides statistics about notifications and system events.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
**System API**: This is a system API and cannot be called by third-party applications.
| Name | Type | Mandatory | Description |
| ------- | ------ | ---- | ----------------- |
| name | string | Yes | Bundle name of the notification sending application or system event name. |
| eventId | number | Yes | Type of the notification or system event. |
| count | number | Yes | Number of application notifications or system event triggering times.|
## IntervalType ## IntervalType
...@@ -597,10 +1084,25 @@ Enumerates the interval types for querying the application usage duration. ...@@ -597,10 +1084,25 @@ Enumerates the interval types for querying the application usage duration.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App **System capability**: SystemCapability.ResourceSchedule.UsageStatistics.App
|Name |Default Value |Description| | Name | Default Value | Description |
| -------- | -------- | -------- | | ------------ | ---- | ---------------------------------------- |
| BY_OPTIMIZED | 0 | The system obtains the application usage duration statistics in the specified time frame at the interval the system deems appropriate.| | BY_OPTIMIZED | 0 | The system obtains the application usage duration statistics in the specified time frame at the interval the system deems appropriate.|
| BY_DAILY | 1 | The system obtains the application usage duration statistics in the specified time frame on a daily basis.| | BY_DAILY | 1 | The system obtains the application usage duration statistics in the specified time frame on a daily basis. |
| BY_WEEKLY | 2 | The system obtains the application usage duration statistics in the specified time frame on a weekly basis.| | BY_WEEKLY | 2 | The system obtains the application usage duration statistics in the specified time frame on a weekly basis. |
| BY_MONTHLY | 3 | The system obtains the application usage duration statistics in the specified time frame on a monthly basis.| | BY_MONTHLY | 3 | The system obtains the application usage duration statistics in the specified time frame on a monthly basis. |
| BY_ANNUALLY | 4 | The system obtains the application usage duration statistics in the specified time frame on an annual basis.| | BY_ANNUALLY | 4 | The system obtains the application usage duration statistics in the specified time frame on an annual basis. |
## GroupType
Enumerates the application group types.
**System capability**: SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
| Name | Default Value | Description |
| ------------------ | ---- | ----------------- |
| ACTIVE_GROUP_ALIVE | 10 | Group of active applications. |
| ACTIVE_GROUP_DAILY | 20 | Group of frequently used applications that are not in the active state. |
| ACTIVE_GROUP_FIXED | 30 | Group of applications that are used periodically but not every day.|
| ACTIVE_GROUP_RARE | 40 | Group of rarely used applications. |
| ACTIVE_GROUP_LIMIT | 50 | Group of restricted applications. |
| ACTIVE_GROUP_NEVER | 60 | Group of applications that have been installed but never run. |
# Pasteboard # Pasteboard
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version. > **NOTE**<br>The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> >
...@@ -48,9 +48,9 @@ Creates a **PasteData** object for plain text. ...@@ -48,9 +48,9 @@ Creates a **PasteData** object for plain text.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("content"); var pasteData = pasteboard.createPlainTextData("content");
``` ```
## pasteboard.createHtmlData<sup>7+</sup> ## pasteboard.createHtmlData<sup>7+</sup>
...@@ -75,10 +75,10 @@ Creates a **PasteData** object for HTML text. ...@@ -75,10 +75,10 @@ Creates a **PasteData** object for HTML text.
**Example** **Example**
```js ```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var pasteData = pasteboard.createHtmlData(html); var pasteData = pasteboard.createHtmlData(html);
``` ```
## pasteboard.createWantData<sup>7+</sup> ## pasteboard.createWantData<sup>7+</sup>
...@@ -103,13 +103,13 @@ Creates a **PasteData** object for Want text. ...@@ -103,13 +103,13 @@ Creates a **PasteData** object for Want text.
**Example** **Example**
```js ```js
var object = { var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
}; };
var pasteData = pasteboard.createWantData(object); var pasteData = pasteboard.createWantData(object);
``` ```
## pasteboard.createUriData<sup>7+</sup> ## pasteboard.createUriData<sup>7+</sup>
...@@ -134,9 +134,9 @@ Creates a **PasteData** object for URI text. ...@@ -134,9 +134,9 @@ Creates a **PasteData** object for URI text.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
``` ```
## pasteboard.createPlainTextRecord<sup>7+</sup> ## pasteboard.createPlainTextRecord<sup>7+</sup>
...@@ -161,9 +161,9 @@ Creates a **PasteDataRecord** object of the plain text type. ...@@ -161,9 +161,9 @@ Creates a **PasteDataRecord** object of the plain text type.
**Example** **Example**
```js ```js
var record = pasteboard.createPlainTextRecord("hello"); var record = pasteboard.createPlainTextRecord("hello");
``` ```
## pasteboard.createHtmlTextRecord<sup>7+</sup> ## pasteboard.createHtmlTextRecord<sup>7+</sup>
...@@ -188,10 +188,10 @@ Creates a **PasteDataRecord** object of the HTML text type. ...@@ -188,10 +188,10 @@ Creates a **PasteDataRecord** object of the HTML text type.
**Example** **Example**
```js ```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var record = pasteboard.createHtmlTextRecord(html); var record = pasteboard.createHtmlTextRecord(html);
``` ```
## pasteboard.createWantRecord<sup>7+</sup> ## pasteboard.createWantRecord<sup>7+</sup>
...@@ -216,13 +216,13 @@ Creates a **PasteDataRecord** object of the Want text type. ...@@ -216,13 +216,13 @@ Creates a **PasteDataRecord** object of the Want text type.
**Example** **Example**
```js ```js
var object = { var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
}; };
var record = pasteboard.createWantRecord(object); var record = pasteboard.createWantRecord(object);
``` ```
## pasteboard.createUriRecord<sup>7+</sup> ## pasteboard.createUriRecord<sup>7+</sup>
...@@ -247,9 +247,9 @@ Creates a **PasteDataRecord** object of the URI text type. ...@@ -247,9 +247,9 @@ Creates a **PasteDataRecord** object of the URI text type.
**Example** **Example**
```js ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
``` ```
## PasteDataProperty<sup>7+</sup> ## PasteDataProperty<sup>7+</sup>
...@@ -301,14 +301,14 @@ Forcibly converts the content in this **PasteData** object to the plain text. Th ...@@ -301,14 +301,14 @@ Forcibly converts the content in this **PasteData** object to the plain text. Th
**Example** **Example**
```js ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
record.convertToText().then((data) => { record.convertToText().then((data) => {
console.info('convertToText success data : ' + JSON.stringify(data)); console.info('convertToText success data : ' + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error('convertToText failed because ' + JSON.stringify(error)); console.error('convertToText failed because ' + JSON.stringify(error));
}); });
``` ```
### convertToText<sup>7+</sup> ### convertToText<sup>7+</sup>
...@@ -327,16 +327,16 @@ Forcibly converts the content in this **PasteData** object to the plain text. Th ...@@ -327,16 +327,16 @@ Forcibly converts the content in this **PasteData** object to the plain text. Th
**Example** **Example**
```js ```js
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
record.convertToText((err, data) => { record.convertToText((err, data) => {
if (err) { if (err) {
console.error('convertToText failed because ' + JSON.stringify(err)); console.error('convertToText failed because ' + JSON.stringify(err));
return; return;
} }
console.info('convertToText success data : ' + JSON.stringify(data)); console.info('convertToText success data : ' + JSON.stringify(data));
}); });
``` ```
## PasteData ## PasteData
...@@ -366,10 +366,10 @@ Obtains the plain text of the primary record. ...@@ -366,10 +366,10 @@ Obtains the plain text of the primary record.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var plainText = pasteData.getPrimaryText(); var plainText = pasteData.getPrimaryText();
``` ```
### getPrimaryHtml<sup>7+</sup> ### getPrimaryHtml<sup>7+</sup>
...@@ -388,11 +388,11 @@ Obtains the HTML text of the primary record. ...@@ -388,11 +388,11 @@ Obtains the HTML text of the primary record.
**Example** **Example**
```js ```js
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var pasteData = pasteboard.createHtmlData(html); var pasteData = pasteboard.createHtmlData(html);
var htmlText = pasteData.getPrimaryHtml(); var htmlText = pasteData.getPrimaryHtml();
``` ```
### getPrimaryWant<sup>7+</sup> ### getPrimaryWant<sup>7+</sup>
...@@ -411,14 +411,14 @@ Obtains the **Want** object of the primary record. ...@@ -411,14 +411,14 @@ Obtains the **Want** object of the primary record.
**Example** **Example**
```js ```js
var object = { var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
}; };
var pasteData = pasteboard.createWantData(object); var pasteData = pasteboard.createWantData(object);
var want = pasteData.getPrimaryWant(); var want = pasteData.getPrimaryWant();
``` ```
### getPrimaryUri<sup>7+</sup> ### getPrimaryUri<sup>7+</sup>
...@@ -437,10 +437,10 @@ Obtains the URI text of the primary record. ...@@ -437,10 +437,10 @@ Obtains the URI text of the primary record.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
var uri = pasteData.getPrimaryUri(); var uri = pasteData.getPrimaryUri();
``` ```
### addTextRecord<sup>7+</sup> ### addTextRecord<sup>7+</sup>
...@@ -485,11 +485,11 @@ The pasteboard supports a maximum number of 128 data records. ...@@ -485,11 +485,11 @@ The pasteboard supports a maximum number of 128 data records.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
pasteData.addHtmlRecord(html); pasteData.addHtmlRecord(html);
``` ```
### addWantRecord<sup>7+</sup> ### addWantRecord<sup>7+</sup>
...@@ -510,14 +510,14 @@ The pasteboard supports a maximum number of 128 data records. ...@@ -510,14 +510,14 @@ The pasteboard supports a maximum number of 128 data records.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var object = { var object = {
bundleName: "com.example.aafwk.test", bundleName: "com.example.aafwk.test",
abilityName: "com.example.aafwk.test.TwoAbility" abilityName: "com.example.aafwk.test.TwoAbility"
}; };
pasteData.addWantRecord(object); pasteData.addWantRecord(object);
``` ```
### addUriRecord<sup>7+</sup> ### addUriRecord<sup>7+</sup>
...@@ -538,10 +538,10 @@ The pasteboard supports a maximum number of 128 data records. ...@@ -538,10 +538,10 @@ The pasteboard supports a maximum number of 128 data records.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt"); pasteData.addUriRecord("dataability:///com.example.myapplication1?user.txt");
``` ```
### addRecord<sup>7+</sup> ### addRecord<sup>7+</sup>
...@@ -562,14 +562,14 @@ The pasteboard supports a maximum number of 128 data records. ...@@ -562,14 +562,14 @@ The pasteboard supports a maximum number of 128 data records.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt"); var pasteData = pasteboard.createUriData("dataability:///com.example.myapplication1?user.txt");
var textRecord = pasteboard.createPlainTextRecord("hello"); var textRecord = pasteboard.createPlainTextRecord("hello");
var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>"; var html = "<!DOCTYPE html>\n" + "<html>\n" + "<head>\n" + "<meta charset=\"utf-8\">\n" + "<title>HTML-PASTEBOARD_HTML</title>\n" + "</head>\n" + "<body>\n" + " <h1>HEAD</h1>\n" + " <p></p>\n" + "</body>\n" + "</html>";
var htmlRecord = pasteboard.createHtmlTextRecord(html); var htmlRecord = pasteboard.createHtmlTextRecord(html);
pasteData.addRecord(textRecord); pasteData.addRecord(textRecord);
pasteData.addRecord(htmlRecord); pasteData.addRecord(htmlRecord);
``` ```
### getMimeTypes<sup>7+</sup> ### getMimeTypes<sup>7+</sup>
...@@ -588,10 +588,10 @@ Obtains **mimeTypes** in [PasteDataProperty](#pastedataproperty7) from this past ...@@ -588,10 +588,10 @@ Obtains **mimeTypes** in [PasteDataProperty](#pastedataproperty7) from this past
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var types = pasteData.getMimeTypes(); var types = pasteData.getMimeTypes();
``` ```
### getPrimaryMimeType<sup>7+</sup> ### getPrimaryMimeType<sup>7+</sup>
...@@ -610,10 +610,10 @@ Obtains the data type of the primary record. ...@@ -610,10 +610,10 @@ Obtains the data type of the primary record.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var type = pasteData.getPrimaryMimeType(); var type = pasteData.getPrimaryMimeType();
``` ```
### getProperty<sup>7+</sup> ### getProperty<sup>7+</sup>
...@@ -632,10 +632,10 @@ Obtains the property description object. ...@@ -632,10 +632,10 @@ Obtains the property description object.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var property = pasteData.getProperty(); var property = pasteData.getProperty();
``` ```
### getRecordAt<sup>7+</sup> ### getRecordAt<sup>7+</sup>
...@@ -660,10 +660,10 @@ Obtains the record with the specified index. ...@@ -660,10 +660,10 @@ Obtains the record with the specified index.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var record = pasteData.getRecordAt(0); var record = pasteData.getRecordAt(0);
``` ```
### getRecordCount<sup>7+</sup> ### getRecordCount<sup>7+</sup>
...@@ -682,10 +682,10 @@ Obtains the number of data records in this pasteboard. ...@@ -682,10 +682,10 @@ Obtains the number of data records in this pasteboard.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var count = pasteData.getRecordCount(); var count = pasteData.getRecordCount();
``` ```
### getTag<sup>7+</sup> ### getTag<sup>7+</sup>
...@@ -704,10 +704,10 @@ Obtains the user-defined tag content. If the tag content is not set, null is ret ...@@ -704,10 +704,10 @@ Obtains the user-defined tag content. If the tag content is not set, null is ret
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var tag = pasteData.getTag(); var tag = pasteData.getTag();
``` ```
### hasMimeType<sup>7+</sup> ### hasMimeType<sup>7+</sup>
...@@ -732,10 +732,10 @@ Checks whether the content of this pasteboard contains the specified data type. ...@@ -732,10 +732,10 @@ Checks whether the content of this pasteboard contains the specified data type.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN); var hasType = pasteData.hasMimeType(pasteboard.MIMETYPE_TEXT_PLAIN);
``` ```
### removeRecordAt<sup>7+</sup> ### removeRecordAt<sup>7+</sup>
...@@ -760,10 +760,10 @@ Removes the data record with a specified index from this pasteboard. ...@@ -760,10 +760,10 @@ Removes the data record with a specified index from this pasteboard.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var isRemove = pasteData.removeRecordAt(0); var isRemove = pasteData.removeRecordAt(0);
``` ```
### replaceRecordAt<sup>7+</sup> ### replaceRecordAt<sup>7+</sup>
...@@ -789,11 +789,11 @@ Replaces the data record with a specified index in this pasteboard. ...@@ -789,11 +789,11 @@ Replaces the data record with a specified index in this pasteboard.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("hello"); var pasteData = pasteboard.createPlainTextData("hello");
var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt"); var record = pasteboard.createUriRecord("dataability:///com.example.myapplication1?user.txt");
var isReplace = pasteData.replaceRecordAt(0, record); var isReplace = pasteData.replaceRecordAt(0, record);
``` ```
## pasteboard.getSystemPasteboard ## pasteboard.getSystemPasteboard
...@@ -812,9 +812,9 @@ Obtains the system pasteboard. ...@@ -812,9 +812,9 @@ Obtains the system pasteboard.
**Example** **Example**
```js ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
``` ```
## SystemPasteboard ## SystemPasteboard
...@@ -843,17 +843,17 @@ Writes data to a pasteboard. This API uses an asynchronous callback to return th ...@@ -843,17 +843,17 @@ Writes data to a pasteboard. This API uses an asynchronous callback to return th
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("content"); var pasteData = pasteboard.createPlainTextData("content");
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setPasteData(pasteData, (error, data) => { systemPasteboard.setPasteData(pasteData, (error, data) => {
if (error) { if (error) {
console.error('Failed to setPasteData. Cause: ' + error.message); console.error('Failed to setPasteData. Cause: ' + error.message);
return; return;
} }
console.info('setPasteData successfully.'); console.info('setPasteData successfully.');
}); });
``` ```
### setPasteData ### setPasteData
...@@ -878,15 +878,15 @@ Writes data to a pasteboard. This API uses a promise to return the result. ...@@ -878,15 +878,15 @@ Writes data to a pasteboard. This API uses a promise to return the result.
**Example** **Example**
```js ```js
var pasteData = pasteboard.createPlainTextData("content"); var pasteData = pasteboard.createPlainTextData("content");
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.setPasteData(pasteData).then((data) => { systemPasteboard.setPasteData(pasteData).then((data) => {
console.info('setPasteData success.'); console.info('setPasteData success.');
}).catch((error) => { }).catch((error) => {
console.error('Failed to setPasteData. Cause: ' + error.message); console.error('Failed to setPasteData. Cause: ' + error.message);
}); });
``` ```
### getPasteData ### getPasteData
...@@ -905,16 +905,16 @@ Reads the system pasteboard content. This API uses an asynchronous callback to r ...@@ -905,16 +905,16 @@ Reads the system pasteboard content. This API uses an asynchronous callback to r
**Example** **Example**
```js ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getPasteData((error, pasteData) => { systemPasteboard.getPasteData((error, pasteData) => {
if (error) { if (error) {
console.error('Failed to getPasteData. Cause: ' + error.message); console.error('Failed to getPasteData. Cause: ' + error.message);
return; return;
} }
var text = pasteData.getPrimaryText(); var text = pasteData.getPrimaryText();
}); });
``` ```
### getPasteData ### getPasteData
...@@ -933,14 +933,14 @@ Reads the system pasteboard content. This API uses a promise to return the resul ...@@ -933,14 +933,14 @@ Reads the system pasteboard content. This API uses a promise to return the resul
**Example** **Example**
```js ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
systemPasteboard.getPasteData().then((pasteData) => { systemPasteboard.getPasteData().then((pasteData) => {
var text = pasteData.getPrimaryText(); var text = pasteData.getPrimaryText();
}).catch((error) => { }).catch((error) => {
console.error('Failed to getPasteData. Cause: ' + error.message); console.error('Failed to getPasteData. Cause: ' + error.message);
}) })
``` ```
### on('update')<sup>7+</sup> ### on('update')<sup>7+</sup>
...@@ -960,18 +960,18 @@ Subscribes to the content change event of the system pasteboard. If the pasteboa ...@@ -960,18 +960,18 @@ Subscribes to the content change event of the system pasteboard. If the pasteboa
**Example** **Example**
```js ```js
var systemPasteboard = pasteboard.getSystemPasteboard(); var systemPasteboard = pasteboard.getSystemPasteboard();
var listener = ()=>{ var listener = () => {
console.info('The system pasteboard has changed'); console.info('The system pasteboard has changed');
}; };
systemPasteboard.on('update', listener); systemPasteboard.on('update', listener);
``` ```
### off('update')<sup>7+</sup> ### off('update')<sup>7+</sup>
off(type: 'update', callback? : () =&gt;void ): void off(type: 'update', callback?: () =&gt;void ): void
Unsubscribes from the system pasteboard content change event. Unsubscribes from the system pasteboard content change event.
...@@ -986,9 +986,12 @@ Unsubscribes from the system pasteboard content change event. ...@@ -986,9 +986,12 @@ Unsubscribes from the system pasteboard content change event.
**Example** **Example**
```js ```js
systemPasteboard.off('update', listener); let listener = () => {
``` console.info('The system pasteboard has changed');
};
systemPasteboard.off('update', listener);
```
### hasPasteData<sup>7+</sup> ### hasPasteData<sup>7+</sup>
...@@ -1007,15 +1010,15 @@ Checks whether the system pasteboard contains content. This API uses an asynchro ...@@ -1007,15 +1010,15 @@ Checks whether the system pasteboard contains content. This API uses an asynchro
**Example** **Example**
```js ```js
systemPasteboard.hasPasteData((err, data) => { systemPasteboard.hasPasteData((err, data) => {
if (err) { if (err) {
console.error('failed to hasPasteData because ' + JSON.stringify(err)); console.error('failed to hasPasteData because ' + JSON.stringify(err));
return; return;
} }
console.info('success hasPasteData : ' + JSON.stringify(data)); console.info('success hasPasteData : ' + JSON.stringify(data));
}); });
``` ```
### hasPasteData<sup>7+</sup> ### hasPasteData<sup>7+</sup>
...@@ -1059,15 +1062,15 @@ Clears the system pasteboard content. This API uses an asynchronous callback to ...@@ -1059,15 +1062,15 @@ Clears the system pasteboard content. This API uses an asynchronous callback to
**Example** **Example**
```js ```js
systemPasteboard.clear((err, data) => { systemPasteboard.clear((err, data) => {
if (err) { if (err) {
console.error('failed to clear because ' + JSON.stringify(err)); console.error('failed to clear because ' + JSON.stringify(err));
return; return;
} }
console.info('success clear'); console.info('success clear');
}); });
``` ```
### clear<sup>7+</sup> ### clear<sup>7+</sup>
...@@ -1086,10 +1089,10 @@ Clears the system pasteboard content. This API uses a promise to return the resu ...@@ -1086,10 +1089,10 @@ Clears the system pasteboard content. This API uses a promise to return the resu
**Example** **Example**
```js ```js
systemPasteboard.clear().then((data) => { systemPasteboard.clear().then((data) => {
console.info('success clear'); console.info('success clear');
}).catch((error) => { }).catch((error) => {
console.error('failed to clear because ' + JSON.stringify(error)); console.error('failed to clear because ' + JSON.stringify(error));
}); });
``` ```
\ No newline at end of file
...@@ -85,7 +85,7 @@ Uploads files. This API uses a promise to return the result. ...@@ -85,7 +85,7 @@ Uploads files. This API uses a promise to return the result.
```js ```js
let file1 = { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }; let file1 = { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" };
let data = { name: "name123", value: "123" }; let data = { name: "name123", value: "123" };
let header = { key1: value1, key2: value2 }; let header = { key1: "value1", key2: "value2" };
let uploadTask; let uploadTask;
request.upload({ url: 'https://patch', header: header, method: "POST", files: [file1], data: [data] }).then((data) => { request.upload({ url: 'https://patch', header: header, method: "POST", files: [file1], data: [data] }).then((data) => {
uploadTask = data; uploadTask = data;
...@@ -117,7 +117,7 @@ Uploads files. This API uses an asynchronous callback to return the result. ...@@ -117,7 +117,7 @@ Uploads files. This API uses an asynchronous callback to return the result.
```js ```js
let file1 = { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" }; let file1 = { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" };
let data = { name: "name123", value: "123" }; let data = { name: "name123", value: "123" };
let header = { key1: value1, key2: value2 }; let header = { key1: "value1", key2: "value2" };
let uploadTask; let uploadTask;
request.upload({ url: 'https://patch', header: header, method: "POST", files: [file1], data: [data] }, (err, data) => { request.upload({ url: 'https://patch', header: header, method: "POST", files: [file1], data: [data] }, (err, data) => {
if (err) { if (err) {
......
# Wallpaper # Wallpaper
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. > **NOTE**<br>The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
## Modules to Import ## Modules to Import
...@@ -29,17 +28,17 @@ Defines the wallpaper type. ...@@ -29,17 +28,17 @@ Defines the wallpaper type.
getColors(wallpaperType: WallpaperType, callback: AsyncCallback&lt;Array&lt;RgbaColor&gt;&gt;): void getColors(wallpaperType: WallpaperType, callback: AsyncCallback&lt;Array&lt;RgbaColor&gt;&gt;): void
Obtains the main color information of the wallpaper of a specified type. Obtains the main color information of the wallpaper of the specified type. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
- Parameters **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
| callback | AsyncCallback&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | Yes | Callback used to return the main color information of the wallpaper. | | callback | AsyncCallback&lt;Array&lt;[RgbaColor](#rgbacolor)&gt;&gt; | Yes | Callback used to return the main color information of the wallpaper. |
- Example **Example**
```js ```js
wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
...@@ -56,7 +55,7 @@ Obtains the main color information of the wallpaper of a specified type. ...@@ -56,7 +55,7 @@ Obtains the main color information of the wallpaper of a specified type.
getColors(wallpaperType: WallpaperType): Promise&lt;Array&lt;RgbaColor&gt;&gt; getColors(wallpaperType: WallpaperType): Promise&lt;Array&lt;RgbaColor&gt;&gt;
Obtains the main color information of the wallpaper of a specified type. Obtains the main color information of the wallpaper of the specified type. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -74,20 +73,20 @@ Obtains the main color information of the wallpaper of a specified type. ...@@ -74,20 +73,20 @@ Obtains the main color information of the wallpaper of a specified type.
**Example** **Example**
```js ```js
wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.getColors(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getColors.`); console.log(`success to getColors.`);
}).catch((error) => { }).catch((error) => {
console.error(`failed to getColors because: ` + JSON.stringify(error)); console.error(`failed to getColors because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.getId ## wallpaper.getId
getId(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): void getId(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): void
Obtains the ID of the wallpaper of the specified type. Obtains the ID of the wallpaper of the specified type. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -100,25 +99,26 @@ Obtains the ID of the wallpaper of the specified type. ...@@ -100,25 +99,26 @@ Obtains the ID of the wallpaper of the specified type.
**Example** **Example**
```js ```js
wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to getId because: ` + JSON.stringify(error)); console.error(`failed to getId because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to getId: ` + JSON.stringify(data)); console.log(`success to getId: ` + JSON.stringify(data));
}); });
``` ```
## wallpaper.getId ## wallpaper.getId
getId(wallpaperType: WallpaperType): Promise&lt;number&gt; getId(wallpaperType: WallpaperType): Promise&lt;number&gt;
Obtains the ID of the wallpaper of the specified type. Obtains the ID of the wallpaper of the specified type. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
...@@ -133,20 +133,20 @@ Obtains the ID of the wallpaper of the specified type. ...@@ -133,20 +133,20 @@ Obtains the ID of the wallpaper of the specified type.
**Example** **Example**
```js ```js
wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.getId(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getId: ` + JSON.stringify(data)); console.log(`success to getId: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to getId because: ` + JSON.stringify(error)); console.error(`failed to getId because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.getMinHeight ## wallpaper.getMinHeight
getMinHeight(callback: AsyncCallback&lt;number&gt;): void getMinHeight(callback: AsyncCallback&lt;number&gt;): void
Obtains the minimum height of the wallpaper. Obtains the minimum height of this wallpaper. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -158,25 +158,26 @@ Obtains the minimum height of the wallpaper. ...@@ -158,25 +158,26 @@ Obtains the minimum height of the wallpaper.
**Example** **Example**
```js ```js
wallpaper.getMinHeight((error, data) => { wallpaper.getMinHeight((error, data) => {
if (error) { if (error) {
console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); console.error(`failed to getMinHeight because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to getMinHeight: ` + JSON.stringify(data)); console.log(`success to getMinHeight: ` + JSON.stringify(data));
}); });
``` ```
## wallpaper.getMinHeight ## wallpaper.getMinHeight
getMinHeight(): Promise&lt;number&gt; getMinHeight(): Promise&lt;number&gt;
Obtains the minimum height of the wallpaper. Obtains the minimum height of this wallpaper. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
**Return value** **Return value**
| Type | Description | | Type | Description |
...@@ -185,20 +186,20 @@ Obtains the minimum height of the wallpaper. ...@@ -185,20 +186,20 @@ Obtains the minimum height of the wallpaper.
**Example** **Example**
```js ```js
wallpaper.getMinHeight().then((data) => { wallpaper.getMinHeight().then((data) => {
console.log(`success to getMinHeight: ` + JSON.stringify(data)); console.log(`success to getMinHeight: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to getMinHeight because: ` + JSON.stringify(error)); console.error(`failed to getMinHeight because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.getMinWidth ## wallpaper.getMinWidth
getMinWidth(callback: AsyncCallback&lt;number&gt;): void getMinWidth(callback: AsyncCallback&lt;number&gt;): void
Obtains the minimum width of the wallpaper. Obtains the minimum width of this wallpaper. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -210,22 +211,22 @@ Obtains the minimum width of the wallpaper. ...@@ -210,22 +211,22 @@ Obtains the minimum width of the wallpaper.
**Example** **Example**
```js ```js
wallpaper.getMinWidth((error, data) => { wallpaper.getMinWidth((error, data) => {
if (error) { if (error) {
console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); console.error(`failed to getMinWidth because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to getMinWidth: ` + JSON.stringify(data)); console.log(`success to getMinWidth: ` + JSON.stringify(data));
}); });
``` ```
## wallpaper.getMinWidth ## wallpaper.getMinWidth
getMinWidth(): Promise&lt;number&gt; getMinWidth(): Promise&lt;number&gt;
Obtains the minimum width of the wallpaper. Obtains the minimum width of this wallpaper. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -237,20 +238,20 @@ Obtains the minimum width of the wallpaper. ...@@ -237,20 +238,20 @@ Obtains the minimum width of the wallpaper.
**Example** **Example**
```js ```js
wallpaper.getMinWidth().then((data) => { wallpaper.getMinWidth().then((data) => {
console.log(`success to getMinWidth: ` + JSON.stringify(data)); console.log(`success to getMinWidth: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to getMinWidth because: ` + JSON.stringify(error)); console.error(`failed to getMinWidth because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.isChangePermitted ## wallpaper.isChangePermitted
isChangePermitted(callback: AsyncCallback&lt;boolean&gt;): void isChangePermitted(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether to allow the application to change the wallpaper for the current user. Checks whether to allow the application to change the wallpaper for the current user. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -258,26 +259,26 @@ Checks whether to allow the application to change the wallpaper for the current ...@@ -258,26 +259,26 @@ Checks whether to allow the application to change the wallpaper for the current
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the queried result. Returns **true** if it is allowed; returns **false** otherwise. | | callback | AsyncCallback&lt;boolean&gt; | Yes | Returns **true** if the application is allowed to change the wallpaper for the current user; returns **false** otherwise. |
**Example** **Example**
```js ```js
wallpaper.isChangePermitted((error, data) => { wallpaper.isChangePermitted((error, data) => {
if (error) { if (error) {
console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); console.error(`failed to isChangePermitted because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to isChangePermitted: ` + JSON.stringify(data)); console.log(`success to isChangePermitted: ` + JSON.stringify(data));
}); });
``` ```
## wallpaper.isChangePermitted ## wallpaper.isChangePermitted
isChangePermitted(): Promise&lt;boolean&gt; isChangePermitted(): Promise&lt;boolean&gt;
Checks whether to allow the application to change the wallpaper for the current user. Checks whether to allow the application to change the wallpaper for the current user. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -285,24 +286,24 @@ Checks whether to allow the application to change the wallpaper for the current ...@@ -285,24 +286,24 @@ Checks whether to allow the application to change the wallpaper for the current
| Type | Description | | Type | Description |
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether to allow the application to change the wallpaper for the current user. Returns **true** if it is allowed; returns **false** otherwise. | | Promise&lt;boolean&gt; | Returns **true** if the application is allowed to change the wallpaper for the current user; returns **false** otherwise. |
**Example** **Example**
```js ```js
wallpaper.isChangePermitted().then((data) => { wallpaper.isChangePermitted().then((data) => {
console.log(`success to isChangePermitted: ` + JSON.stringify(data)); console.log(`success to isChangePermitted: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to isChangePermitted because: ` + JSON.stringify(error)); console.error(`failed to isChangePermitted because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.isOperationAllowed ## wallpaper.isOperationAllowed
isOperationAllowed(callback: AsyncCallback&lt;boolean&gt;): void isOperationAllowed(callback: AsyncCallback&lt;boolean&gt;): void
Checks whether the user is allowed to set wallpapers. Checks whether the user is allowed to set wallpapers. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -310,26 +311,26 @@ Checks whether the user is allowed to set wallpapers. ...@@ -310,26 +311,26 @@ Checks whether the user is allowed to set wallpapers.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. | | callback | AsyncCallback&lt;boolean&gt; | Yes | Returns **true** if the user is allowed to set wallpapers; returns **false** otherwise. |
**Example** **Example**
```js ```js
wallpaper.isOperationAllowed((error, data) => { wallpaper.isOperationAllowed((error, data) => {
if (error) { if (error) {
console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); console.log(`success to isOperationAllowed: ` + JSON.stringify(data));
}); });
``` ```
## wallpaper.isOperationAllowed ## wallpaper.isOperationAllowed
isOperationAllowed(): Promise&lt;boolean&gt; isOperationAllowed(): Promise&lt;boolean&gt;
Checks whether the user is allowed to set wallpapers. Checks whether the user is allowed to set wallpapers. This API uses a promise to return the result.
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -337,26 +338,26 @@ Checks whether the user is allowed to set wallpapers. ...@@ -337,26 +338,26 @@ Checks whether the user is allowed to set wallpapers.
| Type | Description | | Type | Description |
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Promise used to return whether the user is allowed to set wallpapers. Returns **true** if it is allowed; returns **false** otherwise. | | Promise&lt;boolean&gt; | Returns **true** if the user is allowed to set wallpapers; returns **false** otherwise. |
**Example** **Example**
```js ```js
wallpaper.isOperationAllowed().then((data) => { wallpaper.isOperationAllowed().then((data) => {
console.log(`success to isOperationAllowed: ` + JSON.stringify(data)); console.log(`success to isOperationAllowed: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error)); console.error(`failed to isOperationAllowed because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.reset ## wallpaper.reset
reset(wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void reset(wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void
Removes a wallpaper of the specified type and restores the default one. Resets the wallpaper of the specified type to the default wallpaper. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.SET_WALLPAPER **Required permissions**: ohos.permission.SET_WALLPAPER
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -365,28 +366,28 @@ Removes a wallpaper of the specified type and restores the default one. ...@@ -365,28 +366,28 @@ Removes a wallpaper of the specified type and restores the default one.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned. |
**Example** **Example**
```js ```js
wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to reset because: ` + JSON.stringify(error)); console.error(`failed to reset because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to reset.`); console.log(`success to reset.`);
}); });
``` ```
## wallpaper.reset ## wallpaper.reset
reset(wallpaperType: WallpaperType): Promise&lt;void&gt; reset(wallpaperType: WallpaperType): Promise&lt;void&gt;
Removes a wallpaper of the specified type and restores the default one. Resets the wallpaper of the specified type to the default wallpaper. This API uses a promise to return the result.
**Required permission**: ohos.permission.SET_WALLPAPER **Required permissions**: ohos.permission.SET_WALLPAPER
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -400,26 +401,26 @@ Removes a wallpaper of the specified type and restores the default one. ...@@ -400,26 +401,26 @@ Removes a wallpaper of the specified type and restores the default one.
| Type | Description | | Type | Description |
| -------- | -------- | | -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result. If the operation is successful, the result of removal is returned. Otherwise, error information is returned. | | Promise&lt;void&gt; | Promise used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned. |
**Example** **Example**
```js ```js
wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.reset(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to reset.`); console.log(`success to reset.`);
}).catch((error) => { }).catch((error) => {
console.error(`failed to reset because: ` + JSON.stringify(error)); console.error(`failed to reset because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.setWallpaper ## wallpaper.setWallpaper
setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType, callback: AsyncCallback&lt;void&gt;): void
Sets a specified source as the wallpaper of a specified type. Sets a specified source as the wallpaper of a specified type. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.SET_WALLPAPER **Required permissions**: ohos.permission.SET_WALLPAPER
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -427,7 +428,7 @@ Sets a specified source as the wallpaper of a specified type. ...@@ -427,7 +428,7 @@ Sets a specified source as the wallpaper of a specified type.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | URI path of the JPEG or PNG file, or bitmap of the PNG file. | | source | string \| [PixelMap](js-apis-image.md#pixelmap7) | Yes | URI of a JPEG or PNG file, or bitmap of a PNG file. |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. | | wallpaperType | [WallpaperType](#wallpapertype) | Yes | Wallpaper type. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. If the operation is successful, the setting result is returned. Otherwise, error information is returned. |
...@@ -435,25 +436,25 @@ Sets a specified source as the wallpaper of a specified type. ...@@ -435,25 +436,25 @@ Sets a specified source as the wallpaper of a specified type.
```js ```js
// The source type is string. // The source type is string.
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to setWallpaper.`); console.log(`success to setWallpaper.`);
}); });
// The source type is image.PixelMap. // The source type is image.PixelMap.
import image from '@ohos.multimedia.image'; import image from '@ohos.multimedia.image';
let imageSource = image.createImageSource("file://" + wallpaperPath); let imageSource = image.createImageSource("file://" + wallpaperPath);
let opts = { let opts = {
"desiredSize": { "desiredSize": {
"height": 3648, "height": 3648,
"width": 2736 "width": 2736
} }
}; };
imageSource.createPixelMap(opts).then((pixelMap) => { imageSource.createPixelMap(opts).then((pixelMap) => {
wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
...@@ -461,19 +462,19 @@ imageSource.createPixelMap(opts).then((pixelMap) => { ...@@ -461,19 +462,19 @@ imageSource.createPixelMap(opts).then((pixelMap) => {
} }
console.log(`success to setWallpaper.`); console.log(`success to setWallpaper.`);
}); });
}).catch((error) => { }).catch((error) => {
console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); console.error(`failed to createPixelMap because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.setWallpaper ## wallpaper.setWallpaper
setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise&lt;void&gt; setWallpaper(source: string | image.PixelMap, wallpaperType: WallpaperType): Promise&lt;void&gt;
Sets a specified source as the wallpaper of a specified type. Sets a specified source as the wallpaper of a specified type. This API uses a promise to return the result.
**Required permission**: ohos.permission.SET_WALLPAPER **Required permissions**: ohos.permission.SET_WALLPAPER
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -494,38 +495,38 @@ Sets a specified source as the wallpaper of a specified type. ...@@ -494,38 +495,38 @@ Sets a specified source as the wallpaper of a specified type.
```js ```js
// The source type is string. // The source type is string.
let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg"; let wallpaperPath = "/data/data/ohos.acts.aafwk.plrdtest.form/files/Cup_ic.jpg";
wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.setWallpaper(wallpaperPath, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to setWallpaper.`); console.log(`success to setWallpaper.`);
}).catch((error) => { }).catch((error) => {
console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
}); });
// The source type is image.PixelMap. // The source type is image.PixelMap.
import image from '@ohos.multimedia.image'; import image from '@ohos.multimedia.image';
let imageSource = image.createImageSource("file://" + wallpaperPath); let imageSource = image.createImageSource("file://" + wallpaperPath);
let opts = { let opts = {
"desiredSize": { "desiredSize": {
"height": 3648, "height": 3648,
"width": 2736 "width": 2736
} }
}; };
imageSource.createPixelMap(opts).then((pixelMap) => { imageSource.createPixelMap(opts).then((pixelMap) => {
wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.setWallpaper(pixelMap, wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to setWallpaper.`); console.log(`success to setWallpaper.`);
}).catch((error) => { }).catch((error) => {
console.error(`failed to setWallpaper because: ` + JSON.stringify(error)); console.error(`failed to setWallpaper because: ` + JSON.stringify(error));
}); });
}).catch((error) => { }).catch((error) => {
console.error(`failed to createPixelMap because: ` + JSON.stringify(error)); console.error(`failed to createPixelMap because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.getFile<sup>8+</sup> ## wallpaper.getFile<sup>8+</sup>
getFile(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): void getFile(wallpaperType: WallpaperType, callback: AsyncCallback&lt;number&gt;): void
Obtains the wallpaper of the specified type. Obtains the wallpaper of the specified type. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.SET_WALLPAPER and ohos.permission.READ_USER_STORAGE **Required permissions**: ohos.permission.SET_WALLPAPER and ohos.permission.READ_USER_STORAGE
...@@ -540,23 +541,23 @@ Obtains the wallpaper of the specified type. ...@@ -540,23 +541,23 @@ Obtains the wallpaper of the specified type.
**Example** **Example**
```js ```js
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => { wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM, (error, data) => {
if (error) { if (error) {
console.error(`failed to getFile because: ` + JSON.stringify(error)); console.error(`failed to getFile because: ` + JSON.stringify(error));
return; return;
} }
console.log(`success to getFile: ` + JSON.stringify(data)); console.log(`success to getFile: ` + JSON.stringify(data));
}); });
``` ```
## wallpaper.getFile<sup>8+</sup> ## wallpaper.getFile<sup>8+</sup>
getFile(wallpaperType: WallpaperType): Promise&lt;number&gt; getFile(wallpaperType: WallpaperType): Promise&lt;number&gt;
Obtains the wallpaper of the specified type. Obtains the wallpaper of the specified type. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE **Required permissions**: ohos.permission.SET_WALLPAPER and ohos.permission.READ_USER_STORAGE
**System capability**: SystemCapability.MiscServices.Wallpaper **System capability**: SystemCapability.MiscServices.Wallpaper
...@@ -574,13 +575,75 @@ Obtains the wallpaper of the specified type. ...@@ -574,13 +575,75 @@ Obtains the wallpaper of the specified type.
**Example** **Example**
```js ```js
wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => { wallpaper.getFile(wallpaper.WallpaperType.WALLPAPER_SYSTEM).then((data) => {
console.log(`success to getFile: ` + JSON.stringify(data)); console.log(`success to getFile: ` + JSON.stringify(data));
}).catch((error) => { }).catch((error) => {
console.error(`failed to getFile because: ` + JSON.stringify(error)); console.error(`failed to getFile because: ` + JSON.stringify(error));
}); });
``` ```
## wallpaper.getPixelMap
getPixelMap(wallpaperType: WallpaperType, callback: AsyncCallback&lt;image.PixelMap&gt;): void;
Obtains the pixel image for the wallpaper of the specified type. This API uses an asynchronous callback to return the result.
**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE
**System capability**: SystemCapability.MiscServices.Wallpaper
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes| Wallpaper type.|
| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned.|
**Example**
```js
wallpaper.getPixelMap(wallpaper.WallpaperType.WALLPAPER_SYSTEM, function (err, data) {
console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem err : ' + JSON.stringify(err));
console.info('wallpaperXTS ===> testGetPixelMapCallbackSystem data : ' + JSON.stringify(data));
});
```
## wallpaper.getPixelMap
getPixelMap(wallpaperType: WallpaperType): Promise&lt;image.PixelMap&gt;
Obtains the pixel image for the wallpaper of the specified type. This API uses a promise to return the result.
**Required permissions**: ohos.permission.GET_WALLPAPER and ohos.permission.READ_USER_STORAGE
**System capability**: SystemCapability.MiscServices.Wallpaper
**Parameters**
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| wallpaperType | [WallpaperType](#wallpapertype) | Yes| Wallpaper type.|
**Return value**
| Type| Description|
| -------- | -------- |
| Promise&lt;void&gt; | Promise used to return the result. If the operation is successful, the result is returned. Otherwise, error information is returned.|
**Example**
```js
wallpaper.getPixelMap(WALLPAPER_SYSTEM).then((data) => {
console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + data);
console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem data : ' + JSON.stringify(data));
}).catch((err) => {
console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + err);
console.info('wallpaperXTS ===> testGetPixelMapPromiseSystem err : ' + JSON.stringify(err));
});
```
## wallpaper.on('colorChange') ## wallpaper.on('colorChange')
...@@ -596,16 +659,16 @@ Subscribes to the wallpaper color change event. ...@@ -596,16 +659,16 @@ Subscribes to the wallpaper color change event.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the event to subscribe to. The value **colorChange** indicates subscribing to the wallpaper color change event. | | type | string | Yes | Type of the event to subscribe to. The value **colorChange** indicates subscribing to the wallpaper color change event. |
| callback | function | Yes | Callback triggered when the wallpaper color changes. The wallpaper type and main colors are returned.<br/>- colors<br/> Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).<br/>- wallpaperType<br/> Wallpaper type. | | callback | function | Yes | Callback triggered when the wallpaper color changes. The wallpaper type and main colors are returned.<br>- colors<br> Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).<br>- wallpaperType<br> Wallpaper type. |
**Example** **Example**
```js ```js
let listener = (colors, wallpaperType) => { let listener = (colors, wallpaperType) => {
console.log(`wallpaper color changed.`); console.log(`wallpaper color changed.`);
}; };
wallpaper.on('colorChange', listener); wallpaper.on('colorChange', listener);
``` ```
## wallpaper.off('colorChange') ## wallpaper.off('colorChange')
...@@ -621,15 +684,15 @@ Unsubscribes from the wallpaper color change event. ...@@ -621,15 +684,15 @@ Unsubscribes from the wallpaper color change event.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the event to unsubscribe from. The value **colorChange** indicates unsubscribing from the wallpaper color change event. | | type | string | Yes | Type of the event to unsubscribe from. The value **colorChange** indicates unsubscribing from the wallpaper color change event. |
| callback | function | No | Callback for the wallpaper color change event. If this parameter is not specified, all callbacks corresponding to the wallpaper color change event are invoked.<br/>- colors<br/> Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).<br/>- wallpaperType<br/> Wallpaper type. | | callback | function | No | Callback for the wallpaper color change event. If this parameter is not specified, all callbacks corresponding to the wallpaper color change event are invoked.<br>- colors<br> Main color information of the wallpaper. For details, see [RgbaColor](#rgbacolor).<br>- wallpaperType<br> Wallpaper type. |
**Example** **Example**
```js ```js
let listener = (colors, wallpaperType) => { let listener = (colors, wallpaperType) => {
console.log(`wallpaper color changed.`); console.log(`wallpaper color changed.`);
}; };
wallpaper.on('colorChange', listener); wallpaper.on('colorChange', listener);
// Unsubscribe from the listener. // Unsubscribe from the listener.
wallpaper.off('colorChange', listener); wallpaper.off('colorChange', listener);
//Unsubscribe from all subscriptions of the colorChange type. //Unsubscribe from all subscriptions of the colorChange type.
......
...@@ -229,7 +229,7 @@ static int32_t TestCaseAdc(void) ...@@ -229,7 +229,7 @@ static int32_t TestCaseAdc(void)
int32_t i; int32_t i;
int32_t ret; int32_t ret;
DevHandle adcHandle; DevHandle adcHandle;
uint32_t Readbuf[30] = {0}; uint32_t readBuf[30] = {0};
/* Open the ADC device. */ /* Open the ADC device. */
adcHandle = AdcOpen(ADC_DEVICE_NUM); adcHandle = AdcOpen(ADC_DEVICE_NUM);
...@@ -240,7 +240,7 @@ static int32_t TestCaseAdc(void) ...@@ -240,7 +240,7 @@ static int32_t TestCaseAdc(void)
/* Perform 30 times of AD conversions continuously and read the conversion results. */ /* Perform 30 times of AD conversions continuously and read the conversion results. */
for (i = 0; i < 30; i++) { for (i = 0; i < 30; i++) {
ret = AdcRead(adcHandle, ADC_CHANNEL_NUM, &Readbuf[i]); ret = AdcRead(adcHandle, ADC_CHANNEL_NUM, &readBuf[i]);
if (ret != HDF_SUCCESS) { if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: tp ADC write reg fail!:%d", __func__, ret); HDF_LOGE("%s: tp ADC write reg fail!:%d", __func__, ret);
AdcClose(adcHandle); AdcClose(adcHandle);
......
...@@ -10,14 +10,14 @@ ...@@ -10,14 +10,14 @@
- [Creating a Source Code Project](quick-start/quickstart-ide-lite-create-project.md) - [Creating a Source Code Project](quick-start/quickstart-ide-lite-create-project.md)
- Running a Hello World Program - Running a Hello World Program
- Hi3861 Development Board - Hi3861 Development Board
- [Writing a Hello World Program](quick-start/quickstart-ide-lite-steps-hi3861-application-framework.md) - [Writing a Hello World Program](quick-start/quickstart-ide-lite-steps-hi3861-helloworld.md)
- [Building](quick-start/quickstart-ide-lite-steps-hi3861-building.md) - [Building](quick-start/quickstart-ide-lite-steps-hi3861-building.md)
- [Burning](quick-start/quickstart-ide-lite-steps-hi3861-burn.md) - [Burning](quick-start/quickstart-ide-lite-steps-hi3861-burn.md)
- [Networking](quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md) - [Networking](quick-start/quickstart-ide-lite-steps-hi3861-netconfig.md)
- [Debugging and Verification](quick-start/quickstart-ide-lite-steps-hi3861-debug.md) - [Debugging and Verification](quick-start/quickstart-ide-lite-steps-hi3861-debug.md)
- [Running](quick-start/quickstart-ide-lite-steps-hi3861-running.md) - [Running](quick-start/quickstart-ide-lite-steps-hi3861-running.md)
- Hi3516 Development Board - Hi3516 Development Board
- [Writing a Hello World Program](quick-start/quickstart-ide-lite-steps-hi3516-application-framework.md) - [Writing a Hello World Program](quick-start/quickstart-ide-lite-steps-hi3516-helloworld.md)
- [Building](quick-start/quickstart-ide-lite-steps-hi3516-building.md) - [Building](quick-start/quickstart-ide-lite-steps-hi3516-building.md)
- [Burning](quick-start/quickstart-ide-lite-steps-hi3516-burn.md) - [Burning](quick-start/quickstart-ide-lite-steps-hi3516-burn.md)
- [Running](quick-start/quickstart-ide-lite-steps-hi3516-running.md) - [Running](quick-start/quickstart-ide-lite-steps-hi3516-running.md)
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
- Running a Hello World Program - Running a Hello World Program
- Hi3861 Development Board - Hi3861 Development Board
- [Setting Up the Hi3861 Development Board Environment](quick-start/quickstart-lite-steps-hi3861-setting.md) - [Setting Up the Hi3861 Development Board Environment](quick-start/quickstart-lite-steps-hi3861-setting.md)
- [Writing a Hello World Program](quick-start/quickstart-lite-steps-hi3861-application-framework.md) - [Writing a Hello World Program](quick-start/quickstart-lite-steps-hi3861-helloworld.md)
- [Building](quick-start/quickstart-lite-steps-hi3861-building.md) - [Building](quick-start/quickstart-lite-steps-hi3861-building.md)
- [Burning](quick-start/quickstart-lite-steps-hi3861-burn.md) - [Burning](quick-start/quickstart-lite-steps-hi3861-burn.md)
- [Networking](quick-start/quickstart-lite-steps-hi3861-netconfig.md) - [Networking](quick-start/quickstart-lite-steps-hi3861-netconfig.md)
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
- [Running](quick-start/quickstart-lite-steps-hi3861-running.md) - [Running](quick-start/quickstart-lite-steps-hi3861-running.md)
- Hi3516 Development Board - Hi3516 Development Board
- [Setting Up the Hi3516 Development Board Environment](quick-start/quickstart-lite-steps-hi3516-setting.md) - [Setting Up the Hi3516 Development Board Environment](quick-start/quickstart-lite-steps-hi3516-setting.md)
- [Writing a Hello World Program](quick-start/quickstart-lite-steps-hi3516-application-framework.md) - [Writing a Hello World Program](quick-start/quickstart-lite-steps-hi3516-helloworld.md)
- [Building](quick-start/quickstart-lite-steps-hi3516-building.md) - [Building](quick-start/quickstart-lite-steps-hi3516-building.md)
- [Burning](quick-start/quickstart-lite-steps-hi3516-burn.md) - [Burning](quick-start/quickstart-lite-steps-hi3516-burn.md)
- [Running](quick-start/quickstart-lite-steps-hi3516-running.md) - [Running](quick-start/quickstart-lite-steps-hi3516-running.md)
...@@ -376,15 +376,18 @@ ...@@ -376,15 +376,18 @@
- [UART](driver/driver-platform-uart-des.md) - [UART](driver/driver-platform-uart-des.md)
- [WatchDog](driver/driver-platform-watchdog-des.md) - [WatchDog](driver/driver-platform-watchdog-des.md)
- Peripheral Driver Usage - Peripheral Driver Usage
- [Audio](driver/driver-peripherals-audio-des.md)
- [Camera](driver/driver-peripherals-camera-des.md)
- [Facial Authentication](driver/driver-peripherals-face_auth-des.md)
- [LCD](driver/driver-peripherals-lcd-des.md) - [LCD](driver/driver-peripherals-lcd-des.md)
- [Touchscreen](driver/driver-peripherals-touch-des.md) - [Light](driver/driver-peripherals-light-des.md)
- [PIN Authentication](driver/driver-peripherals-pinauth-des.md)
- [Sensor](driver/driver-peripherals-sensor-des.md) - [Sensor](driver/driver-peripherals-sensor-des.md)
- [WLAN](driver/driver-peripherals-external-des.md) - [Touchscreen](driver/driver-peripherals-touch-des.md)
- [Audio](driver/driver-peripherals-audio-des.md)
- [USB](driver/driver-peripherals-usb-des.md) - [USB](driver/driver-peripherals-usb-des.md)
- [Camera](driver/driver-peripherals-camera-des.md) - [User Authentication](driver/driver-peripherals-user-auth-des.md)
- [Vibrator](driver/driver-peripherals-vibrator-des.md) - [Vibrator](driver/driver-peripherals-vibrator-des.md)
- [Light](driver/driver-peripherals-light-des.md) - [WLAN](driver/driver-peripherals-external-des.md)
- Compilation and Building - Compilation and Building
- [Building Mini and Small Systems](subsystems/subsys-build-mini-lite.md) - [Building Mini and Small Systems](subsystems/subsys-build-mini-lite.md)
- [Building the Standard System](subsystems/subsys-build-standard-large.md) - [Building the Standard System](subsystems/subsys-build-standard-large.md)
......
...@@ -118,7 +118,7 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可 ...@@ -118,7 +118,7 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
## 实现页面间的跳转 ## 实现页面间的跳转
页面间的导航可以通过页面路由router来实现。页面路由router根据页面uri找到目标页面,从而实现跳转。使用页面路由请导入router模块。 页面间的导航可以通过页面路由router来实现。页面路由router根据页面url找到目标页面,从而实现跳转。使用页面路由请导入router模块。
1. 第一个页面跳转到第二个页面。 1. 第一个页面跳转到第二个页面。
在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。需同时处理ets文件及visual文件。 在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。需同时处理ets文件及visual文件。
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
- **src &gt; main &gt; ets &gt; MainAbility &gt; app.ets** :承载Ability生命周期。 - **src &gt; main &gt; ets &gt; MainAbility &gt; app.ets** :承载Ability生命周期。
- **src &gt; main &gt; resources** :用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。 - **src &gt; main &gt; resources** :用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。
- **src &gt; main &gt; config.json** :模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[应用包结构配置文件的说明](package-structure.md) - **src &gt; main &gt; config.json** :模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[应用包结构配置文件的说明](package-structure.md)
- **build-profile.json5** :当前的模块信息 、编译信息配置项,包括 buildOption target配置等。 - **build-profile.json5** :当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。
- **hvigorfile.js** :模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 - **hvigorfile.js** :模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。
- **build-profile.json5** :应用级配置信息,包括签名、产品配置等。 - **build-profile.json5** :应用级配置信息,包括签名、产品配置等。
...@@ -154,7 +154,7 @@ ...@@ -154,7 +154,7 @@
## 实现页面间的跳转 ## 实现页面间的跳转
页面间的导航可以通过页面路由router来实现。页面路由router根据页面uri找到目标页面,从而实现跳转。使用页面路由请导入router模块。 页面间的导航可以通过页面路由router来实现。页面路由router根据页面url找到目标页面,从而实现跳转。使用页面路由请导入router模块。
1. 第一个页面跳转到第二个页面。 1. 第一个页面跳转到第二个页面。
在第一个页面中,跳转按钮绑定onClick事件,点击按钮时跳转到第二页。“**index.ets**”文件的示例如下: 在第一个页面中,跳转按钮绑定onClick事件,点击按钮时跳转到第二页。“**index.ets**”文件的示例如下:
......
...@@ -103,7 +103,7 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可 ...@@ -103,7 +103,7 @@ OpenHarmony低代码开发方式具有丰富的UI界面编辑功能,通过可
## 实现页面间的跳转 ## 实现页面间的跳转
页面间的导航可以通过[页面路由router](../ui/ui-js-building-ui-routes.md)来实现。页面路由router根据页面uri找到目标页面,从而实现跳转。使用页面路由请导入router模块。 页面间的导航可以通过[页面路由router](../ui/ui-js-building-ui-routes.md)来实现。页面路由router根据页面url找到目标页面,从而实现跳转。使用页面路由请导入router模块。
1. 第一个页面跳转到第二个页面。 1. 第一个页面跳转到第二个页面。
在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。需同时处理js文件及visual文件。 在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。需同时处理js文件及visual文件。
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
- **src &gt; main &gt; resources** :用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。 - **src &gt; main &gt; resources** :用于存放应用/服务所用到的资源文件,如图形、多媒体、字符串、布局文件等。
- **src &gt; main &gt; config.json** :模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[应用包结构配置文件的说明](package-structure.md) - **src &gt; main &gt; config.json** :模块配置文件。主要包含HAP包的配置信息、应用/服务在具体设备上的配置信息以及应用/服务的全局配置信息。具体的配置文件说明,详见[应用包结构配置文件的说明](package-structure.md)
- **build-profile.json5** :当前的模块信息 、编译信息配置项,包括 buildOption target配置等。 - **build-profile.json5** :当前的模块信息 、编译信息配置项,包括buildOption、targets配置等。
- **hvigorfile.js** :模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。 - **hvigorfile.js** :模块级编译构建任务脚本,开发者可以自定义相关任务和代码实现。
- **build-profile.json5** :应用级配置信息,包括签名、产品配置等。 - **build-profile.json5** :应用级配置信息,包括签名、产品配置等。
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
## 实现页面间的跳转 ## 实现页面间的跳转
页面间的导航可以通过[页面路由router](../ui/ui-js-building-ui-routes.md)来实现。页面路由router根据页面uri找到目标页面,从而实现跳转。使用页面路由请导入router模块。 页面间的导航可以通过[页面路由router](../ui/ui-js-building-ui-routes.md)来实现。页面路由router根据页面url找到目标页面,从而实现跳转。使用页面路由请导入router模块。
1. 第一个页面跳转到第二个页面。 1. 第一个页面跳转到第二个页面。
在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。“**index.js**”示例如下: 在第一个页面中,跳转按钮绑定onclick方法,点击按钮时跳转到第二页。“**index.js**”示例如下:
......
...@@ -1089,6 +1089,8 @@ type ScopeType = ScopeComparable | number; ...@@ -1089,6 +1089,8 @@ type ScopeType = ScopeComparable | number;
```js ```js
class Temperature{ class Temperature{
constructor(value){ constructor(value){
// 当使用ts语言开发时,需要补充以下代码:
// private readonly _temp: Temperature;
this._temp = value; this._temp = value;
} }
comapreTo(value){ comapreTo(value){
......
...@@ -40,9 +40,9 @@ ImageAnimator() ...@@ -40,9 +40,9 @@ ImageAnimator()
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- | -------- |
| src | string \| [Resource](../../ui/ts-types.md#resource类型)<sup>9+</sup> | "" | 是 | 图片路径,图片格式为svg,png和jpg,从API9起支持[Resource](../../ui/ts-types.md#resource类型)类型的路径 | | src | string \| [Resource](../../ui/ts-types.md#resource类型)<sup>9+</sup> | "" | 是 | 图片路径,图片格式为svg,png和jpg,从API9起支持[Resource](../../ui/ts-types.md#resource类型)类型的路径 |
| width | [Length](../../ui/ts-types.md#长度类型) | 0 | 否 | 图片宽度 | | width | [Length](../../ui/ts-types.md#长度类型) | 0 | 否 | 图片宽度 |
| height | Length | 0 | 否 | 图片高度 | | height | [Length](../../ui/ts-types.md#长度类型) | 0 | 否 | 图片高度 |
| top | Length | 0 | 否 | 图片相对于组件左上角的纵向坐标 | | top | [Length](../../ui/ts-types.md#长度类型) | 0 | 否 | 图片相对于组件左上角的纵向坐标 |
| left | Length | 0 | 否 | 图片相对于组件左上角的横向坐标 | | left | [Length](../../ui/ts-types.md#长度类型) | 0 | 否 | 图片相对于组件左上角的横向坐标 |
| duration | number | 0 | 否 | 每一帧图片的播放时长,单位毫秒 | | duration | number | 0 | 否 | 每一帧图片的播放时长,单位毫秒 |
- AnimationStatus枚举说明 - AnimationStatus枚举说明
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
- 认证凭据模板 - 认证凭据模板
认证凭据模板在用户设置认证凭据时由认证服务产生并存储。在认证时,读取模板信息并用和当次认证过程中产生的认证数据做对比,完成身份认证。每个模板有一个ID,用于索引模板信息文件 认证凭据模板在用户设置认证凭据时由认证服务产生并存储。每个模板有一个ID,用于索引模板信息文件。在认证时,读取模板信息并用和当次认证过程中产生的认证数据做对比,完成身份认证
- 执行器 - 执行器
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
- 执行器角色 - 执行器角色
- ​ 全功能执行器:执行器可独立处理一次凭据注册和身份认证请求,即可提供用户认证数据采集、处理、储存及比对能力。 - ​ 全功能执行器:执行器可独立处理凭据注册和身份认证请求,即可提供用户认证数据采集、处理、储存及比对能力。
- ​ 采集器:执行器提供用户认证时的数据采集能力,需要和认证器配合完成用户认证。 - ​ 采集器:执行器提供用户认证时的数据采集能力,需要和认证器配合完成用户认证。
...@@ -144,7 +144,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ...@@ -144,7 +144,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
1. 基于HDF驱动框架,按照驱动Driver Entry程序,完成User_auth驱动开发,主要由Bind、Init、Release、Dispatch函数接口实现,详细代码参见[user_auth_interface_driver.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/user_auth/hdi_service/service/user_auth_interface_driver.cpp)文件。 1. 基于HDF驱动框架,按照驱动Driver Entry程序,完成User_auth驱动开发,主要由Bind、Init、Release、Dispatch函数接口实现,详细代码参见[user_auth_interface_driver.cpp](https://gitee.com/openharmony/drivers_peripheral/blob/master/user_auth/hdi_service/service/user_auth_interface_driver.cpp)文件。
```c++ ```c++
// 通过自定义的HdfUserAuthInterfaceHost对象包含ioService对象和真正的HDI Service实现IRemoteObject对象 // 通过自定义的HdfUserAuthInterfaceHost对象包含IoService对象和真正的HDI Service实现IRemoteObject对象
struct HdfUserAuthInterfaceHost { struct HdfUserAuthInterfaceHost {
struct IDeviceIoService ioService; struct IDeviceIoService ioService;
OHOS::sptr<OHOS::IRemoteObject> stub; OHOS::sptr<OHOS::IRemoteObject> stub;
...@@ -187,7 +187,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ...@@ -187,7 +187,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
auto *hdfUserAuthInterfaceHost = new (std::nothrow) HdfUserAuthInterfaceHost; auto *hdfUserAuthInterfaceHost = new (std::nothrow) HdfUserAuthInterfaceHost;
if (hdfUserAuthInterfaceHost == nullptr) { if (hdfUserAuthInterfaceHost == nullptr) {
HDF_LOGE("%{public}s: failed to create create HdfUserAuthInterfaceHost object", __func__); HDF_LOGE("%{public}s: failed to create HdfUserAuthInterfaceHost object", __func__);
return HDF_FAILURE; return HDF_FAILURE;
} }
...@@ -197,7 +197,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ...@@ -197,7 +197,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
auto serviceImpl = IUserAuthInterface::Get(true); auto serviceImpl = IUserAuthInterface::Get(true);
if (serviceImpl == nullptr) { if (serviceImpl == nullptr) {
HDF_LOGE("%{public}s: failed to get of implement service", __func__); HDF_LOGE("%{public}s: failed to implement service", __func__);
return HDF_FAILURE; return HDF_FAILURE;
} }
...@@ -271,7 +271,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ...@@ -271,7 +271,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
int32_t ret = OpenEditSession(userId, &challengeU64); int32_t ret = OpenEditSession(userId, &challengeU64);
challenge.resize(sizeof(uint64_t)); challenge.resize(sizeof(uint64_t));
if (memcpy_s(&challenge[0], challenge.size(), &challengeU64, sizeof(uint64_t)) != EOK) { if (memcpy_s(&challenge[0], challenge.size(), &challengeU64, sizeof(uint64_t)) != EOK) {
IAM_LOGE("challengeU64 copy failed"); IAM_LOGE("failed to copy challengeU64");
return RESULT_BAD_COPY; return RESULT_BAD_COPY;
} }
GlobalUnLock(); GlobalUnLock();
...@@ -310,18 +310,18 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ...@@ -310,18 +310,18 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
CoAuthSchedule scheduleInfo; CoAuthSchedule scheduleInfo;
int32_t ret = CheckEnrollPermission(checkParam, &scheduleInfo.scheduleId); int32_t ret = CheckEnrollPermission(checkParam, &scheduleInfo.scheduleId);
if (ret != RESULT_SUCCESS) { if (ret != RESULT_SUCCESS) {
IAM_LOGE("check permission failed"); IAM_LOGE("Failed to check permission");
GlobalUnLock(); GlobalUnLock();
return ret; return ret;
} }
ret = GetCoAuthSchedule(&scheduleInfo); ret = GetCoAuthSchedule(&scheduleInfo);
if (ret != RESULT_SUCCESS) { if (ret != RESULT_SUCCESS) {
IAM_LOGE("get schedule info failed"); IAM_LOGE("Failed to get schedule info");
GlobalUnLock(); GlobalUnLock();
return ret; return ret;
} }
if (!CopyScheduleInfo(&scheduleInfo, &info)) { if (!CopyScheduleInfo(&scheduleInfo, &info)) {
IAM_LOGE("copy schedule info failed"); IAM_LOGE("Failed to copy schedule info");
ret = RESULT_BAD_COPY; ret = RESULT_BAD_COPY;
} }
GlobalUnLock(); GlobalUnLock();
...@@ -356,7 +356,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ...@@ -356,7 +356,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
bool isUpdate; bool isUpdate;
int32_t ret = GetIsUpdate(&isUpdate); int32_t ret = GetIsUpdate(&isUpdate);
if (ret != RESULT_SUCCESS) { if (ret != RESULT_SUCCESS) {
IAM_LOGE("get isUpdate failed"); IAM_LOGE("Failed to get isUpdate");
return ret; return ret;
} }
if (isUpdate) { if (isUpdate) {
...@@ -397,7 +397,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ...@@ -397,7 +397,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
{ {
IAM_LOGI("start"); IAM_LOGI("start");
if (param.challenge.size() != sizeof(uint64_t)) { if (param.challenge.size() != sizeof(uint64_t)) {
IAM_LOGE("challenge copy failed"); IAM_LOGE("Failed to copy challenge");
return RESULT_BAD_PARAM; return RESULT_BAD_PARAM;
} }
GlobalLock(); GlobalLock();
...@@ -410,13 +410,13 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ...@@ -410,13 +410,13 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
solutionIn.authTrustLevel = param.authTrustLevel; solutionIn.authTrustLevel = param.authTrustLevel;
if (memcpy_s(&solutionIn.challenge, sizeof(uint64_t), &param.challenge[0], if (memcpy_s(&solutionIn.challenge, sizeof(uint64_t), &param.challenge[0],
param.challenge.size()) != EOK) { param.challenge.size()) != EOK) {
IAM_LOGE("challenge copy failed"); IAM_LOGE("Failed to copy challenge");
GlobalUnLock(); GlobalUnLock();
return RESULT_BAD_COPY; return RESULT_BAD_COPY;
} }
int32_t ret = GenerateSolutionFunc(solutionIn, &schedulesGet, &scheduleIdNum); int32_t ret = GenerateSolutionFunc(solutionIn, &schedulesGet, &scheduleIdNum);
if (ret != RESULT_SUCCESS) { if (ret != RESULT_SUCCESS) {
IAM_LOGE("generate solution failed"); IAM_LOGE("Failed to generate solution");
GlobalUnLock(); GlobalUnLock();
return ret; return ret;
} }
...@@ -456,14 +456,14 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ...@@ -456,14 +456,14 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
UserAuthTokenHal authTokenHal; UserAuthTokenHal authTokenHal;
info.result = RequestAuthResultFunc(contextId, scheduleResultBuffer, &authTokenHal); info.result = RequestAuthResultFunc(contextId, scheduleResultBuffer, &authTokenHal);
if (info.result != RESULT_SUCCESS) { if (info.result != RESULT_SUCCESS) {
IAM_LOGE("execute func failed"); IAM_LOGE("Failed to execute func");
DestoryBuffer(scheduleResultBuffer); DestoryBuffer(scheduleResultBuffer);
GlobalUnLock(); GlobalUnLock();
return info.result; return info.result;
} }
info.token.resize(sizeof(UserAuthTokenHal)); info.token.resize(sizeof(UserAuthTokenHal));
if (memcpy_s(&info.token[0], info.token.size(), &authTokenHal, sizeof(authTokenHal)) != EOK) { if (memcpy_s(&info.token[0], info.token.size(), &authTokenHal, sizeof(authTokenHal)) != EOK) {
IAM_LOGE("copy authToken failed"); IAM_LOGE("Failed to copy authToken");
DestoryBuffer(scheduleResultBuffer); DestoryBuffer(scheduleResultBuffer);
GlobalUnLock(); GlobalUnLock();
return RESULT_BAD_COPY; return RESULT_BAD_COPY;
...@@ -481,7 +481,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据 ...@@ -481,7 +481,7 @@ User_auth驱动的主要工作是为User_auth服务提供稳定的用户凭据
uint32_t scheduleIdNum = 0; uint32_t scheduleIdNum = 0;
int32_t ret = CancelContextFunc(contextId, nullptr, &scheduleIdNum); int32_t ret = CancelContextFunc(contextId, nullptr, &scheduleIdNum);
if (ret != RESULT_SUCCESS) { if (ret != RESULT_SUCCESS) {
IAM_LOGE("execute func failed"); IAM_LOGE("Failed to execute func");
GlobalUnLock(); GlobalUnLock();
return ret; return ret;
} }
......
...@@ -182,7 +182,7 @@ static int32_t TestCaseAdc(void) ...@@ -182,7 +182,7 @@ static int32_t TestCaseAdc(void)
int32_t i; int32_t i;
int32_t ret; int32_t ret;
DevHandle adcHandle; DevHandle adcHandle;
uint32_t Readbuf[30] = {0}; uint32_t readBuf[30] = {0};
/* 打开ADC设备 */ /* 打开ADC设备 */
adcHandle = AdcOpen(ADC_DEVICE_NUM); adcHandle = AdcOpen(ADC_DEVICE_NUM);
...@@ -193,7 +193,7 @@ static int32_t TestCaseAdc(void) ...@@ -193,7 +193,7 @@ static int32_t TestCaseAdc(void)
/* 连续进行30次AD转换并读取转换结果 */ /* 连续进行30次AD转换并读取转换结果 */
for (i = 0; i < 30; i++) { for (i = 0; i < 30; i++) {
ret = AdcRead(adcHandle, ADC_CHANNEL_NUM, &Readbuf[i]); ret = AdcRead(adcHandle, ADC_CHANNEL_NUM, &readBuf[i]);
if (ret != HDF_SUCCESS) { if (ret != HDF_SUCCESS) {
HDF_LOGE("%s: ADC read fail!:%d", __func__, ret); HDF_LOGE("%s: ADC read fail!:%d", __func__, ret);
AdcClose(adcHandle); AdcClose(adcHandle);
......
...@@ -2448,7 +2448,7 @@ root { ...@@ -2448,7 +2448,7 @@ root {
pwmBacklightConfig { pwmBacklightConfig {
match_attr = "pwm_bl_dev"; match_attr = "pwm_bl_dev";
pwmDevNum = 1; pwmDevNum = 1;
pwmMaxPeroid = 25000; pwmMaxPeriod = 25000;
backlightDevName = "hdf_pwm"; backlightDevName = "hdf_pwm";
minBrightness = 0; minBrightness = 0;
defBrightness = 127; defBrightness = 127;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册