doze mode

从android M (6.0)开始, Google加入了doze mode支持. 


1. doze模式几个状态

  1. ACTIVE - Device is in use, or connected to a charge source.
  2. INACTIVE - Device has recently come out of the active state (user turned off the display or unplugged it, for example)
  3. IDLE_PENDING - Hold on to your hats, we are about to enter idle mode.
  4. IDLE - Device is idle.
  5. IDLE_MAINTENANCE - Window is open for applications to do processing.

2. 实现

frameworks/base/services/core/java/com/android/server/DeviceIdleController.java
frameworks/base/services/core/java/com/android/server/SystemConfig.java


log:

D/DeviceIdleController(  941): Moved from STATE_ACTIVE to STATE_INACTIVE
D/DeviceIdleController(  941): Moved from STATE_ACTIVE to STATE_INACTIVE
D/DeviceIdleController(  941): Moved from STATE_INACTIVE to STATE_IDLE_PENDING.
D/DeviceIdleController(  941): Moved from STATE_IDLE_PENDING to STATE_SENSING.
D/DeviceIdleController(  941): Moved from STATE_SENSING to STATE_LOCATING.
D/DeviceIdleController(  941): Moved to STATE_IDLE. Next alarm in 3600000 ms.
D/DeviceIdleController(  941): updateDisplayLocked: screenOn=true
I/DeviceIdleController(  941): becomeActiveLocked, reason = screen
(I/DeviceIdleController(  941): becomeActiveLocked, reason = disabled)


3. 进入退出doze mode命令

3.1 进入doze mode

  adb shell dumpsys battery unplug

 adb shell dumpsys deviceidle step

3.2 退出doze mode

 adb shell dumpsys deviceidle disable

3.3 enable doze mode

adb shell dumpsys deviceidle enable


4. 白名单

4.1 查看白名单

 adb shell dumpsys deviceidle

adb shell dumpsys deviceidle whitelist

4.2 加入白名单

adb shell dumpsys deviceidle whitelist  +packageName

4.3 删除白名单

adb shell dumpsys deviceidle whitelist -packageName

vendor/google/etc/sysconfig/google.xml  (etc/sysconfig/google.xml)
frameworks/base/data/etc/platform.xml (etc/permissions/platform.xml)
4.4 配置白名单

 <!-- These are the standard packages that are white-listed to always have internet
       access while in power save mode, even if they aren't in the foreground. -->
 <allow-in-power-save-except-idle package="com.android.providers.downloads" />


5. deviceilde影响的service

NetworkPolicyManagerService

JobSchedulerService

SyncManager

PowerManagerService

AlarmManagerService


参考文档

https://developer.android.com/training/monitoring-device-state/doze-standby.html

https://newcircle.com/s/post/1739/2015/06/12/diving-into-android-m-doze

http://blog.sina.com.cn/s/blog_b9ead2b70102w07r.html


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值