From e4a5951925f16f18dae91ed65567e96528f17fee Mon Sep 17 00:00:00 2001 From: Dianne Hackborn Date: Tue, 7 Dec 2010 11:08:07 -0800 Subject: Fix issue #3154576: battery stats checkin should include UID -> packages+ map Includes some other small fixes to battery collection and a few other things. Output of package info looks like this: 5,0,i,uid,1000,com.android.settings 5,0,i,uid,1000,com.android.providers.subscribedfeeds 5,0,i,uid,1000,com.android.providers.settings 5,0,i,uid,1000,com.android.server.vpn 5,0,i,uid,1000,android 5,0,i,uid,1000,com.android.systemui 5,0,i,uid,1000,com.google.android.backup 5,0,i,uid,1001,com.android.phone 5,0,i,uid,1001,com.android.providers.telephony 5,0,i,uid,1022,com.android.nfc 5,0,i,uid,10021,com.google.android.location 5,0,i,uid,10021,com.google.android.syncadapters.calendar 5,0,i,uid,10021,com.google.android.gsf 5,0,i,uid,10021,com.google.android.syncadapters.contacts 5,0,i,uid,10026,com.android.providers.downloads.ui 5,0,i,uid,10026,com.android.providers.media 5,0,i,uid,10026,com.android.providers.drm 5,0,i,uid,10026,com.android.providers.downloads 5,0,i,uid,10032,com.android.launcher 5,0,i,uid,10039,com.google.android.gm 5,0,i,uid,10041,com.google.android.gallery3d 5,0,i,uid,10049,com.android.providers.calendar Change-Id: I9e38f254eef146339113ad270f5c6e8b60fb7a1d --- cmds/pm/src/com/android/commands/pm/Pm.java | 76 ++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 8 deletions(-) (limited to 'cmds') diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index 9b8b0ac..311dc38 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -152,6 +152,7 @@ public final class Pm { * pm list permission-groups * pm list permissions * pm list features + * pm list libraries * pm list instrumentation */ private void runList() { @@ -169,6 +170,8 @@ public final class Pm { runListPermissions(); } else if ("features".equals(type)) { runListFeatures(); + } else if ("libraries".equals(type)) { + runListLibraries(); } else if ("instrumentation".equals(type)) { runListInstrumentation(); } else { @@ -181,6 +184,8 @@ public final class Pm { * Lists all the installed packages. */ private void runListPackages(boolean showApplicationPackage) { + int getFlags = 0; + boolean listDisabled = false, listEnabled = false; try { String opt; while ((opt=nextOption()) != null) { @@ -190,6 +195,12 @@ public final class Pm { showApplicationPackage = true; } else if (opt.equals("-f")) { showApplicationPackage = true; + } else if (opt.equals("-d")) { + listDisabled = true; + } else if (opt.equals("-e")) { + listEnabled = true; + } else if (opt.equals("-u")) { + getFlags |= PackageManager.GET_UNINSTALLED_PACKAGES; } else { System.err.println("Error: Unknown option: " + opt); showUsage(); @@ -202,18 +213,26 @@ public final class Pm { return; } + String filter = nextArg(); + try { - List packages = mPm.getInstalledPackages(0 /* all */); + List packages = mPm.getInstalledPackages(getFlags); int count = packages.size(); for (int p = 0 ; p < count ; p++) { PackageInfo info = packages.get(p); - System.out.print("package:"); - if (showApplicationPackage) { - System.out.print(info.applicationInfo.sourceDir); - System.out.print("="); + if (filter != null && !info.packageName.contains(filter)) { + continue; + } + if ((!listDisabled || !info.applicationInfo.enabled) && + (!listEnabled || info.applicationInfo.enabled)) { + System.out.print("package:"); + if (showApplicationPackage) { + System.out.print(info.applicationInfo.sourceDir); + System.out.print("="); + } + System.out.println(info.packageName); } - System.out.println(info.packageName); } } catch (RemoteException e) { System.err.println(e.toString()); @@ -260,6 +279,42 @@ public final class Pm { } /** + * Lists all of the libraries supported by the current device. + * + * pm list libraries + */ + private void runListLibraries() { + try { + List list = new ArrayList(); + String[] rawList = mPm.getSystemSharedLibraryNames(); + for (int i=0; i() { + public int compare(String o1, String o2) { + if (o1 == o2) return 0; + if (o1 == null) return -1; + if (o2 == null) return 1; + return o1.compareTo(o2); + } + }); + + int count = (list != null) ? list.size() : 0; + for (int p = 0; p < count; p++) { + String lib = list.get(p); + System.out.print("library:"); + System.out.println(lib); + } + } catch (RemoteException e) { + System.err.println(e.toString()); + System.err.println(PM_NOT_RUNNING_ERR); + } + } + + /** * Lists all of the installed instrumentation, or all for a given package * * pm list instrumentation [package] [-f] @@ -880,11 +935,12 @@ public final class Pm { private static void showUsage() { System.err.println("usage: pm [list|path|install|uninstall]"); - System.err.println(" pm list packages [-f]"); + System.err.println(" pm list packages [-f] [-d] [-e] [-u] [FILTER]"); System.err.println(" pm list permission-groups"); System.err.println(" pm list permissions [-g] [-f] [-d] [-u] [GROUP]"); System.err.println(" pm list instrumentation [-f] [TARGET-PACKAGE]"); System.err.println(" pm list features"); + System.err.println(" pm list libraries"); System.err.println(" pm path PACKAGE"); System.err.println(" pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH"); System.err.println(" pm uninstall [-k] PACKAGE"); @@ -892,8 +948,12 @@ public final class Pm { System.err.println(" pm disable PACKAGE_OR_COMPONENT"); System.err.println(" pm setInstallLocation [0/auto] [1/internal] [2/external]"); System.err.println(""); - System.err.println("The list packages command prints all packages. Options:"); + System.err.println("The list packages command prints all packages, optionally only"); + System.err.println("those whose package name contains the text in FILTER. Options:"); System.err.println(" -f: see their associated file."); + System.err.println(" -d: filter to include disbled packages."); + System.err.println(" -e: filter to include enabled packages."); + System.err.println(" -u: also include uninstalled packages."); System.err.println(""); System.err.println("The list permission-groups command prints all known"); System.err.println("permission groups."); -- cgit v1.1