Ricket
Ricket

Reputation: 34057

Android: Enumerate all wake locks in the system

I have trouble with an Android app keeping a partial wake lock on my system; so I'd like to write an app that keeps an eye on the bad app and kills its partial wake lock shortly after it acquires one.

android.os.PowerManager is used to acquire and release wake locks but I don't see any way to get all wake locks in the system; even if I got access to its IPowerManager mService variable, that service doesn't release a wake lock without the IBinder object associated with the wake lock.

So I'm stuck. How do I proceed? Is this even possible?

Upvotes: 1

Views: 3266

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006654

It's not possible, in that you cannot write an app that cancels another app's WakeLocks.

FWIW, you can use adb shell dumpsys to find out about outstanding WakeLocks, among other things.

Upvotes: 2

Related Questions