From 7ea3e7df1f1ff5dde8ffb42fa179beef679f40ea Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Fri, 20 Apr 2012 15:19:35 -0700 Subject: [PATCH] Fix dumpsys package. Was bailing out due to insufficient permissions to query users. Bug: 6374050 Change-Id: Ic4a4ab32e2efb4d1fc1f1607fd304f99d5382743 --- services/java/com/android/server/pm/Settings.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/java/com/android/server/pm/Settings.java b/services/java/com/android/server/pm/Settings.java index 35b6bdefd3f55..d0152782f39d1 100644 --- a/services/java/com/android/server/pm/Settings.java +++ b/services/java/com/android/server/pm/Settings.java @@ -2300,12 +2300,15 @@ final class Settings { } private List getAllUsers() { + long id = Binder.clearCallingIdentity(); try { return AppGlobals.getPackageManager().getUsers(); } catch (RemoteException re) { // Local to system process, shouldn't happen } catch (NullPointerException npe) { // packagemanager not yet initialized + } finally { + Binder.restoreCallingIdentity(id); } return null; } @@ -2347,6 +2350,7 @@ final class Settings { final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); final Date date = new Date(); boolean printedSomething = false; + List users = getAllUsers(); for (final PackageSetting ps : mPackages.values()) { if (packageName != null && !packageName.equals(ps.realName) && !packageName.equals(ps.name)) { @@ -2447,7 +2451,6 @@ final class Settings { pw.print(" haveGids="); pw.println(ps.haveGids); pw.print(" pkgFlags=0x"); pw.print(Integer.toHexString(ps.pkgFlags)); pw.print(" installStatus="); pw.print(ps.installStatus); - List users = getAllUsers(); for (UserInfo user : users) { pw.print(" User "); pw.print(user.id); pw.print(": "); pw.print(" stopped=");