Android知识点 361 —— dumpsys power 分析屏保和STR问题

文章原文: 天下文章一大抄,具体抄的哪里找不到了。

返回知识列表:Android知识点list


dumpsys power| grep -A 5 "Wake Lock"

可以用来查看当前系统的Wake Lock, 尤其是关不了机的时候,查看。、

这个不太靠谱,还是要看底层, cat  /sys/power/wake_lock

释放锁 echo usb_adb_enable > /sys/power/wake_unlock   因为还有非 PowerManager申请的锁。例如从Android Q开始adb enable后会申请一个adb wake lock导致无法待机。

#dumpsys power
POWER MANAGER (dumpsys power)

Power Manager State:
  Settings power_manager_constants:
    no_cached_wake_locks=true
  mDirty=0x0                   ##                 
  mWakefulness=Dozing          ## 这个值可以是Awake,Dreaming. 
## 变化的顺序一定是从Awake ->Dozing -> Dreaming 。这个是记录状态变化的结果了。
## 我一般是用这个值来判断开关机问题。首先确定设备的状态。
  mWakefulnessChanging=false
  mIsPowered=true
  mPlugType=2
  mBatteryLevel=71
  mBatteryLevelWhenDreamStarted=71
  mDockState=0
  mStayOn=false                ## 要想无操作进入屏保,这个值必须是false 

  mProximityPositive=false     ## 距离传感器,同样的如果需要进入屏保,这个值也必须是false 

  mBootCompleted=true          ## 说明是开机了?好像一直是true 

  mSystemReady=true            ## 这个值也是一直是 true

  mHalAutoSuspendModeEnabled=true
  mHalInteractiveModeEnabled=true
  mWakeLockSummary=0x40        ## 关键信息,是否有锁,没有锁的话这个值是0
  mNotifyLongScheduled=+8s880ms
  mNotifyLongDispatched=-51s43ms
  mNotifyLongNextCheck=+8s880ms
  mUserActivitySummary=0x1     ## 这个看代码可知,1表示USER_ACTIVITY_SCREEN_BRIGHT,
     ## 2 表示 USER_ACTIVITY_SCREEN_DIM
     ## 3 表示 USER_ACTIVITY_SCREEN_DREAM
     ## 而这只表示Activity的状态,举例说5分钟无按键操作进入屏保,现在的确是无操作了,
     ## 也过了5 分钟了,则这个状态就会变成 USER_ACTIVITY_SCREEN_DREAM 。
     ## 但是,这仅仅是Activity的判断可以进入Dreaming了,还需要看其他的标志位。例如,mWakeLockSummary,mStayOn等等的值,
     ##具体参考isBeingKeptAwakeLocked()函数。
  mRequestWaitForNegativeProximity=false
  mSandmanScheduled=false
  mSandmanSummoned=false
  mBatteryLevelLow=false
  mLightDeviceIdleMode=false
  mDeviceIdleMode=false
  mDeviceIdleWhitelist=[1001, 2000, 9802, 10008, 10015, 10023, 10038, 10044, 10045, 10060, 10065, 10073, 10079, 10080, 1
0086, 10089, 10093, 10101, 10109, 10112, 10115, 10128, 10141, 10149, 10160]
  mDeviceIdleTempWhitelist=[]
  mLastWakeTime=3249188 (14364 ms ago) 
  mLastSleepTime=3259470 (4082 ms ago)
  mLastUserActivityTime=3249467 (14085 ms ago)
  mLastUserActivityTimeNoChangeLights=840153 (2423399 ms ago)
  mLastInteractivePowerHintTime=3249467 (14085 ms ago)
  mLastScreenBrightnessBoostTime=0 (3263553 ms ago)
  mScreenBrightnessBoostInProgress=false
  mDisplayReady=true
  mHoldingWakeLockSuspendBlocker=false
  mHoldingDisplaySuspendBlocker=false

Settings and Configuration:         ## UI 设置菜单里的配置
  mDecoupleHalAutoSuspendModeFromDisplayConfig=true
  mDecoupleHalInteractiveModeFromDisplayConfig=false
  mWakeUpWhenPluggedOrUnpluggedConfig=true
  mWakeUpWhenPluggedOrUnpluggedInTheaterModeConfig=false
  mTheaterModeEnabled=false
  mSuspendWhenScreenOffDueToProximityConfig=false
  mDreamsSupportedConfig=true
  mDreamsEnabledByDefaultConfig=true
  mDreamsActivatedOnSleepByDefaultConfig=false
  mDreamsActivatedOnDockByDefaultConfig=true
  mDreamsEnabledOnBatteryConfig=false
  mDreamsBatteryLevelMinimumWhenPoweredConfig=-1
  mDreamsBatteryLevelMinimumWhenNotPoweredConfig=15
  mDreamsBatteryLevelDrainCutoffConfig=5
  mDreamsEnabledSetting=true                          ## 是否打开了屏保功能,ture 是打开
  mDreamsActivateOnSleepSetting=false ##这个值需要是true,否则dream时间到了,待机了。是一个问题!!
  mDreamsActivateOnDockSetting=true
  mDozeAfterScreenOff=true
  mMinimumScreenOffTimeoutConfig=10000
  mMaximumScreenDimDurationConfig=18000
  mMaximumScreenDimRatioConfig=0.29999995
  mScreenOffTimeoutSetting=600000
  mSleepTimeoutSetting=-1                         ## 多长时间无操作待机
  mMaximumScreenOffTimeoutFromDeviceAdmin=9223372036854775807 (enforced=false)
                            ## 9223372036854775807 是默认值 LONG.MAX_VALUE
  mStayOnWhilePluggedInSetting=0   ## 电源类型,BATTERY_PLUGGED_AC = 1
                                   ## BATTERY_PLUGGED_USB = 2
                                   ## BATTERY_PLUGGED_WIRELESS = 4
                                   ## 这个值可以逻辑运算,BATTERY_PLUGGED_ANY = 1 | 2 | 4 = 7
                                   ## 这个值 = 0,就比较有意思了,那么mStayOn always = false. 上面提到过,只有mStayOn=false才能进入屏保。
  mScreenBrightnessSetting=0
  mScreenBrightnessModeSetting=1
  mScreenBrightnessOverrideFromWindowManager=-1
  mUserActivityTimeoutOverrideFromWindowManager=-1
  mUserInactiveOverrideFromWindowManager=false
  mDozeScreenStateOverrideFromDreamManager=4
  mDrawWakeLockOverrideFromSidekick=false
  mDozeScreenBrightnessOverrideFromDreamManager=-1
  mScreenBrightnessSettingMinimum=3
  mScreenBrightnessSettingMaximum=1023
  mScreenBrightnessSettingDefault=268
  mDoubleTapWakeEnabled=false
  mIsVrModeEnabled=false
  mForegroundProfile=0

Sleep timeout: -1 ms
Screen off timeout: 600000 ms
Screen dim duration: 18000 ms

UID states (changing=false changed=false):
  UID 1000:   ACTIVE  count=1 state=0
  UID 1001:   ACTIVE  count=0 state=0
  UID 1002:   ACTIVE  count=0 state=0
  UID 1027:   ACTIVE  count=0 state=0
  UID 1068:   ACTIVE  count=0 state=0
  UID 9802: INACTIVE  count=0 state=18
  UID 9810:   ACTIVE  count=0 state=0
  UID u0a8: INACTIVE  count=0 state=9
  UID u0a19:   ACTIVE  count=0 state=0
  UID u0a23: INACTIVE  count=0 state=13
  UID u0a24: INACTIVE  count=0 state=11
  UID u0a33:   ACTIVE  count=0 state=4
  UID u0a40: INACTIVE  count=0 state=18
  UID u0a45: INACTIVE  count=0 state=7
  UID u0a48: INACTIVE  count=0 state=18
  UID u0a58: INACTIVE  count=0 state=18
  UID u0a59: INACTIVE  count=0 state=15
  UID u0a60:   ACTIVE  count=0 state=3
  UID u0a69:   ACTIVE  count=0 state=5
  UID u0a70: INACTIVE  count=0 state=18
  UID u0a73: INACTIVE  count=0 state=7
  UID u0a79: INACTIVE  count=0 state=9
  UID u0a80:   ACTIVE  count=0 state=0
  UID u0a87: INACTIVE  count=0 state=19
  UID u0a96:   ACTIVE  count=0 state=5
  UID u0a97:   ACTIVE  count=0 state=0
  UID u0a101: INACTIVE  count=0 state=18
  UID u0a107: INACTIVE  count=0 state=19
  UID u0a108: INACTIVE  count=0 state=18
  UID u0a112:   ACTIVE  count=0 state=3
  UID u0a115: INACTIVE  count=0 state=18
  UID u0a121: INACTIVE  count=0 state=19
  UID u0a122: INACTIVE  count=0 state=19
  UID u0a123: INACTIVE  count=0 state=19
  UID u0a124: INACTIVE  count=0 state=19
  UID u0a127: INACTIVE  count=0 state=19
  UID u0a129: INACTIVE  count=0 state=19
  UID u0a130: INACTIVE  count=0 state=19
  UID u0a133: INACTIVE  count=0 state=19
  UID u0a134: INACTIVE  count=0 state=19
  UID u0a135: INACTIVE  count=0 state=19
  UID u0a136: INACTIVE  count=0 state=19
  UID u0a139: INACTIVE  count=0 state=19
  UID u0a141: INACTIVE  count=0 state=9
  UID u0a142: INACTIVE  count=0 state=19
  UID u0a145: INACTIVE  count=0 state=9
  UID u0a146: INACTIVE  count=0 state=19
  UID u0a147:   ACTIVE  count=0 state=4
  UID u0a148: INACTIVE  count=0 state=19
  UID u0a151: INACTIVE  count=0 state=19
  UID u0a152: INACTIVE  count=0 state=19
  UID u0a153: INACTIVE  count=0 state=19
  UID u0a154: INACTIVE  count=0 state=9
  UID u0a158: INACTIVE  count=0 state=19
  UID u0a159: INACTIVE  count=0 state=19
  UID u0a160: INACTIVE  count=0 state=18
  UID u0a163: INACTIVE  count=0 state=19
  UID u0a165: INACTIVE  count=0 state=19
  UID u0a167: INACTIVE  count=0 state=19
  UID u0a168: INACTIVE  count=0 state=19
  UID u0a169: INACTIVE  count=0 state=19
  UID u0a171: INACTIVE  count=0 state=19
  UID u0a172: INACTIVE  count=0 state=19
  UID u0a173: INACTIVE  count=0 state=19
  UID u0a174: INACTIVE  count=0 state=19
  UID u0a175: INACTIVE  count=0 state=19
  UID u0a176: INACTIVE  count=0 state=19

Looper state:
  Looper (PowerManagerService, tid 32) {ab50d87}
Dump time: 2019-03-28 19:44:15.573 GMT+08:00
Package: system_server
Version code: 28
Version name: 9
Current loop: Looper (PowerManagerService, tid 32) {ab50d87}


Wake Locks: size=1    ## 这个最关键了,进入屏保的话会申请 SCREEN_BRIGHT_WAKE_LOCK
                      ## 调查STR关机失败的话,很有可能是因为应用申请了 PARTIAL_WAKE_LOCK
                      ## 当然了,如果没有申请锁,size=0 就会正常关机了
  DOZE_WAKE_LOCK                 'DreamManagerService' ACQ=-3s157ms (uid=1000 pid=1349)

Suspend Blockers: size=4
  PowerManagerService.WakeLocks: ref count=0
  PowerManagerService.Display: ref count=0
  PowerManagerService.Broadcasts: ref count=0
  PowerManagerService.WirelessChargerDetector: ref count=0

Display Power: state=DOZE_SUSPEND

Battery saving stats:
  Battery Saver is currently: OFF
    Last OFF time: 2019-03-28 16:05:53.391 -3h38m22s183ms
    Times enabled: 0

  Drain stats:
                     Battery saver OFF                          ON
  NonDoze NonIntr:     14m     59mAh(  1%)    243.1mAh/h          0m      0mAh(  0%)      0.0mAh/h
             Intr:     22m    109mAh(  2%)    286.8mAh/h          0m      0mAh(  0%)      0.0mAh/h
  Deep    NonIntr:     85m    108mAh(  2%)     76.6mAh/h          0m      0mAh(  0%)      0.0mAh/h
             Intr:      0m      0mAh(  0%)      0.0mAh/h          0m      0mAh(  0%)      0.0mAh/h
  Light   NonIntr:     92m     31mAh(  1%)     20.7mAh/h          0m      0mAh(  0%)      0.0mAh/h
             Intr:      0m      0mAh(  0%)      0.0mAh/h          0m      0mAh(  0%)      0.0mAh/h

Battery saver policy (*NOTE* they only apply when battery saver is ON):
  Settings: battery_saver_constants
    value: null
  Settings: (overlay)
    value:

  mAccessibilityEnabled=false
  vibration_disabled:config=true
  vibration_disabled:effective=true
  animation_disabled=false
  fullbackup_deferred=true
  keyvaluebackup_deferred=true
  firewall_disabled=false
  datasaver_disabled=true
  launch_boost_disabled=true
  adjust_brightness_disabled=true
  adjust_brightness_factor=0.5
  gps_mode=2
  force_all_apps_standby=true
  force_background_check=true
  optional_sensors_disabled=true
  aod_disabled=true
  send_tron_log=false

  Interactive File values:

  Noninteractive File values:

Battery saver state machine:
  Enabled=false
  mLastChangedIntReason=0
  mLastChangedStrReason=null
  mBootCompleted=true
  mSettingsLoaded=true
  mBatteryStatusSet=true
  mBatterySaverSnoozing=false
  mIsPowered=true
  mBatteryLevel=71
  mIsBatteryLevelLow=false
  mSettingBatterySaverEnabled=false
  mSettingBatterySaverEnabledSticky=false
  mSettingBatterySaverTriggerThreshold=0

Profile power states: size=0

Wireless Charger Detector State:
  mGravitySensor={Sensor name="gravity  Non-wakeup", vendor="qualcomm", version=1, type=9, maxRange=156.99008, resolutio
n=0.1, power=0.515, minDelay=5000}
  mPoweredWirelessly=false
  mAtRest=false
  mRestX=0.0, mRestY=0.0, mRestZ=0.0
  mDetectionInProgress=false
  mDetectionStartTime=0 (never)
  mMustUpdateRestPosition=false
  mTotalSamples=0
  mMovingSamples=0
  mFirstSampleX=0.0, mFirstSampleY=0.0, mFirstSampleZ=0.0
  mLastSampleX=0.0, mLastSampleY=0.0, mLastSampleZ=0.0

 

cat  /sys/power/wake_lock   查看锁

echo   *************   /sys/power/wake_unlock  释放某一个锁。

 

 

 

 

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值