Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
5b17f180
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看板
提交
5b17f180
编写于
5月 24, 2023
作者:
G
geraltxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
文档修改
Signed-off-by:
N
xufanghan
<
xufanghan@huawei.com
>
上级
172cf0c1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
74 addition
and
66 deletion
+74
-66
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md
.../reference/apis/js-apis-resourceschedule-deviceStandby.md
+74
-66
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md
浏览文件 @
5b17f180
# @ohos.resourceschedule.deviceStandby(设备待机
空闲部件功能
)
# @ohos.resourceschedule.deviceStandby(设备待机
模块
)
本模块提供设备待机空闲部件管理功能
本模块提供设备待机空闲部件管理功能
API使用场景:
API使用场景:
如果用户长时间没有主动使用设备,且屏幕已关闭,则系统会使设备进入待机低功耗续航模式。待机续航模式会延迟应用后台CPU和网络活动,从而延长电池续航时间。 包括:
当设备长时间未被使用或通过按键,可以使设备进入待机模式。待机模式不影响应用使用,还可以延长电池续航时间。
1、应用限网:限制后台应用访问网络
通过本模块接口,可查询设备是否为待机模式,以及使应用灵活申请开启或关闭待机模式。
2、Work待机任务:延迟应用的work任务响应
3、running_lock锁:临时释放应用的background running_lock锁
4、Timer响应:延迟应用的timer响应
5、待规划:停止wifi扫描、停止蓝牙扫描、云同步账户等
> **说明:**
> **说明:**
> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...
@@ -15,22 +13,23 @@ API使用场景:
...
@@ -15,22 +13,23 @@ API使用场景:
import
deviceStandby
from
'
@ohos.resourceschedule.deviceStandby
'
;
import
deviceStandby
from
'
@ohos.resourceschedule.deviceStandby
'
;
```
```
## deviceStandby.isDeviceInStandby
## deviceStandby.isDeviceInStandby
function isDeviceInStandby(callback: AsyncCallback
<boolean>
): void;
isDeviceInStandby(callback: AsyncCallback
<boolean>
): void;
当前设备是否进入待机低功耗续航模式
当前设备是否进入待机低功耗续航模式,使用Callback异步回调。
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby
**参数**
:
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------ |
| -------- | -------------------- | ---- | ------------------------------ |
| callback | Callback
<
void
>
| 是 | 延迟即将超时的回调函数,一般在超时前6秒通过此回调通知应用。 |
| callback | Callback
<
boolean
>
| 是 | 延迟即将超时的回调函数,一般在超时前6秒通过此回调通知应用。 |
**错误码**
:
**错误码**
:
以下错误码的详细介绍请参见
[
@ohos.resourceschedule.backgroundTaskManager (后台任务管理)
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
错误码
。
以下错误码的详细介绍请参见
[
后台任务错误码
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
。
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| ---- | --------------------- |
| ---- | --------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 9800001 | Memory operation failed. |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
| 9800002 | Parcel operation failed. |
| 9800003 | IPC failed. |
| 9800003 | IPC failed. |
...
@@ -38,9 +37,12 @@ function isDeviceInStandby(callback: AsyncCallback<boolean>): void;
...
@@ -38,9 +37,12 @@ function isDeviceInStandby(callback: AsyncCallback<boolean>): void;
| 18700001 | Caller information verification failed when applying for efficiency resources. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
## deviceStandby.isDeviceInStandby
## deviceStandby.isDeviceInStandby
function isDeviceInStandby(): Promise
<
boolean
>
isDeviceInStandby(): Promise
<
boolean
>
当前设备是否进入待机低功耗续航模式
当前设备是否进入待机低功耗续航模式,使用Promise异步回调。
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby
**返回值**
:
**返回值**
:
| 类型 | 说明 |
| 类型 | 说明 |
...
@@ -48,12 +50,10 @@ function isDeviceInStandby(): Promise<boolean>
...
@@ -48,12 +50,10 @@ function isDeviceInStandby(): Promise<boolean>
| Promise
<
boolean
>
| 指定的Promise回调方法。返回是否进入待机低功耗续航模式。|
| Promise
<
boolean
>
| 指定的Promise回调方法。返回是否进入待机低功耗续航模式。|
**错误码**
:
**错误码**
:
以下错误码的详细介绍请参见
[
@ohos.resourceschedule.backgroundTaskManager (后台任务管理)
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
错误码
。
以下错误码的详细介绍请参见
[
后台任务错误码
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
。
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| ---- | --------------------- |
| ---- | --------------------- |
| 201 | Permission denied. |
| 401 | Parameter error. |
| 9800001 | Memory operation failed. |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
| 9800002 | Parcel operation failed. |
| 9800003 | IPC failed. |
| 9800003 | IPC failed. |
...
@@ -61,52 +61,57 @@ function isDeviceInStandby(): Promise<boolean>
...
@@ -61,52 +61,57 @@ function isDeviceInStandby(): Promise<boolean>
| 18700001 | Caller information verification failed when applying for efficiency resources. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
## deviceStandby.getExemptedApps
## deviceStandby.getExemptedApps
function getExemptedApps(resourceTypes: number, callback: AsyncCallback
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
): void;
getExemptedApps(resourceTypes: number, callback: AsyncCallback
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
): void;
返回豁免应用名单
获取进入待机模式的应用名单,使用Callback异步回调。
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby
**系统API:**
此接口为系统接口。
**系统API:**
此接口为系统接口。
**参数**
:
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------ |
| -------- | -------------------- | ---- | ------------------------------ |
| resourceTypes |number | 是 |
资源类型,具体结构见文末枚举
|
| resourceTypes |number | 是 |
[
ResourceType
](
#ResourceType
)
|
| callback | AsyncCallback
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
| 是 |
回调函数,具体结构见文末
|
| callback | AsyncCallback
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
| 是 |
[
ExemptedAppInfo
](
#ExemptedAppInfo
)
|
**错误码**
:
**错误码**
:
以下错误码的详细介绍请参见
[
@ohos.resourceschedule.backgroundTaskManager (后台任务管理)
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
错误码
。
以下错误码的详细介绍请参见
[
后台任务错误码
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
。
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| ---- | --------------------- |
| ---- | --------------------- |
| 201 | Permission denied. |
| 202 | Not System App. |
| 401 | Parameter error. |
| 9800001 | Memory operation failed. |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
| 9800002 | Parcel operation failed. |
| 9800003 | IPC failed. |
| 9800003 | IPC failed. |
| 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. |
## deviceStandby.getExemptedApps
## deviceStandby.getExemptedApps
function getExemptedApps(resourceTypes: number): Promise
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
;
getExemptedApps(resourceTypes: number): Promise
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
;
返回豁免应用名单
获取进入待机模式的应用名单,使用Promise异步回调。
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby
**系统API:**
此接口为系统接口。
**系统API:**
此接口为系统接口。
**参数**
:
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------ |
| -------- | -------------------- | ---- | ------------------------------ |
| resourceTypes |number | 是 |
资源类型。
|
| resourceTypes |number | 是 |
[
ResourceType
](
#ResourceType
)
|
**返回值**
:
**返回值**
:
| 类型 | 说明 |
| 类型 | 说明 |
| --------------------- | ---------------------------------------- |
| --------------------- | ---------------------------------------- |
| Promise
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
|
指定的Promise回调方法。返回豁免应用名单,具体结构见文末
|
| Promise
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
|
[
ExemptedAppInfo
](
#ExemptedAppInfo
)
|
**错误码**
:
**错误码**
:
以下错误码的详细介绍请参见
[
@ohos.resourceschedule.backgroundTaskManager (后台任务管理)
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
错误码
。
以下错误码的详细介绍请参见
[
后台任务错误码
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
。
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| ---- | --------------------- |
| ---- | --------------------- |
...
@@ -120,25 +125,26 @@ function getExemptedApps(resourceTypes: number): Promise<Array<ExemptedAppInf
...
@@ -120,25 +125,26 @@ function getExemptedApps(resourceTypes: number): Promise<Array<ExemptedAppInf
| 18700001 | Caller information verification failed when applying for efficiency resources. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
## deviceStandby.requestExemptionResource
## deviceStandby.requestExemptionResource
function requestExemptionResource(request: ResourceRequest): void;
requestExemptionResource(request: ResourceRequest): void;
订阅申请豁免
订阅申请豁免。
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
**系统API:**
此接口为系统接口。
**系统API:**
此接口为系统接口。
**参数**
:
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------ |
| -------- | -------------------- | ---- | ------------------------------ |
| request |ResourceRequest | 是 |
请求豁免应用信息数据结构,具体结构见文末请求体
|
| request |ResourceRequest | 是 |
[
ResourceRequest
](
#ResourceRequest
)
|
**错误码**
:
**错误码**
:
以下错误码的详细介绍请参见
[
@ohos.resourceschedule.backgroundTaskManager (后台任务管理)
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
错误码
。
以下错误码的详细介绍请参见
[
后台任务错误码
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
。
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| ---- | --------------------- |
| ---- | --------------------- |
| 201 | Permission denied. |
| 202 | Not System App. |
| 401 | Parameter error. |
| 9800001 | Memory operation failed. |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
| 9800002 | Parcel operation failed. |
| 9800003 | IPC failed. |
| 9800003 | IPC failed. |
...
@@ -146,26 +152,26 @@ function requestExemptionResource(request: ResourceRequest): void;
...
@@ -146,26 +152,26 @@ function requestExemptionResource(request: ResourceRequest): void;
| 18700001 | Caller information verification failed when applying for efficiency resources. |
| 18700001 | Caller information verification failed when applying for efficiency resources. |
## deviceStandby.releaseExemptionResource
## deviceStandby.releaseExemptionResource
function releaseExemptionResource(request: ResourceRequest): void;
releaseExemptionResource(request: ResourceRequest): void;
去除订阅申请豁免
去除订阅申请豁免。
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
**系统API:**
此接口为系统接口。
**系统API:**
此接口为系统接口。
**参数**
:
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------ |
| -------- | -------------------- | ---- | ------------------------------ |
| request |ResourceRequest | 是 |
请求豁免应用信息数据结构,具体结构见文末请求体
|
| request |ResourceRequest | 是 |
[
ResourceRequest
](
#ResourceRequest
)
|
**错误码**
:
**错误码**
:
以下错误码的详细介绍请参见
[
@ohos.resourceschedule.backgroundTaskManager (后台任务管理)
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
错误码
。
以下错误码的详细介绍请参见
[
后台任务错误码
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
。
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| ---- | --------------------- |
| ---- | --------------------- |
| 201 | Permission denied. |
| 202 | Not System App. |
| 401 | Parameter error. |
| 9800001 | Memory operation failed. |
| 9800001 | Memory operation failed. |
| 9800002 | Parcel operation failed. |
| 9800002 | Parcel operation failed. |
| 9800003 | IPC failed. |
| 9800003 | IPC failed. |
...
@@ -174,37 +180,39 @@ function releaseExemptionResource(request: ResourceRequest): void;
...
@@ -174,37 +180,39 @@ function releaseExemptionResource(request: ResourceRequest): void;
## 枚举类和请求体
## 枚举类和请求体
### ResourceType
### ResourceType
The resource type of exemption application.
豁免应用资源枚举
<br>
<br>
|名称 |
枚举
值 |说明|
|名称 |值 |说明|
| ------------ | ------------ |--------------|
| ------------ | ------------ |--------------|
|NETWORK |1 |
The resource for non-standby network access.
|
|NETWORK |1 |
非待机网络访问资源
|
|RUNNING_LOCK |
1 << 1 |The resource for non-standby cpu-runninglock.
|
|RUNNING_LOCK |
2 |非待机cpu-runninglock资源
|
|TIMER |
1 << 2 |The resource for non-standby timer.
|
|TIMER |
4 | 非待机timer任务资源
|
|WORK_SCHEDULER |
1 << 3 |The resource for non-standby workscheduler.
|
|WORK_SCHEDULER |
8 | 非待机work任务资源
|
|AUTO_SYNC |1
<< 4 |The resource for non-standby Automatic synchronization.
|
|AUTO_SYNC |1
6 | 非待机自动同步的资源
|
|PUSH |
1 << 5 |The resource for non-standby pushkit.
|
|PUSH |
32 | 非待机pushkit资源
|
|FREEZE |
1 << 6 |The resource for non-standby freezing application.
|
|FREEZE |
64 | 非待机冻结应用资源
|
### ExemptedAppInfo
### ExemptedAppInfo
The information of exemption application.
豁免应用信息
..
<br>
<br>
|
对象名
|类型 |说明 |
|
名称
|类型 |说明 |
| ------------ | ------------ | ------------ |
| ------------ | ------------ | ------------ |
|resourceTypes | number |
The set of resource types that app wants to apply.
|
|resourceTypes | number |
应用的资源类型
|
|name |string |
The app name.
|
|name |string |
应用名
|
|duration | number |
The exemption duration.
|
|duration | number |
豁免时长
|
### ResourceRequest
### ResourceRequest
The request of standby resources.
待机资源请求体
<br>
<br>
|
对象名
|类型 |说明 |
|
名称
|类型 |说明 |
| ------------ | ------------ | ------------ |
| ------------ | ------------ | ------------ |
|resourceTypes | number |The set of resource types that app wants to apply. |
|resourceTypes | number |应用的资源类型 |
|uid | number |The app uid. |
|uid | number |应用uid |
|name |string | The app name. |
|name |string | 应用名称 |
|duration | number | The exemption duration. |
|duration | number | 豁免时长 |
|reason |string | The apply reason. |
|reason |string | 申请原因 |
\ No newline at end of file
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录