Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f5bd092b authored by Mike Lockwood's avatar Mike Lockwood
Browse files

Improve wakelock debugging:



Throw NullPointerException if tag is null in PowerManager.newWakelock()
Print wakelock owner's uid and pid in dumpsys power output.

BUG: 2522675

Change-Id: I462c7f8c49f9896b2f58cef5a678ebd2c062a8f7
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent fb0de34a
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -361,6 +361,9 @@ public class PowerManager
     */
    public WakeLock newWakeLock(int flags, String tag)
    {
        if (tag == null) {
            throw new NullPointerException("tag is null in PowerManager.newWakeLock");
        }
        return new WakeLock(flags, tag);
    }

+4 −1
Original line number Diff line number Diff line
@@ -571,6 +571,7 @@ class PowerManagerService extends IPowerManager.Stub
            binder = b;
            tag = t;
            uid = u == MY_UID ? Process.SYSTEM_UID : u;
            pid = Binder.getCallingPid();
            if (u != MY_UID || (
                    !"KEEP_SCREEN_ON_FLAG".equals(tag)
                    && !"KeyInputQueue".equals(tag))) {
@@ -595,6 +596,7 @@ class PowerManagerService extends IPowerManager.Stub
        final IBinder binder;
        final String tag;
        final int uid;
        final int pid;
        final int monitorType;
        boolean activated = true;
        int minState;
@@ -998,7 +1000,8 @@ class PowerManagerService extends IPowerManager.Stub
                   activated = " activated";
                }
                pw.println("  " + type + " '" + wl.tag + "'" + acquireCausesWakeup
                        + activated + " (minState=" + wl.minState + ")");
                        + activated + " (minState=" + wl.minState + ", uid=" + wl.uid
                        + ", pid=" + wl.pid + ")");
            }

            pw.println();