How can I see which wakelocks are active

前端 未结 8 2151
时光说笑
时光说笑 2020-12-12 16:02

For some reason my Android phone won\'t go to sleep. I assume that a wakelock is keeping it awake, but there is no way to tell which wakelocks are active. The running servic

8条回答
  •  甜味超标
    2020-12-12 16:19

    You can use below adb command to require a wake lock

      adb shell "echo mylock > /sys/power/wake_lock"
    

    Then, you can use below command to watch if this lock is active. You will see the time column continuously change, it means the wake lock is active

      watch -n 1 'adb shell "cat /proc/wakelocks" | grep mylock'
    

    Now, use this adb command to release the wake lock

      adb shell "echo mylock > /sys/power/wake_unlock"
    

    Then, check it again, the time column will freeze, it means the wake lock is non active

      watch -n 1 'adb shell "cat /proc/wakelocks" | grep mylock'
    

    You can use the same technique to observe the wake lock you acquire in the code.

提交回复
热议问题