Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
8568e6b7
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看板
提交
8568e6b7
编写于
6月 13, 2023
作者:
G
geraltxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update js-apis-resourceschedule-deviceStandby.md
Signed-off-by:
N
xufanghan
<
xufanghan@huawei.com
>
上级
3244ba9b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
130 addition
and
3 deletion
+130
-3
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md
.../reference/apis/js-apis-resourceschedule-deviceStandby.md
+130
-3
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md
浏览文件 @
8568e6b7
# @ohos.resourceschedule.deviceStandby(设备待机模块)
# @ohos.resourceschedule.deviceStandby(设备待机模块)
当设备长时间未被使用或通过按键,可以使设备进入待机模式。待机模式不影响应用使用,还可以延长电池续航时间。通过本模块接口,可查询设备是否为待机模式,以及使
应用灵活申请开启或关闭待机模式
。
当设备长时间未被使用或通过按键,可以使设备进入待机模式。待机模式不影响应用使用,还可以延长电池续航时间。通过本模块接口,可查询设备是否为待机模式,以及使
设备某个应用能避免纳入待机资源管控、解除避免资源管控
。
> **说明:**
> **说明:**
> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...
@@ -8,6 +8,9 @@
...
@@ -8,6 +8,9 @@
```
js
```
js
import
deviceStandby
from
'
@ohos.resourceschedule.deviceStandby
'
;
import
deviceStandby
from
'
@ohos.resourceschedule.deviceStandby
'
;
```
```
需要检查是否已经配置请求相应的权限: ohos.permission.DEVICE_STANDBY_EXEMPTION
## deviceStandby.isDeviceInStandby
## deviceStandby.isDeviceInStandby
isDeviceInStandby(callback: AsyncCallback
<
boolean
>
): void;
isDeviceInStandby(callback: AsyncCallback
<
boolean
>
): void;
...
@@ -33,6 +36,20 @@ isDeviceInStandby(callback: AsyncCallback<boolean>): void;
...
@@ -33,6 +36,20 @@ isDeviceInStandby(callback: AsyncCallback<boolean>): void;
| 9800004 | System service operation failed. |
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
**示例**
:
try{
deviceStandby.isDeviceInStandby((err, res) => {
if (err) {
console.log('DEVICE_STANDBY isDeviceInStandby callback failed. code is: ' + err.code + ',message is: ' + err.message);
} else {
console.log('DEVICE_STANDBY isDeviceInStandby callback succeeded, result: ' + JSON.stringify(res));
}
});
} catch(error) {
console.log('DEVICE_STANDBY isDeviceInStandby throw error, code is: ' + error.code + ',message is: ' + error.message);
}
## deviceStandby.isDeviceInStandby
## deviceStandby.isDeviceInStandby
isDeviceInStandby(): Promise
<
boolean
>
isDeviceInStandby(): Promise
<
boolean
>
...
@@ -58,6 +75,18 @@ isDeviceInStandby(): Promise<boolean>
...
@@ -58,6 +75,18 @@ isDeviceInStandby(): Promise<boolean>
| 9800004 | System service operation failed. |
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
**示例**
:
try{
deviceStandby.isDeviceInStandby().then( res => {
console.log('DEVICE_STANDBY isDeviceInStandby promise succeeded, result: ' + JSON.stringify(res));
}).catch( err => {
console.log('DEVICE_STANDBY isDeviceInStandby promise failed. code is: ' + err.code + ',message is: ' + err.message);
});
} catch (error) {
console.log('DEVICE_STANDBY isDeviceInStandby throw error, code is: ' + error.code + ',message is: ' + error.message);
}
## deviceStandby.getExemptedApps
## deviceStandby.getExemptedApps
getExemptedApps(resourceTypes: number, callback: AsyncCallback
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
): void;
getExemptedApps(resourceTypes: number, callback: AsyncCallback
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
): void;
...
@@ -86,6 +115,23 @@ getExemptedApps(resourceTypes: number, callback: AsyncCallback<Array<Exempted
...
@@ -86,6 +115,23 @@ getExemptedApps(resourceTypes: number, callback: AsyncCallback<Array<Exempted
| 9800004 | System service operation failed. |
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
**示例**
:
try{
deviceStandby.getExemptedApps(resourceTypes, (err, res) => {
if (err) {
console.log('DEVICE_STANDBY getExemptedApps callback failed. code is: ' + err.code + ',message is: ' + err.message);
} else {
console.log('DEVICE_STANDBY getExemptedApps callback success.');
for (let i = 0; i < res.length; i++) {
console.log('DEVICE_STANDBY getExemptedApps callback result ' + JSON.stringify(res[i]));
}
}
});
} catch (error) {
console.log('DEVICE_STANDBY getExemptedApps throw error, code is: ' + error.code + ',message is: ' + error.message);
}
## deviceStandby.getExemptedApps
## deviceStandby.getExemptedApps
getExemptedApps(resourceTypes: number): Promise
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
;
getExemptedApps(resourceTypes: number): Promise
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
;
...
@@ -122,10 +168,25 @@ getExemptedApps(resourceTypes: number): Promise<Array<ExemptedAppInfo>>;
...
@@ -122,10 +168,25 @@ getExemptedApps(resourceTypes: number): Promise<Array<ExemptedAppInfo>>;
| 9800004 | System service operation failed. |
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
**示例**
:
try{
deviceStandby.getExemptedApps(resourceTypes).then( res => {
console.log('DEVICE_STANDBY getExemptedApps promise success.');
for (let i = 0; i < res.length; i++) {
console.log('DEVICE_STANDBY getExemptedApps promise result ' + JSON.stringify(res[i]));
}
}).catch( err => {
console.log('DEVICE_STANDBY getExemptedApps promise failed. code is: ' + err.code + ',message is: ' + err.message);
});
} catch (error) {
console.log('DEVICE_STANDBY getExemptedApps throw error, code is: ' + error.code + ',message is: ' + error.message);
}
## deviceStandby.requestExemptionResource
## deviceStandby.requestExemptionResource
requestExemptionResource(request: ResourceRequest): void;
requestExemptionResource(request: ResourceRequest): void;
订阅申请豁免,为应用申请临时不进入待机管控能力。
订阅申请豁免,为应用申请临时不进入待机管控能力。
(申请豁免待机状态解除指定类型资源限制)
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
...
@@ -149,10 +210,43 @@ requestExemptionResource(request: ResourceRequest): void;
...
@@ -149,10 +210,43 @@ requestExemptionResource(request: ResourceRequest): void;
| 9800004 | System service operation failed. |
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
**示例**
:
let resRequest = {
resourceTypes: 1,
uid:10003,
name:"com.example.app",
duration:10,
reason:"apply",
};
// 异步方法promise方式
try{
deviceStandby.requestExemptionResource(resRequest).then( () => {
console.log('DEVICE_STANDBY requestExemptionResource promise succeeded.');
}).catch( err => {
console.log('DEVICE_STANDBY requestExemptionResource promise failed. code is: ' + err.code + ',message is: ' + err.message);
});
} catch (error) {
console.log('DEVICE_STANDBY requestExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message);
}
// 异步方法callback方式
try{
deviceStandby.requestExemptionResource(resRequest, (err) => {
if (err) {
console.log('DEVICE_STANDBY requestExemptionResource callback failed. code is: ' + err.code + ',message is: ' + err.message);
} else {
console.log('DEVICE_STANDBY requestExemptionResource callback succeeded.');
}
});
} catch (error) {
console.log('DEVICE_STANDBY requestExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message);
}
## deviceStandby.releaseExemptionResource
## deviceStandby.releaseExemptionResource
releaseExemptionResource(request: ResourceRequest): void;
releaseExemptionResource(request: ResourceRequest): void;
去除订阅申请豁免,去除应用暂时不进入待机管控的能力。
去除订阅申请豁免,去除应用暂时不进入待机管控的能力。
(申请去除豁免待机状态解除指定类型资源限制)
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
...
@@ -176,6 +270,39 @@ releaseExemptionResource(request: ResourceRequest): void;
...
@@ -176,6 +270,39 @@ releaseExemptionResource(request: ResourceRequest): void;
| 9800004 | System service operation failed. |
| 9800004 | System service operation failed. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
**示例**
:
let resRequest = {
resourceTypes: 1,
uid:10003,
name:"com.demo.app",
duration:10,
reason:"unapply",
};
// 异步方法promise方式
try{
deviceStandby.releaseExemptionResource(resRequest).then( () => {
console.log('DEVICE_STANDBY releaseExemptionResource promise succeeded.');
}).catch( err => {
console.log('DEVICE_STANDBY releaseExemptionResource promise failed. code is: ' + err.code + ',message is: ' + err.message);
});
} catch (error) {
console.log('DEVICE_STANDBY releaseExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message);
}
// 异步方法callback方式
try{
deviceStandby.releaseExemptionResource(resRequest, (err) => {
if (err) {
console.log('DEVICE_STANDBY releaseExemptionResource callback failed. code is: ' + err.code + ',message is: ' + err.message);
} else {
console.log('DEVICE_STANDBY releaseExemptionResource callback succeeded.');
}
});
} catch (error) {
console.log('DEVICE_STANDBY releaseExemptionResource throw error, code is: ' + error.code + ',message is: ' + error.message);
}
## ResourceType
## ResourceType
非待机应用资源枚举。
非待机应用资源枚举。
<br>
<br>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录