Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
a0d83ea1
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
未验证
提交
a0d83ea1
编写于
8月 18, 2023
作者:
O
openharmony_ci
提交者:
Gitee
8月 18, 2023
浏览文件
操作
浏览文件
下载
差异文件
!22003 异步接口整改文档修改
Merge pull request !22003 from geraltxu/master
上级
7ca9eaa4
d942f07b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
148 addition
and
0 deletion
+148
-0
zh-cn/application-dev/device-usage-statistics/device-usage-statistics-use-guide.md
...ice-usage-statistics/device-usage-statistics-use-guide.md
+18
-0
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md
...ce/apis/js-apis-resourceschedule-deviceUsageStatistics.md
+130
-0
未找到文件。
zh-cn/application-dev/device-usage-statistics/device-usage-statistics-use-guide.md
浏览文件 @
a0d83ea1
...
...
@@ -21,9 +21,12 @@ import usageStatistics from '@ohos.resourceschedule.usageStatistics';
| function queryBundleStatsInfoByInterval(byInterval: IntervalType, begin: number, end: number, callback: AsyncCallback
<
Array
<
BundleStatsInfo
>>
): void | 通过指定时间段间隔(天、周、月、年)查询应用使用时长统计信息。 |
| function queryAppGroup(callback: AsyncCallback
<
number
>
): void | 查询当前应用的使用优先级群组。callback形式。 |
| function queryAppGroup(): Promise
<
number
>
; | 查询当前应用的使用优先级群组。promise形式。 |
|function queryAppGroupSync(): number; | 查询当前应用的使用优先级群组。同步接口。|
| function queryAppGroup(bundleName : string, callback: AsyncCallback
<
number
>
): void | 查询指定应用的使用优先级群组。callback形式。 |
| function queryAppGroup(bundleName : string): Promise
<
number
>
; | 查询当前调用者应用或者指定应用的使用优先级群组。promise形式。 |
|function queryAppGroupSync(bundleName: string): number; | 查询当前调用者应用或者指定应用的使用优先级群组。同步接口。|
| function isIdleState(bundleName: string, callback: AsyncCallback
<
boolean
>
): void | 判断指定Bundle Name的应用当前是否是空闲状态。 |
|function isIdleStateSync(bundleName: string): boolean; | 判断指定Bundle Name的应用当前是否是空闲状态,同步接口。 |
| function queryModuleUsageRecords(callback: AsyncCallback
<
HapModuleInfo
>
): void | 查询FA使用记录,返回不超过1000条FA使用记录。 |
| function queryModuleUsageRecords(maxNum: number, callback: AsyncCallback
<
HapModuleInfo
>
): void | 根据maxNum,查询FA使用记录,返回不超过maxNum条FA使用记录。 maxNum不超过1000|
| function queryNotificationEventStats(begin: number, end: number, callback: AsyncCallback
<
Array
<
DeviceEventStats
>>
): void | 通过指定起始和结束时间查询所有应用的通知次数。 |
...
...
@@ -225,6 +228,14 @@ import usageStatistics from '@ohos.resourceschedule.usageStatistics';
} catch (error) {
console.log('BUNDLE_ACTIVE queryAppGroup throw error, code is: ' + error.code + ',message is: ' + error.message);
}
//同步方式
try{
var priorityGroup = usageStatistics.queryAppGroupSync();
} catch (error) {
console.log('BUNDLE_ACTIVE queryAppGroup throw error, code is: ' + error.code + ',message is: ' + error.message);
}
```
7.
判断指定Bundle Name的应用当前是否是空闲状态,需要配置ohos.permission.BUNDLE_ACTIVE_INFO权限。
...
...
@@ -255,6 +266,13 @@ import usageStatistics from '@ohos.resourceschedule.usageStatistics';
} catch(error) {
console.log('BUNDLE_ACTIVE isIdleState throw error, code is: ' + error.code + ',message is: ' + error.message);
}
//同步方式
try{
var isIdleState = usageStatistics.isIdleStateSync("com.ohos.camera");
} catch(error) {
console.log('BUNDLE_ACTIVE isIdleState throw error, code is: ' + error.code + ',message is: ' + error.message);
}
```
8.
查询FA使用记录。返回数量最大不超过maxNum设置的值,若不传入maxNum参数,则默认maxNum为1000, 需要配置ohos.permission.BUNDLE_ACTIVE_INFO权限。
...
...
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceUsageStatistics.md
浏览文件 @
a0d83ea1
...
...
@@ -124,6 +124,50 @@ isIdleState(bundleName: string): Promise<boolean>
console
.
log
(
'
BUNDLE_ACTIVE isIdleState throw error, code is:
'
+
error
.
code
+
'
,message is:
'
+
error
.
message
);
}
```
## usageStatistics.isIdleStateSync<sup>10+<sup>
isIdleStateSync(bundleName: string): boolean
判断指定bundleName的应用当前是否是空闲状态,三方应用只能查询自身的空闲状态。
**需要权限**
:ohos.permission.BUNDLE_ACTIVE_INFO
**系统能力**
:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**系统API**
:此接口为系统接口。
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------- | ---- | ---------------------------------------- |
| bundleName | string | 是 | 应用的bundleName。 |
**返回值**
:
| 类型 | 说明 |
| ---------------------- | ---------------------------------------- |
| boolean | 如果指定的bundleName有效,返回true则表示空闲状态,false则非空闲。 |
**错误码**
:
以下错误码的详细介绍请参见
[
设备信息使用统计错误码
](
../errorcodes/errorcode-DeviceUsageStatistics.md
)
。
| 错误码ID | 错误信息 |
| ---------- | ---------------------------- |
| 10000001 | Memory operation failed. |
| 10000002 | Parcel operation failed. |
| 10000003 | System service operation failed. |
| 10000004 | IPC failed. |
| 10000006 | Failed to get the application information. |
**示例**
:
```
js
try
{
var
isIdleState
=
usageStatistics
.
isIdleStateSync
(
"
com.ohos.camera
"
);
}
catch
(
error
)
{
console
.
log
(
'
BUNDLE_ACTIVE isIdleState throw error, code is:
'
+
error
.
code
+
'
,message is:
'
+
error
.
message
);
}
```
## usageStatistics.queryAppGroup
...
...
@@ -215,6 +259,92 @@ queryAppGroup(callback: AsyncCallback<number>): void
}
```
## usageStatistics.queryAppGroupSync<sup>10+<sup>
queryAppGroupSync(): number;
查询当前应用的优先级分组。
**系统能力**
:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**系统API**
:此接口为系统接口。
**返回值**
:
| 类型 | 说明 |
| --------------- | --------------------------- |
| number | 返回当前应用优先级分组结果。 |
**错误码**
:
以下错误码的详细介绍请参见
[
设备信息使用统计错误码
](
../errorcodes/errorcode-DeviceUsageStatistics.md
)
。
| 错误码ID | 错误信息 |
| ---------- | ---------------------------- |
| 10000001 | Memory operation failed. |
| 10000002 | Parcel operation failed. |
| 10000003 | System service operation failed. |
| 10000004 | IPC failed. |
| 10000005 | Application is not installed. |
| 10000006 | Failed to get the application information. |
| 10100002 | Failed to get the application group information. |
**示例**
:
```
javascript
try
{
var
priorityGroup
=
usageStatistics
.
queryAppGroupSync
();
}
catch
(
error
)
{
console
.
log
(
'
BUNDLE_ACTIVE queryAppGroup throw error, code is:
'
+
error
.
code
+
'
,message is:
'
+
error
.
message
);
}
```
## usageStatistics.queryAppGroupSync<sup>10+<sup>
queryAppGroupSync(bundleName: string): number
查询指定bundleName应用的优先级分组。
**系统能力**
:SystemCapability.ResourceSchedule.UsageStatistics.AppGroup
**系统API**
:此接口为系统接口。
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------- | ---- | ---------------------------------------- |
| bundleName | string | 是 | 应用的bundleName。 |
**返回值**
:
| 类型 | 说明 |
| --------------- | --------------------------- |
| number | 返回指定bundleName应用优先级分组结果。 |
**错误码**
:
以下错误码的详细介绍请参见
[
设备信息使用统计错误码
](
../errorcodes/errorcode-DeviceUsageStatistics.md
)
。
| 错误码ID | 错误信息 |
| ---------- | ---------------------------- |
| 10000001 | Memory operation failed. |
| 10000002 | Parcel operation failed. |
| 10000003 | System service operation failed. |
| 10000004 | IPC failed. |
| 10000005 | Application is not installed. |
| 10000006 | Failed to get the application information. |
| 10100002 | Failed to get the application group information. |
**示例**
:
```
javascript
try
{
var
priorityGroup
=
usageStatistics
.
queryAppGroupSync
(
"
com.ohos.camera
"
);
}
catch
(
error
)
{
console
.
log
(
'
BUNDLE_ACTIVE queryAppGroup throw error, code is:
'
+
error
.
code
+
'
,message is:
'
+
error
.
message
);
}
```
## usageStatistics.queryBundleStatsInfos
queryBundleStatsInfos(begin: number, end: number, callback: AsyncCallback
<
BundleStatsMap
>
): void
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录