提交 73436c3b 编写于 作者: H houdisheng

同步API评审意见

Signed-off-by: Nhoudisheng <houdisheng@huawei.com>
上级 48fecfde
...@@ -207,7 +207,7 @@ import stats from '@ohos.bundleState'; ...@@ -207,7 +207,7 @@ import stats from '@ohos.bundleState';
}); });
``` ```
8. 查询FA使用记录。返回数量最大不超过maxNum设置的值,config.json中需要配置权限:ohos.permission.BUNDLE_ACTIVE_INFO。 8. 查询FA使用记录。返回数量最大不超过maxNum设置的值,若不传入maxNum参数,则默认maxNum为1000。config.json中需要配置权限:ohos.permission.BUNDLE_ACTIVE_INFO。
```js ```js
import stats from '@ohos.bundleState' import stats from '@ohos.bundleState'
...@@ -223,6 +223,17 @@ import stats from '@ohos.bundleState'; ...@@ -223,6 +223,17 @@ 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);
}); });
// 无参数异步方法promise方式
stats.getRecentlyUsedModules().then( res => {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise result ' + JSON.stringify(res[i]));
}
}).catch( err=> {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code);
});
// 异步方法callback方式 // 异步方法callback方式
stats.getRecentlyUsedModules(this.maxNum,(err, res) => { stats.getRecentlyUsedModules(this.maxNum,(err, res) => {
if(err) { if(err) {
...@@ -235,5 +246,18 @@ import stats from '@ohos.bundleState'; ...@@ -235,5 +246,18 @@ import stats from '@ohos.bundleState';
} }
} }
}); });
// 无参数异步方法callback方式
stats.getRecentlyUsedModules((err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback succeeded.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback result ' + JSON.stringify(res[i]));
}
}
});
``` ```
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
4. 根据interval(日、周、月、年)类型和起止时间查询应用的使用时长。 4. 根据interval(日、周、月、年)类型和起止时间查询应用的使用时长。
5. 查询调用者应用的优先级群组。 5. 查询调用者应用的优先级群组。
6. 判断指定应用当前是否是空闲状态。 6. 判断指定应用当前是否是空闲状态。
7. 查询FA使用记录。返回数量最大不超过maxNum设置的值,FA使用记录由近及远排序,maxNum最大为1000。 7. 查询FA使用记录。返回数量最大不超过maxNum设置的值,FA使用记录由近及远排序,maxNum最大为1000,若不填写maxNum参数,则maxNum默认为1000
### 设备使用信息统计使用权限 ### 设备使用信息统计使用权限
- 设备使用信息统计的queryBundleActiveStates、queryBundleStateInfos、queryBundleStateInfoByInterval接口为系统api,调用前需要申请ohos.permission.BUNDLE_ACTIVE_INFO权限。 - 设备使用信息统计的queryBundleActiveStates、queryBundleStateInfos、queryBundleStateInfoByInterval接口为系统api,调用前需要申请ohos.permission.BUNDLE_ACTIVE_INFO权限。
......
...@@ -417,7 +417,7 @@ getRecentlyUsedModules(maxNum: number): Promise&lt;Array&lt;BundleActiveModuleIn ...@@ -417,7 +417,7 @@ getRecentlyUsedModules(maxNum: number): Promise&lt;Array&lt;BundleActiveModuleIn
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| maxNum | number | 是 | 返回条目的最大数量。| | maxNum | number | 否 | 返回条目的最大数量,若不填写,则默认为1000。|
**返回值** **返回值**
...@@ -437,6 +437,17 @@ getRecentlyUsedModules(maxNum: number): Promise&lt;Array&lt;BundleActiveModuleIn ...@@ -437,6 +437,17 @@ getRecentlyUsedModules(maxNum: number): Promise&lt;Array&lt;BundleActiveModuleIn
}).catch( err=> { }).catch( err=> {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code); console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code);
}); });
// 无参数调用方式
bundleState.getRecentlyUsedModules().then( res => {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise succeeded');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise result ' + JSON.stringify(res[i]));
}
}).catch( err=> {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules promise failed, because: ' + err.code);
});
``` ```
## bundleState.getRecentlyUsedModules<sup>9+</sup> ## bundleState.getRecentlyUsedModules<sup>9+</sup>
...@@ -453,7 +464,7 @@ getRecentlyUsedModules(maxNum: number, callback: AsyncCallback&lt;Array&lt;Bundl ...@@ -453,7 +464,7 @@ getRecentlyUsedModules(maxNum: number, callback: AsyncCallback&lt;Array&lt;Bundl
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| maxNum | number | 是 | 返回条目的最大数量。| | maxNum | number | 否 | 返回条目的最大数量,若不填写,则默认为1000。|
| callback | AsyncCallback&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivestate)&gt;&gt; | 是 | 指定的CallBack回调方法。返回不超过maxNum条FA使用记录。| | callback | AsyncCallback&lt;Array&lt;[BundleActiveModuleInfo](#bundleactivestate)&gt;&gt; | 是 | 指定的CallBack回调方法。返回不超过maxNum条FA使用记录。|
**示例** **示例**
...@@ -470,13 +481,24 @@ getRecentlyUsedModules(maxNum: number, callback: AsyncCallback&lt;Array&lt;Bundl ...@@ -470,13 +481,24 @@ getRecentlyUsedModules(maxNum: number, callback: AsyncCallback&lt;Array&lt;Bundl
} }
} }
}); });
// 无参数调用方式
stats.getRecentlyUsedModules((err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback succeeded.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentlyUsedModules callback result ' + JSON.stringify(res[i]));
}
}
});
``` ```
## BundleActiveModuleInfo<sup>9+</sup> ## BundleActiveModuleInfo<sup>9+</sup>
FA的使用信息的属性集合。 FA的使用信息的属性集合。
### 属性
**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.App **系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.App
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
...@@ -487,7 +509,7 @@ FA的使用信息的属性集合。 ...@@ -487,7 +509,7 @@ FA的使用信息的属性集合。
| abilityName | string | 是 | FA的MainAbility名。| | abilityName | string | 是 | FA的MainAbility名。|
| appLabelId | number | 是 | FA的应用labelId。| | appLabelId | number | 是 | FA的应用labelId。|
| labelId | number | 是 | FA所属module的labelId。| | labelId | number | 是 | FA所属module的labelId。|
| descriptionId | number | 是 | FA的应用descriptionId。| | descriptionId | number | 是 | FA所属的应用descriptionId。|
| abilityLableId | number | 是 | FA的MainAbility labelId。| | abilityLableId | number | 是 | FA的MainAbility labelId。|
| abilityDescriptionId | number | 是 | FA的MainAbility descriptionId。| | abilityDescriptionId | number | 是 | FA的MainAbility descriptionId。|
| abilityIconId | number | 是 | FA的MainAbility iconId。| | abilityIconId | number | 是 | FA的MainAbility iconId。|
...@@ -498,8 +520,6 @@ FA的使用信息的属性集合。 ...@@ -498,8 +520,6 @@ FA的使用信息的属性集合。
## BundleActiveFormInfo<sup>9+</sup> ## BundleActiveFormInfo<sup>9+</sup>
FA卡片的使用信息的属性集合。 FA卡片的使用信息的属性集合。
### 属性
**系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.App **系统能力**:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.App
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册