Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
a1156b55
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
You need to sign in or sign up before continuing.
未验证
提交
a1156b55
编写于
4月 12, 2022
作者:
O
openharmony_ci
提交者:
Gitee
4月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3165 新增FA使用记录查询接口
Merge pull request !3165 from Houdisheng/master
上级
c683cb0f
0c27188f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
161 addition
and
21 deletion
+161
-21
zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md
...ice-usage-statistics/device-usage-statistics-dev-guide.md
+33
-1
zh-cn/application-dev/device-usage-statistics/device-usage-statistics-overview.md
...vice-usage-statistics/device-usage-statistics-overview.md
+10
-9
zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md
...ation-dev/reference/apis/js-apis-deviceUsageStatistics.md
+118
-11
未找到文件。
zh-cn/application-dev/device-usage-statistics/device-usage-statistics-dev-guide.md
浏览文件 @
a1156b55
...
@@ -21,6 +21,7 @@ import stats from '@ohos.bundleState';
...
@@ -21,6 +21,7 @@ import stats from '@ohos.bundleState';
| function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback
<
Array
<
BundleStateInfo
>>
): void | 通过指定时间段间隔(天、周、月、年)查询应用使用时长统计信息。 |
| function queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback
<
Array
<
BundleStateInfo
>>
): void | 通过指定时间段间隔(天、周、月、年)查询应用使用时长统计信息。 |
| function queryAppUsagePriorityGroup(callback: AsyncCallback
<
number
>
): void | 查询(返回)当前调用者应用的使用优先级群组。 |
| function queryAppUsagePriorityGroup(callback: AsyncCallback
<
number
>
): void | 查询(返回)当前调用者应用的使用优先级群组。 |
| function isIdleState(bundleName: string, callback: AsyncCallback
<
boolean
>
): void | 判断指定Bundle Name的应用当前是否是空闲状态。 |
| function isIdleState(bundleName: string, callback: AsyncCallback
<
boolean
>
): void | 判断指定Bundle Name的应用当前是否是空闲状态。 |
| function getRecentUsageModules(maxNum: number, callback: AsyncCallback
<
BundleActiveModuleInfo
>
): void | 根据maxNum,查询FA使用记录,返回不超过maxNum条FA使用记录。 |
## 开发步骤
## 开发步骤
...
@@ -204,4 +205,35 @@ import stats from '@ohos.bundleState';
...
@@ -204,4 +205,35 @@ import stats from '@ohos.bundleState';
console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res));
console.log('BUNDLE_ACTIVE isIdleState callback succeeded, result: ' + JSON.stringify(res));
}
}
});
});
```
```
\ No newline at end of file
8.
查询FA使用记录。返回数量最大不超过maxNum设置的值,config.json中需要配置权限:ohos.permission.BUNDLE_ACTIVE_INFO。
```js
import stats from '@ohos.bundleState'
// 异步方法promise方式
stats.getRecentUsageModules(this.maxNum).then( res => {
console.log('BUNDLE_ACTIVE getRecentUsageModules promise succeeded');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentUsageModules promise number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentUsageModules promise result ' + JSON.stringify(res[i]));
}
}).catch( err=> {
console.log('BUNDLE_ACTIVE getRecentUsageModules promise failed, because: ' + err.code);
});
// 异步方法callback方式
stats.getRecentUsageModules(this.maxNum,(err, res) => {
if(err) {
console.log('BUNDLE_ACTIVE getRecentUsageModules callback failed, because: ' + err.code);
} else {
console.log('BUNDLE_ACTIVE getRecentUsageModules callback succeeded.');
for (let i = 0; i < res.length; i++) {
console.log('BUNDLE_ACTIVE getRecentUsageModules callback number : ' + (i + 1));
console.log('BUNDLE_ACTIVE getRecentUsageModules callback result ' + JSON.stringify(res[i]));
}
}
});
```
zh-cn/application-dev/device-usage-statistics/device-usage-statistics-overview.md
浏览文件 @
a1156b55
...
@@ -7,17 +7,18 @@
...
@@ -7,17 +7,18 @@
设备使用信息统计接口众多,目前只支持app usage使用统计,接下来介绍下应用使用详情(app usage)的接口逻辑。
设备使用信息统计接口众多,目前只支持app usage使用统计,接下来介绍下应用使用详情(app usage)的接口逻辑。
-
**应用使用统计信息落盘时机**
:
-
**应用使用统计信息落盘时机**
:
>1. 每隔30分钟触发一次刷新;
1.
每隔30分钟触发一次刷新。
>2. 系统时间变更触发一次刷新;
2.
系统时间变更触发一次刷新。
>3. 下一天开始触发一次刷新;
3.
下一天开始触发一次刷新。
-
**应用查询接口**
:
-
**应用查询接口**
:
>1. 根据起止时间查询所有应用的事件集合;
1.
根据起止时间查询所有应用的事件集合。
>2. 根据起止时间查询应用的使用时长;
2.
根据起止时间查询应用的使用时长。
>3. 根据起止时间查询当前应用的事件集合;
3.
根据起止时间查询当前应用的事件集合。
>4. 根据interval(日、周、月、年)类型和起止时间查询应用的使用时长;
4.
根据interval(日、周、月、年)类型和起止时间查询应用的使用时长。
>5. 查询调用者应用的优先级群组;
5.
查询调用者应用的优先级群组。
>6. 判断指定应用当前是否是空闲状态;
6.
判断指定应用当前是否是空闲状态。
7.
查询FA使用记录。返回数量最大不超过maxNum设置的值,maxNum最大为1000。
### 设备使用信息统计使用权限
### 设备使用信息统计使用权限
-
设备使用信息统计的queryBundleActiveStates、queryBundleStateInfos、queryBundleStateInfoByInterval接口为系统api,调用前需要申请ohos.permission.BUNDLE_ACTIVE_INFO权限。
-
设备使用信息统计的queryBundleActiveStates、queryBundleStateInfos、queryBundleStateInfoByInterval接口为系统api,调用前需要申请ohos.permission.BUNDLE_ACTIVE_INFO权限。
...
...
zh-cn/application-dev/reference/apis/js-apis-deviceUsageStatistics.md
浏览文件 @
a1156b55
...
@@ -59,7 +59,7 @@ isIdleState(bundleName: string): Promise<boolean>
...
@@ -59,7 +59,7 @@ isIdleState(bundleName: string): Promise<boolean>
**示例**
:
**示例**
:
```
```
js
bundleState
.
isIdleState
(
"
com.ohos.camera
"
).
then
(
res
=>
{
bundleState
.
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
=>
{
...
@@ -83,7 +83,7 @@ queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void
...
@@ -83,7 +83,7 @@ queryAppUsagePriorityGroup(callback: AsyncCallback<number>): void
**示例**
:
**示例**
:
```
```
js
bundleState
.
queryAppUsagePriorityGroup
((
err
,
res
)
=>
{
bundleState
.
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
);
...
@@ -109,7 +109,7 @@ queryAppUsagePriorityGroup(): Promise<number>
...
@@ -109,7 +109,7 @@ queryAppUsagePriorityGroup(): Promise<number>
**示例**
:
**示例**
:
```
```
js
bundleState
.
queryAppUsagePriorityGroup
().
then
(
res
=>
{
bundleState
.
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
=>
{
...
@@ -137,7 +137,7 @@ queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback<Bun
...
@@ -137,7 +137,7 @@ queryBundleStateInfos(begin: number, end: number, callback: AsyncCallback<Bun
**示例**
:
**示例**
:
```
```
js
bundleState
.
queryBundleStateInfos
(
0
,
20000000000000
,
(
err
,
res
)
=>
{
bundleState
.
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
);
...
@@ -178,7 +178,7 @@ queryBundleStateInfos(begin: number, end: number): Promise<BundleActiveInfoRe
...
@@ -178,7 +178,7 @@ queryBundleStateInfos(begin: number, end: number): Promise<BundleActiveInfoRe
**示例**
:
**示例**
:
```
```
js
bundleState
.
queryBundleStateInfos
(
0
,
20000000000000
).
then
(
res
=>
{
bundleState
.
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
;
...
@@ -213,7 +213,7 @@ queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: num
...
@@ -213,7 +213,7 @@ queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: num
**示例**
:
**示例**
:
```
```
js
bundleState
.
queryBundleStateInfoByInterval
(
0
,
0
,
20000000000000
,
(
err
,
res
)
=>
{
bundleState
.
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
);
...
@@ -253,7 +253,7 @@ queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: num
...
@@ -253,7 +253,7 @@ queryBundleStateInfoByInterval(byInterval: IntervalType, begin: number, end: num
**示例**
:
**示例**
:
```
```
js
bundleState
.
queryBundleStateInfoByInterval
(
0
,
0
,
20000000000000
).
then
(
res
=>
{
bundleState
.
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
++
)
{
...
@@ -285,7 +285,7 @@ queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback<A
...
@@ -285,7 +285,7 @@ queryBundleActiveStates(begin: number, end: number, callback: AsyncCallback<A
**示例**
:
**示例**
:
```
```
js
bundleState
.
queryBundleActiveStates
(
0
,
20000000000000
,
(
err
,
res
)
=>
{
bundleState
.
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
);
...
@@ -324,7 +324,7 @@ queryBundleActiveStates(begin: number, end: number): Promise<Array<BundleA
...
@@ -324,7 +324,7 @@ queryBundleActiveStates(begin: number, end: number): Promise<Array<BundleA
**示例**
:
**示例**
:
```
```
js
bundleState
.
queryBundleActiveStates
(
0
,
20000000000000
).
then
(
res
=>
{
bundleState
.
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
++
)
{
...
@@ -354,7 +354,7 @@ queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallba
...
@@ -354,7 +354,7 @@ queryCurrentBundleActiveStates(begin: number, end: number, callback: AsyncCallba
**示例**
:
**示例**
:
```
```
js
bundleState
.
queryCurrentBundleActiveStates
(
0
,
20000000000000
,
(
err
,
res
)
=>
{
bundleState
.
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
);
...
@@ -391,7 +391,7 @@ queryCurrentBundleActiveStates(begin: number, end: number): Promise<Array<
...
@@ -391,7 +391,7 @@ queryCurrentBundleActiveStates(begin: number, end: number): Promise<Array<
**示例**
:
**示例**
:
```
```
js
bundleState
.
queryCurrentBundleActiveStates
(
0
,
20000000000000
).
then
(
res
=>
{
bundleState
.
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
++
)
{
...
@@ -403,6 +403,113 @@ queryCurrentBundleActiveStates(begin: number, end: number): Promise<Array<
...
@@ -403,6 +403,113 @@ queryCurrentBundleActiveStates(begin: number, end: number): Promise<Array<
});
});
```
```
## bundleState.getRecentUsageModules<sup>9+</sup>
getRecentUsageModules(maxNum: number): Promise
<
Array
<
BundleActiveModuleInfo
>>
据maxNum,查询FA使用记录,使用Promise形式返回不超过maxNum条FA使用记录,maxNum最大为1000。
**需要权限**
:ohos.permission.BUNDLE_ACTIVE_INFO
**系统能力**
:SystemCapability.ResourceSchedule.UsageStatistics.App
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| maxNum | number | 是 | 返回条目的最大数量。|
**返回值**
:
| 类型 | 说明 |
| -------- | -------- |
| Promise
<
Array
<
[BundleActiveModuleInfo](#bundleactivestate)
>>
| 指定的Promise回调方法。返回不超过maxNum条FA使用记录。|
**示例**
:
```
js
bundleState
.
getRecentUsageModules
(
this
.
maxNum
).
then
(
res
=>
{
console
.
log
(
'
BUNDLE_ACTIVE getRecentUsageModules promise succeeded
'
);
for
(
let
i
=
0
;
i
<
res
.
length
;
i
++
)
{
console
.
log
(
'
BUNDLE_ACTIVE getRecentUsageModules promise number :
'
+
(
i
+
1
));
console
.
log
(
'
BUNDLE_ACTIVE getRecentUsageModules promise result
'
+
JSON
.
stringify
(
res
[
i
]));
}
}).
catch
(
err
=>
{
console
.
log
(
'
BUNDLE_ACTIVE getRecentUsageModules promise failed, because:
'
+
err
.
code
);
});
```
## bundleState.getRecentUsageModules<sup>9+</sup>
getRecentUsageModules(maxNum: number): Promise
<
Array
<
BundleActiveModuleInfo
>>
查询FA使用记录。使用callback形式返回数量最大不超过maxNum设置的值,maxNum最大为1000。
**需要权限**
:ohos.permission.BUNDLE_ACTIVE_INFO
**系统能力**
:SystemCapability.ResourceSchedule.UsageStatistics.App
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| maxNum | number | 是 | 返回条目的最大数量。|
| callback | AsyncCallback
<
Array
<
[BundleActiveModuleInfo](#bundleactivestate)
>>
| 是 | 指定的CallBack回调方法。返回不超过maxNum条FA使用记录。|
**示例**
:
```
js
bundleState
.
getRecentUsageModules
(
this
.
maxNum
,(
err
,
res
)
=>
{
if
(
err
)
{
console
.
log
(
'
BUNDLE_ACTIVE getRecentUsageModules callback failed, because:
'
+
err
.
code
);
}
else
{
console
.
log
(
'
BUNDLE_ACTIVE getRecentUsageModules callback succeeded.
'
);
for
(
let
i
=
0
;
i
<
res
.
length
;
i
++
)
{
console
.
log
(
'
BUNDLE_ACTIVE getRecentUsageModules callback number :
'
+
(
i
+
1
));
console
.
log
(
'
BUNDLE_ACTIVE getRecentUsageModules callback result
'
+
JSON
.
stringify
(
res
[
i
]));
}
}
});
```
## BundleActiveModuleInfo<sup>9+</sup>
FA的使用信息的属性集合。
### 属性
**系统能力**
:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.App
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| deviceId | string | 是 | FA所属deviceId。|
| bundleName | string | 是 | FA所属应用包名。|
| moduleName | string | 是 | FA所属module名。|
| abilityName | string | 是 | FA的MainAbility名。|
| appLabelId | number | 是 | FA的应用labelId。|
| labelId | number | 是 | FA所属module的labelId。|
| descriptionId | number | 是 | FA的应用descriptionId。|
| abilityLableId | number | 是 | FA的MainAbility labelId。|
| abilityDescriptionId | number | 是 | FA的MainAbility descriptionId。|
| abilityIconId | number | 是 | FA的MainAbility iconId。|
| launchedCount | number | 是 | FA的启动次数。|
| lastModuleUsedTime | number | 是 | FA的上一次使用时间。|
| formRecords | Array
<BundleActiveFormInfo>
| 是 | FA中卡片的使用记录。|
## BundleActiveFormInfo<sup>9+</sup>
FA卡片的使用信息的属性集合。
### 属性
**系统能力**
:以下各项对应的系统能力均为SystemCapability.ResourceSchedule.UsageStatistics.App
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| formName | number | 是 | 卡片名称。|
| formDimension | number | 是 | 卡片尺寸。|
| formId | number | 是 | 卡片Id。|
| formLastUsedTime | number | 是 | 卡片的上一次点击时间。|
| count | number | 是 | 卡片的点击次数。|
## BundleStateInfo
## BundleStateInfo
提供应用使用时长的具体信息。
提供应用使用时长的具体信息。
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录