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: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Mike Lockwood
2010-03-22 17:10:15 -04:00
parent fb0de34a47
commit f5bd092b50
2 changed files with 7 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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();