Some notes from poking around in adb shell
:
CD-18781Y:/ $ cat /sys/power/wake_lock
PowerManagerService.Display PowerManagerService.WakeLocks
CD-18781Y:/ $ echo "PowerManagerService.Display" > /sys/power/wake_unlock
CD-18781Y:/ $ echo "PowerManagerService.WakeLocks" > /sys/power/wake_unlock
# Device still won't time out to go to sleep.
CD-18781Y:/ $ echo "mem" > /sys/power/state
# Device successfully sleeps and can be woken.
CD-18781Y:/ $ dumpsys deviceidle force-idle deep
Unable to go deep idle; not enabled
CD-18781Y:/ $ dumpsys deviceidle force-idle light
Unable to go light idle; stopped at ACTIVE
CD-18781Y:/ $ dumpsys deviceidle force-inactive
Light state: ACTIVE, deep state: ACTIVE
# Device still won't time out to go to sleep
CD-18781Y:/ $ dumpsys deviceidle enabled light
0
CD-18781Y:/ $ dumpsys deviceidle enabled deep
0
CD-18781Y:/ $ dumpsys deviceidle enable light
Light idle mode enable
CD-18781Y:/ $ dumpsys deviceidle enabled light
1
CD-18781Y:/ $ dumpsys deviceidle enable deep
Deep idle mode enabled
CD-18781Y:/ # dumpsys deviceidle enabled deep
1
# Screen still won't time out to go to sleep.
CD-18781Y:/ $ echo "mem" > /sys/power/state
# Device still won't time out to go to sleep.
I’m not an android developer; I have no idea what these values normally look like (are those normal wakelocks?) apart from what’s in the AOSP doco. But it’s interesting that
- idle mode doesn’t make a difference to sleep.
- removing wakelocks doesn’t make a difference.
- sometimes I can trigger sleep with
/sys/power/state
(which is how AOSP doco says Android does it), but sometimes ZE GOGGLES, ZEY DO NAHSING.
Here’s what dmesg
has to say on that failed echo "mem" > /sys/power/state
call:
[42841.916164] PM: suspend entry 2024-01-29 10:03:57.976069816 UTC
[42841.916196] PM: Syncing filesystems ... done.
[42841.972494] ueventd: firmware: loading 'a506_zap.mdt' for '/devices/virtual/firmware/a506_zap.mdt'
[42841.977606] ueventd: loading /devices/virtual/firmware/a506_zap.mdt took 5ms
[42841.982049] ueventd: firmware: loading 'venus.mdt' for '/devices/virtual/firmware/venus.mdt'
[42841.984421] ueventd: loading /devices/virtual/firmware/venus.mdt took 3ms
[42841.989349] ueventd: firmware: loading 'bdwlan30.bin' for '/devices/virtual/firmware/bdwlan30.bin'
[42841.994355] ueventd: loading /devices/virtual/firmware/bdwlan30.bin took 5ms
[42842.002325] ueventd: firmware: loading 'qwlan30.bin' for '/devices/virtual/firmware/qwlan30.bin'
[42842.007823] ueventd: firmware: loading 'wlan/qca_cld/WCNSS_qcom_cfg.ini' for '/devices/virtual/firmware/wlan!qca_cld!WCNSS_qcom_cfg.ini'
[42842.012231] ueventd: loading /devices/virtual/firmware/wlan!qca_cld!WCNSS_qcom_cfg.ini took 5ms
[42842.015741] ueventd: firmware: loading 'adsp.mdt' for '/devices/virtual/firmware/adsp.mdt'
[42842.019983] ueventd: loading /devices/virtual/firmware/adsp.mdt took 4ms
[42842.023935] ueventd: firmware: loading 'otp30.bin' for '/devices/virtual/firmware/otp30.bin'
[42842.027312] ueventd: firmware: loading 'modem.mdt' for '/devices/virtual/firmware/modem.mdt'
[42842.028027] ueventd: loading /devices/virtual/firmware/otp30.bin took 4ms
[42842.032545] ueventd: loading /devices/virtual/firmware/modem.mdt took 6ms
[42842.036236] ueventd: loading /devices/virtual/firmware/qwlan30.bin took 34ms
[42842.037703] Freezing user space processes ... (elapsed 0.009 seconds) done.
[42842.047380] Freezing remaining freezable tasks ... (elapsed 0.004 seconds) done.
[42842.052316] Suspending console(s) (use no_console_suspend to debug)
[42842.072390] HIFsuspendwow TODO
[42842.079754] msm-dwc3 7000000.ssusb: Abort PM suspend!! (USB is outside LPM)
[42842.079778] dpm_run_callback(): platform_pm_suspend+0x0/0x58 returns -16
[42842.079787] PM: Device 7000000.ssusb failed to suspend: error -16
[42842.079795] PM: Some devices failed to suspend, or early wake event detected
[42842.086078] R0: [irq/62-mmc1][11:03:58.146000] wlan: [0:F :WDA] WOW wakeup host event received (reason: UNSPECIFIED(-1)) for vdev 0
[42842.090539] PM: resume of devices complete after 10.727 msecs
[42842.096747] Restarting tasks ... done.
[42842.106813] Abort: Some devices failed to suspend, or early wake event detected
[42842.106942] PM: suspend exit 2024-01-29 10:03:58.166868670 UTC
I read that dmesg output to mean that my USB ADB connection is what’s blocking suspend. But why did it work the first time??? No idea and it drives me nuts
I restarted the device and plugged into USB, and it went to sleep just fine. The same two services are present in wake_lock, even while it’s sleeping.
Oh, and input keyevent KEYCODE_POWER
works fine to turn off the screen. It’s just the timeout that sucks.
also while the screen is off:
CD-18781Y:/ $ dumpsys power |grep Wake
mWakefulness=Awake
Which tells me it’s not actually sleeping, just screen off, and I’ve been barking up the wrong tree.
So FWIW:
CD-18781Y:/ # dumpsys power
POWER MANAGER (dumpsys power)
Power Manager State:
Settings power_manager_constants:
no_cached_wake_locks=true
mDirty=0x0
mWakefulness=Awake
mWakefulnessChanging=false
mIsPowered=true
mPlugType=2
mBatteryLevel=50
mBatteryLevelWhenDreamStarted=0
mDockState=0
mStayOn=false
mProximityPositive=false
mBootCompleted=true
mSystemReady=true
mHalAutoSuspendModeEnabled=false
mHalInteractiveModeEnabled=true
mWakeLockSummary=0x1
mNotifyLongScheduled=+5s905ms
mNotifyLongDispatched=-1m12s53ms
mNotifyLongNextCheck=(none)
mUserActivitySummary=0x1
mRequestWaitForNegativeProximity=false
mSandmanScheduled=false
mSandmanSummoned=false
mLowPowerModeEnabled=false
mBatteryLevelLow=false
mLightDeviceIdleMode=false
mDeviceIdleMode=false
mDeviceIdleWhitelist=[1000, 1001, 2000, 10008, 10009, 10062]
mDeviceIdleTempWhitelist=[]
mLastWakeTime=282193 (85923 ms ago)
mLastSleepTime=358603 (9513 ms ago)
mLastUserActivityTime=368051 (65 ms ago)
mLastUserActivityTimeNoChangeLights=33238 (334878 ms ago)
mLastInteractivePowerHintTime=368051 (65 ms ago)
mLastScreenBrightnessBoostTime=0 (368116 ms ago)
mScreenBrightnessBoostInProgress=false
mDisplayReady=true
mHoldingWakeLockSuspendBlocker=true
mHoldingDisplaySuspendBlocker=true
Settings and Configuration:
mDecoupleHalAutoSuspendModeFromDisplayConfig=false
mDecoupleHalInteractiveModeFromDisplayConfig=false
mWakeUpWhenPluggedOrUnpluggedConfig=true
mWakeUpWhenPluggedOrUnpluggedInTheaterModeConfig=false
mTheaterModeEnabled=false
mSuspendWhenScreenOffDueToProximityConfig=true
mDreamsSupportedConfig=true
mDreamsEnabledByDefaultConfig=true
mDreamsActivatedOnSleepByDefaultConfig=false
mDreamsActivatedOnDockByDefaultConfig=false
mDreamsEnabledOnBatteryConfig=true
mDreamsBatteryLevelMinimumWhenPoweredConfig=-1
mDreamsBatteryLevelMinimumWhenNotPoweredConfig=15
mDreamsBatteryLevelDrainCutoffConfig=5
mDreamsEnabledSetting=false
mDreamsActivateOnSleepSetting=true
mDreamsActivateOnDockSetting=true
mDozeAfterScreenOffConfig=true
mLowPowerModeSetting=false
mAutoLowPowerModeConfigured=false
mAutoLowPowerModeSnoozing=false
mMinimumScreenOffTimeoutConfig=10000
mMaximumScreenDimDurationConfig=7000
mMaximumScreenDimRatioConfig=0.20000005
mScreenOffTimeoutSetting=15000
mSleepTimeoutSetting=-1
mMaximumScreenOffTimeoutFromDeviceAdmin=2147483647 (enforced=false)
mStayOnWhilePluggedInSetting=0
mScreenBrightnessSetting=102
mScreenAutoBrightnessAdjustmentSetting=0.64746094
mScreenBrightnessModeSetting=0
mScreenBrightnessOverrideFromWindowManager=-1
mUserActivityTimeoutOverrideFromWindowManager=-1
mUserInactiveOverrideFromWindowManager=false
mTemporaryScreenBrightnessSettingOverride=-1
mTemporaryScreenAutoBrightnessAdjustmentSettingOverride=NaN
mDozeScreenStateOverrideFromDreamManager=0
mDozeScreenBrightnessOverrideFromDreamManager=-1
mScreenBrightnessSettingMinimum=10
mScreenBrightnessSettingMaximum=255
mScreenBrightnessSettingDefault=102
mScreenBrightnessForVrSettingDefault=86
mScreenBrightnessForVrSetting=86
mDoubleTapWakeEnabled=false
mIsVrModeEnabled=false
Sleep timeout: -1 ms
Screen off timeout: 15000 ms
Screen dim duration: 5000 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=6
UID 1037: INACTIVE count=0 state=17
UID u0a3: INACTIVE count=0 state=17
UID u0a9: INACTIVE count=0 state=17
UID u0a10: INACTIVE count=0 state=17
UID u0a14: INACTIVE count=0 state=13
UID u0a24: ACTIVE count=0 state=0
UID u0a36: INACTIVE count=0 state=17
UID u0a43: ACTIVE count=0 state=7
UID u0a44: INACTIVE count=0 state=17
UID u0a49: INACTIVE count=0 state=17
UID u0a53: ACTIVE count=0 state=6
UID u0a57: ACTIVE count=0 state=2
UID u0a58: INACTIVE count=0 state=8
UID u0a59: INACTIVE count=0 state=17
UID u0a60: ACTIVE count=0 state=3
UID u0a61: INACTIVE count=0 state=17
UID u0a62: ACTIVE count=1 state=2
UID u0i0: ACTIVE count=0 state=2
Looper state:
Looper (PowerManagerService, tid 29) {4263d71}
Message 0: { when=+5s902ms what=4 target=com.android.server.power.PowerManagerService$PowerManagerHandler }
Message 1: { when=+9s932ms what=1 target=com.android.server.power.PowerManagerService$PowerManagerHandler }
Message 2: { when=+3m26s89ms callback=com.android.server.power.PowerManagerService$4 target=com.android.server.power.PowerManagerService$PowerManagerHandler }
(Total messages: 3, polling=true, quitting=false)
Wake Locks: size=2
PARTIAL_WAKE_LOCK '*job*/io.homeassistant.companion.android.minimal/androidx.work.impl.background.systemjob.SystemJobService' ACQ=-5m27s855ms LONG (uid=1000 pid=1198 ws=WorkSource{10062})
PARTIAL_WAKE_LOCK 'WorkManager: ProcessorForegroundLck' ACQ=-5m27s670ms LONG (uid=10062 pid=2597)
Suspend Blockers: size=4
PowerManagerService.WakeLocks: ref count=1
PowerManagerService.Display: ref count=1
PowerManagerService.Broadcasts: ref count=0
PowerManagerService.WirelessChargerDetector: ref count=0
Display Power: state=ON
Battery saver policy
Settings battery_saver_constants
value: null
vibration_disabled=true
animation_disabled=true
fullbackup_deferred=true
keyvaluebackup_deferred=true
firewall_disabled=false
datasaver_disabled=true
adjust_brightness_disabled=false
adjust_brightness_factor=0.5
gps_mode=1
Wireless Charger Detector State:
mGravitySensor=null
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