提交 2a6a7f15 编写于 作者: G geraltxu

文档修改

Signed-off-by: Nxufanghan <xufanghan@huawei.com>
上级 4b897008
# 设备待机续航部件开发指南 # 设备待机模块开发指南
## 场景介绍 ## 设备待机模块概述
当前设备在灭屏进入待机睡眠前,应用不会被冻结、Work任务不会被延迟、Timer时间不会变慢、CPU锁不会释放、应用网络访问不会停止,导致设备灭屏功耗大,影响整机续航。 为提高设备续航,降低设备功耗,在设备进入待机空闲状态时,限制后台应用使用资源。开发者可以根据自身情况,为自己的应用申请纳入待机资源管控或者暂时不被待机资源管控。
因此,在进入待机空闲状态下,需要限制后台应用使用资源,降低整机功耗。<br>
解决以下场景<br>
一、采集系统设备进入待机空闲特征,进入待机时机,退出待机条件<br>
二、检测设备进入浅睡眠状态和深睡眠状态<br>
三、设备每隔一段时间暂停睡眠,进入维护状态<br>
四、检测到设备进入待机空闲状态,触发资源管控
本文档旨在帮助开发者理解设备待机空闲下的相关功能和资源使用规范。
## 待机低续航模式介绍 ## 待机低续航模式介绍
待机低续航模式会延迟应用后台cpu和网络活动,从而延长电池续航时间。 待机低续航模式会延迟应用后台cpu和网络活动,从而延长电池续航时间。
<br>包括: <br>包括:
...@@ -17,9 +10,12 @@ ...@@ -17,9 +10,12 @@
<br>3.running_lock锁:释放应用申请的cpu running_lock锁 <br>3.running_lock锁:释放应用申请的cpu running_lock锁
<br>4.Timer响应:延迟应用的timer响应 <br>4.Timer响应:延迟应用的timer响应
## 接口说明 ## 接口说明
一、应用查询待机空闲状态接口<br> [设备待机模块接口api开发文档](https://gitee.com/openharmony/docs/blob/4b89700885537543d26e2dfc96b4dee15a544229/zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md)
isDeviceInStandby
二、应用申请待机空闲状态正常使用资源的接口<br> 主要接口
getExemptedApps | 接口 | 说明 |
requestExemptionResource |--------------------------|----|
releaseExemptionResource | isDeviceInStandby | 查询应用是否处于待机空闲状态,如果处于空闲状态,该应用可能被纳入资源管控。 |
| getExemptedApps | 获取不会被纳入待机资源管控的应用列表 |
| requestExemptionResource | 为应用申请暂时不会被纳入待机资源管控的能力 |
| releaseExemptionResource | 取消应用暂时不会被纳入待机资源管控能力 |
\ No newline at end of file
# @ohos.resourceschedule.deviceStandby(设备待机模块) # @ohos.resourceschedule.deviceStandby(设备待机模块)
本模块提供设备待机空闲部件管理功能 本模块提供设备待机空闲部件管理功能。当设备长时间未被使用或通过按键,可以使设备进入待机模式。待机模式不影响应用使用,还可以延长电池续航时间。通过本模块接口,可查询设备是否为待机模式,以及使应用灵活申请开启或关闭待机模式。
API使用场景:
当设备长时间未被使用或通过按键,可以使设备进入待机模式。待机模式不影响应用使用,还可以延长电池续航时间。
通过本模块接口,可查询设备是否为待机模式,以及使应用灵活申请开启或关闭待机模式。
> **说明:** > **说明:**
> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...@@ -26,6 +22,7 @@ isDeviceInStandby(callback: AsyncCallback<boolean>): void; ...@@ -26,6 +22,7 @@ isDeviceInStandby(callback: AsyncCallback<boolean>): void;
| callback | Callback&lt;boolean&gt; | 是 | 延迟即将超时的回调函数,一般在超时前6秒通过此回调通知应用。 | | callback | Callback&lt;boolean&gt; | 是 | 延迟即将超时的回调函数,一般在超时前6秒通过此回调通知应用。 |
**错误码** **错误码**
以下错误码的详细介绍请参见[后台任务错误码](../errorcodes/errorcode-backgroundTaskMgr.md) 以下错误码的详细介绍请参见[后台任务错误码](../errorcodes/errorcode-backgroundTaskMgr.md)
| 错误码ID | 错误信息 | | 错误码ID | 错误信息 |
...@@ -73,8 +70,8 @@ getExemptedApps(resourceTypes: number, callback: AsyncCallback<Array&lt;Exempted ...@@ -73,8 +70,8 @@ getExemptedApps(resourceTypes: number, callback: AsyncCallback<Array&lt;Exempted
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------ | | -------- | -------------------- | ---- | ------------------------------ |
| resourceTypes |number | 是 | [ResourceType](#resourcetype) | | [ResourceType](#resourcetype)|number | 是 | 资源类型 |
| callback | AsyncCallback<Array&lt;ExemptedAppInfo&gt;> | 是 | [ExemptedAppInfo ](#exemptedappinfo)| | callback | AsyncCallback<Array&lt;[ExemptedAppInfo](#exemptedappinfo)&gt;> | 是 |豁免应用信息 |
**错误码** **错误码**
...@@ -101,13 +98,13 @@ getExemptedApps(resourceTypes: number): Promise<Array&lt;ExemptedAppInfo&gt;>; ...@@ -101,13 +98,13 @@ getExemptedApps(resourceTypes: number): Promise<Array&lt;ExemptedAppInfo&gt;>;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------ | | -------- | -------------------- | ---- | ------------------------------ |
| resourceTypes |number | 是 | [ResourceType](#resourcetype) | | [ResourceType](#resourcetype)|number | 是 |资源类型|
**返回值** **返回值**
| 类型 | 说明 | | 类型 | 说明 |
| --------------------- | ---------------------------------------- | | --------------------- | ---------------------------------------- |
| Promise<Array&lt;ExemptedAppInfo&gt;> | [ExemptedAppInfo ](#exemptedappinfo)| | Promise<Array&lt;[ExemptedAppInfo](#exemptedappinfo)&gt;> | 豁免应用信息 |
**错误码** **错误码**
...@@ -127,7 +124,7 @@ getExemptedApps(resourceTypes: number): Promise<Array&lt;ExemptedAppInfo&gt;>; ...@@ -127,7 +124,7 @@ getExemptedApps(resourceTypes: number): Promise<Array&lt;ExemptedAppInfo&gt;>;
## deviceStandby.requestExemptionResource ## deviceStandby.requestExemptionResource
requestExemptionResource(request: ResourceRequest): void; requestExemptionResource(request: ResourceRequest): void;
订阅申请豁免。 订阅申请豁免,为应用申请临时不进入待机管控能力
**系统能力:** SystemCapability.ResourceSchedule.DeviceStandby.Exemption **系统能力:** SystemCapability.ResourceSchedule.DeviceStandby.Exemption
...@@ -137,7 +134,7 @@ requestExemptionResource(request: ResourceRequest): void; ...@@ -137,7 +134,7 @@ requestExemptionResource(request: ResourceRequest): void;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------ | | -------- | -------------------- | ---- | ------------------------------ |
| request |ResourceRequest | 是 | [ResourceRequest ](#resourcerequest) | | request |[ResourceRequest](#resourcerequest)| 是 | 资源请求 |
**错误码** **错误码**
...@@ -154,7 +151,7 @@ requestExemptionResource(request: ResourceRequest): void; ...@@ -154,7 +151,7 @@ requestExemptionResource(request: ResourceRequest): void;
## deviceStandby.releaseExemptionResource ## deviceStandby.releaseExemptionResource
releaseExemptionResource(request: ResourceRequest): void; releaseExemptionResource(request: ResourceRequest): void;
去除订阅申请豁免。 去除订阅申请豁免,去除应用暂时不进入待机管控的能力
**系统能力:** SystemCapability.ResourceSchedule.DeviceStandby.Exemption **系统能力:** SystemCapability.ResourceSchedule.DeviceStandby.Exemption
...@@ -164,7 +161,7 @@ releaseExemptionResource(request: ResourceRequest): void; ...@@ -164,7 +161,7 @@ releaseExemptionResource(request: ResourceRequest): void;
| 参数名 | 类型 | 必填 | 说明 | | 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------ | | -------- | -------------------- | ---- | ------------------------------ |
| request |ResourceRequest | 是 | [ResourceRequest ](#resourcerequest) | | request |[ResourceRequest](#resourcerequest)| 是 | 资源请求 |
**错误码** **错误码**
...@@ -178,9 +175,8 @@ releaseExemptionResource(request: ResourceRequest): void; ...@@ -178,9 +175,8 @@ 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. |
## 枚举类和请求体 ## ResourceType
### ResourceType 应用资源枚举。
豁免应用资源枚举
<br> <br>
|名称 |值 |说明| |名称 |值 |说明|
...@@ -193,10 +189,8 @@ releaseExemptionResource(request: ResourceRequest): void; ...@@ -193,10 +189,8 @@ releaseExemptionResource(request: ResourceRequest): void;
|PUSH |32 | 非待机pushkit资源| |PUSH |32 | 非待机pushkit资源|
|FREEZE |64 | 非待机冻结应用资源| |FREEZE |64 | 非待机冻结应用资源|
### ExemptedAppInfo ## ExemptedAppInfo
豁免应用信息 豁免应用信息,不进入待机管控的应用信息。
..
<br> <br>
|名称 |类型 |说明 | |名称 |类型 |说明 |
...@@ -205,8 +199,8 @@ releaseExemptionResource(request: ResourceRequest): void; ...@@ -205,8 +199,8 @@ releaseExemptionResource(request: ResourceRequest): void;
|name |string | 应用名 | |name |string | 应用名 |
|duration | number | 豁免时长 | |duration | number | 豁免时长 |
### ResourceRequest ## ResourceRequest
待机资源请求体 待机资源请求体
<br> <br>
|名称 |类型 |说明 | |名称 |类型 |说明 |
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册