Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
172cf0c1
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看板
提交
172cf0c1
编写于
5月 19, 2023
作者:
G
geraltxu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
设备待机续航部件开发指南修改
Signed-off-by:
N
xufanghan
<
xufanghan@huawei.com
>
上级
644b42df
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
34 addition
and
75 deletion
+34
-75
zh-cn/application-dev/device_standby/device-standby-use-guide.md
...pplication-dev/device_standby/device-standby-use-guide.md
+12
-24
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md
.../reference/apis/js-apis-resourceschedule-deviceStandby.md
+22
-51
未找到文件。
zh-cn/application-dev/device_standby/device-standby-use-guide.md
浏览文件 @
172cf0c1
# 设备待机
空闲
部件开发指南
# 设备待机
续航
部件开发指南
## 场景介绍
## 场景介绍
当前设备在
待机状态及睡眠状态,应用不会被冻结、任务不会被延迟、时钟时间不会变慢、CPU锁不会释放、网络不会停止,导致灭屏功耗大
。
当前设备在
灭屏进入待机睡眠前,应用不会被冻结、Work任务不会被延迟、Timer时间不会变慢、CPU锁不会释放、应用网络访问不会停止,导致设备灭屏功耗大,影响整机续航
。
设备灭屏/锁屏情况下,保持一段时间后进入待机空闲模式,限制后台应用使用资源,降低
功耗。
<br>
因此,在进入待机空闲状态下,需要限制后台应用使用资源,降低整机
功耗。
<br>
解决以下场景
<br>
解决以下场景
<br>
一、采集系统设备进入待机空闲特征
<br>
一、采集系统设备进入待机空闲特征
,进入待机时机,退出待机条件
<br>
二、检测设备进入浅睡眠状态和深睡眠状态
<br>
二、检测设备进入浅睡眠状态和深睡眠状态
<br>
三、设备每隔一段时间暂停睡眠,进入维护状态
<br>
三、设备每隔一段时间暂停睡眠,进入维护状态
<br>
四、检测到设备进入待机空闲状态,触发资源管控
四、检测到设备进入待机空闲状态,触发资源管控
...
@@ -12,26 +12,14 @@
...
@@ -12,26 +12,14 @@
## 待机低续航模式介绍
## 待机低续航模式介绍
待机低续航模式会延迟应用后台cpu和网络活动,从而延长电池续航时间。
待机低续航模式会延迟应用后台cpu和网络活动,从而延长电池续航时间。
<br>
包括:
<br>
包括:
<br>
1.应用限网:限制访问网络
<br>
1.应用限网:限制
应用
访问网络
<br>
2.work待机任务:延迟应用的work任务响应
<br>
2.work待机任务:延迟应用的work任务响应
<br>
3.running_lock锁:释放应用
的
锁
<br>
3.running_lock锁:释放应用
申请的cpu running_lock
锁
<br>
4.Timer响应:延迟应用的timer响应
<br>
4.Timer响应:延迟应用的timer响应
## 接口说明
## 接口说明
### 一、返回当前是否进入待机功耗续航模式
一、应用查询待机空闲状态接口
<br>
isDeviceInStandby()
isDeviceInStandby
<br>
二、应用申请待机空闲状态正常使用资源的接口
<br>
功能描述:返回当前是否进入待机低功耗续航模式。
getExemptedApps
<br>
requestExemptionResource
举例:push客户端应用获取待机状态管控消息推送缓存
releaseExemptionResource
### 二、获取豁免信息
getExemptionListApps()
<br>
功能描述:获取豁免信息
<br>
举例:push客户端应用获取push限网豁免名单
### 三、更新调用者豁免信息
applyExemptionAppResource()、unapplyExemptionAppResource()
<br>
功能描述:更新调用者豁免信息
<br>
举例:针对系统应用可以申请临时豁免,临时放行待机状态管控该应用使用资源限制
zh-cn/application-dev/reference/apis/js-apis-resourceschedule-deviceStandby.md
浏览文件 @
172cf0c1
# @ohos.resourceschedule.deviceStandby(设备待机空闲部件功能)
# @ohos.resourceschedule.deviceStandby(设备待机空闲部件功能)
本模块提供设备待机空闲部件管理功能
本模块提供设备待机空闲部件管理功能
<br>
API使用场景:
API使用场景:
<br>
如果用户长时间没有主动使用设备,且屏幕已关闭,则系统会使设备进入待机低功耗续航模式。待机续航模式会延迟应用后台CPU和网络活动,从而延长电池续航时间。 包括:
如果用户长时间没有主动使用设备,且屏幕已关闭,则系统会使设备进入待机低功耗续航模式。待机续航模式会延迟应用后台CPU和网络活动,从而延长电池续航时间。 包括:
<br>
1、应用限网:限制后台应用访问网络
1、应用限网:通过iptable防火墙限制后台应用访问网络
<br>
2、Work待机任务:延迟应用的work任务响应
2、Work待机任务:延迟应用的work任务响应
<br>
3、running_lock锁:临时释放应用的background running_lock锁
3、running_lock锁:临时释放应用的background running_lock锁
<br>
4、Timer响应:延迟应用的timer响应
4、Timer响应:延迟应用的timer响应
<br>
5、待规划:停止wifi扫描、停止蓝牙扫描、云同步账户等
5、待规划:停止wifi扫描、停止蓝牙扫描、云同步账户等
> **说明:**
> **说明:**
> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块首批接口从API version 10开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...
@@ -24,11 +16,8 @@ import deviceStandby from '@ohos.resourceschedule.deviceStandby';
...
@@ -24,11 +16,8 @@ import deviceStandby from '@ohos.resourceschedule.deviceStandby';
```
```
## deviceStandby.isDeviceInStandby
## deviceStandby.isDeviceInStandby
function isDeviceInStandby(callback: AsyncCallback
<boolean>
): void;
function isDeviceInStandby(callback: AsyncCallback
<boolean>
): void;
<br>
当前设备是否进入待机低功耗续航模式
当前设备是否进入待机低功耗续航模式
<br>
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Idle
**参数**
:
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
...
@@ -36,7 +25,6 @@ function isDeviceInStandby(callback: AsyncCallback<boolean>): void;
...
@@ -36,7 +25,6 @@ function isDeviceInStandby(callback: AsyncCallback<boolean>): void;
| callback | Callback
<
void
>
| 是 | 延迟即将超时的回调函数,一般在超时前6秒通过此回调通知应用。 |
| callback | Callback
<
void
>
| 是 | 延迟即将超时的回调函数,一般在超时前6秒通过此回调通知应用。 |
**错误码**
:
**错误码**
:
以下错误码的详细介绍请参见
[
@ohos.resourceschedule.backgroundTaskManager (后台任务管理)
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
错误码。
以下错误码的详细介绍请参见
[
@ohos.resourceschedule.backgroundTaskManager (后台任务管理)
](
../errorcodes/errorcode-backgroundTaskMgr.md
)
错误码。
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
...
@@ -45,17 +33,14 @@ function isDeviceInStandby(callback: AsyncCallback<boolean>): void;
...
@@ -45,17 +33,14 @@ function isDeviceInStandby(callback: AsyncCallback<boolean>): void;
| 401 | Parameter error. |
| 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.isDeviceInStandby
## deviceStandby.isDeviceInStandby
function isDeviceInStandby(): Promise
<
boolean
>
function isDeviceInStandby(): Promise
<
boolean
>
<br>
当前设备是否进入待机低功耗续航模式
当前设备是否进入待机低功耗续航模式
<br>
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Idle
**返回值**
:
**返回值**
:
| 类型 | 说明 |
| 类型 | 说明 |
...
@@ -71,17 +56,14 @@ function isDeviceInStandby(): Promise<boolean>
...
@@ -71,17 +56,14 @@ function isDeviceInStandby(): Promise<boolean>
| 401 | Parameter error. |
| 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.getExemptionListApps
## deviceStandby.getExemptedApps
function getExemptionListApps(resourceTypes: number, callback: AsyncCallback
<Array
&
lt
;
ExemptionAppInfo
&
gt
;
>
): void;
function getExemptedApps(resourceTypes: number, callback: AsyncCallback
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
): void;
<br>
返回豁免应用名单
返回豁免应用名单
<br>
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
<br>
**系统API:**
此接口为系统接口。
**系统API:**
此接口为系统接口。
**参数**
:
**参数**
:
...
@@ -89,7 +71,7 @@ function getExemptionListApps(resourceTypes: number, callback: AsyncCallback<Arr
...
@@ -89,7 +71,7 @@ function getExemptionListApps(resourceTypes: number, callback: AsyncCallback<Arr
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------------ |
| -------- | -------------------- | ---- | ------------------------------ |
| resourceTypes |number | 是 | 资源类型,具体结构见文末枚举 |
| resourceTypes |number | 是 | 资源类型,具体结构见文末枚举 |
| callback | AsyncCallback
<Array
&
lt
;
Exempt
ion
AppInfo
&
gt
;
>
| 是 | 回调函数,具体结构见文末 |
| callback | AsyncCallback
<Array
&
lt
;
Exempt
ed
AppInfo
&
gt
;
>
| 是 | 回调函数,具体结构见文末 |
**错误码**
:
**错误码**
:
...
@@ -102,18 +84,14 @@ function getExemptionListApps(resourceTypes: number, callback: AsyncCallback<Arr
...
@@ -102,18 +84,14 @@ function getExemptionListApps(resourceTypes: number, callback: AsyncCallback<Arr
| 401 | Parameter error. |
| 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.getExemptionListApps
## deviceStandby.getExemptedApps
function getExemptionListApps(resourceTypes: number): Promise
<Array
&
lt
;
ExemptionAppInfo
&
gt
;
>
;
function getExemptedApps(resourceTypes: number): Promise
<Array
&
lt
;
ExemptedAppInfo
&
gt
;
>
;
<br>
返回豁免应用名单
返回豁免应用名单
<br>
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
<br>
**系统API:**
此接口为系统接口。
**系统API:**
此接口为系统接口。
**参数**
:
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
...
@@ -124,7 +102,7 @@ function getExemptionListApps(resourceTypes: number): Promise<Array<Exemption
...
@@ -124,7 +102,7 @@ function getExemptionListApps(resourceTypes: number): Promise<Array<Exemption
| 类型 | 说明 |
| 类型 | 说明 |
| --------------------- | ---------------------------------------- |
| --------------------- | ---------------------------------------- |
| Promise
<Array
&
lt
;
Exempt
ion
AppInfo
&
gt
;
>
| 指定的Promise回调方法。返回豁免应用名单,具体结构见文末|
| Promise
<Array
&
lt
;
Exempt
ed
AppInfo
&
gt
;
>
| 指定的Promise回调方法。返回豁免应用名单,具体结构见文末|
**错误码**
:
**错误码**
:
...
@@ -137,19 +115,15 @@ function getExemptionListApps(resourceTypes: number): Promise<Array<Exemption
...
@@ -137,19 +115,15 @@ function getExemptionListApps(resourceTypes: number): Promise<Array<Exemption
| 401 | Parameter error. |
| 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.applyExemptionAppResource
## deviceStandby.requestExemptionResource
function applyExemptionAppResource(request: ResourceRequest): void;
function requestExemptionResource(request: ResourceRequest): void;
<br>
订阅申请豁免
订阅申请豁免
<br>
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
<br>
**系统API:**
此接口为系统接口。
**系统API:**
此接口为系统接口。
**参数**
:
**参数**
:
| 参数名 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
...
@@ -167,17 +141,14 @@ function applyExemptionAppResource(request: ResourceRequest): void;
...
@@ -167,17 +141,14 @@ function applyExemptionAppResource(request: ResourceRequest): void;
| 401 | Parameter error. |
| 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.unapplyExemptionAppResource
## deviceStandby.releaseExemptionResource
function unapplyExemptionAppResource(request: ResourceRequest): void;
function releaseExemptionResource(request: ResourceRequest): void;
<br>
去除订阅申请豁免
去除订阅申请豁免
<br>
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
**系统能力:**
SystemCapability.ResourceSchedule.DeviceStandby.Exemption
<br>
**系统API:**
此接口为系统接口。
**系统API:**
此接口为系统接口。
**参数**
:
**参数**
:
...
@@ -197,7 +168,7 @@ function unapplyExemptionAppResource(request: ResourceRequest): void;
...
@@ -197,7 +168,7 @@ function unapplyExemptionAppResource(request: ResourceRequest): void;
| 401 | Parameter error. |
| 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. |
...
@@ -216,7 +187,7 @@ The resource type of exemption application.
...
@@ -216,7 +187,7 @@ The resource type of exemption application.
|PUSH |1 << 5 |The resource for non-standby pushkit.|
|PUSH |1 << 5 |The resource for non-standby pushkit.|
|FREEZE |1 << 6 |The resource for non-standby freezing application.|
|FREEZE |1 << 6 |The resource for non-standby freezing application.|
### Exempt
ionAppInfo
### Exempt
edAppInfo
The information of exemption application.
The information of exemption application.
<br>
<br>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录