diff options
author | Brian Carlstrom <bdc@google.com> | 2015-10-15 16:16:07 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-10-15 16:16:07 +0000 |
commit | 80435a7fcd98e5ad1a0537a9646be2fca575f3bb (patch) | |
tree | 64881f56b3a2219032c12f1c68b75eaec99d86c4 /cmds/pm | |
parent | d25c9018fbbc9318f48f139489a0ceabf7a52ef3 (diff) | |
parent | bd5b6252a5dd068c2db30fbbd16e87a656047197 (diff) |
am bd5b6252: am b9a28ae1: am f916524f: Merge "Add support for --user to "pm path" for work profile use"
* commit 'bd5b6252a5dd068c2db30fbbd16e87a656047197':
Add support for --user to "pm path" for work profile use
Diffstat (limited to 'cmds/pm')
-rw-r--r-- | cmds/pm/src/com/android/commands/pm/Pm.java | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java index 393956f29948..3f8e3111cd37 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -283,7 +283,7 @@ public final class Pm { } else if (args.length == 2) { if (args[0].equalsIgnoreCase("-p")) { validCommand = true; - return displayPackageFilePath(args[1]); + return displayPackageFilePath(args[1], UserHandle.USER_OWNER); } } return 1; @@ -767,12 +767,25 @@ public final class Pm { } private int runPath() { + int userId = UserHandle.USER_OWNER; + String option = nextOption(); + if (option != null && option.equals("--user")) { + String optionData = nextOptionData(); + if (optionData == null || !isNumber(optionData)) { + System.err.println("Error: no USER_ID specified"); + showUsage(); + return 1; + } else { + userId = Integer.parseInt(optionData); + } + } + String pkg = nextArg(); if (pkg == null) { System.err.println("Error: no package specified"); return 1; } - return displayPackageFilePath(pkg); + return displayPackageFilePath(pkg, userId); } private int runDump() { @@ -1637,7 +1650,7 @@ public final class Pm { } private int runClear() { - int userId = 0; + int userId = UserHandle.USER_OWNER; String option = nextOption(); if (option != null && option.equals("--user")) { String optionData = nextOptionData(); @@ -1709,7 +1722,7 @@ public final class Pm { } private int runSetEnabledSetting(int state) { - int userId = 0; + int userId = UserHandle.USER_OWNER; String option = nextOption(); if (option != null && option.equals("--user")) { String optionData = nextOptionData(); @@ -1758,7 +1771,7 @@ public final class Pm { } private int runSetHiddenSetting(boolean state) { - int userId = 0; + int userId = UserHandle.USER_OWNER; String option = nextOption(); if (option != null && option.equals("--user")) { String optionData = nextOptionData(); @@ -1963,9 +1976,9 @@ public final class Pm { * Displays the package file for a package. * @param pckg */ - private int displayPackageFilePath(String pckg) { + private int displayPackageFilePath(String pckg, int userId) { try { - PackageInfo info = mPm.getPackageInfo(pckg, 0, 0); + PackageInfo info = mPm.getPackageInfo(pckg, 0, userId); if (info != null && info.applicationInfo != null) { System.out.print("package:"); System.out.println(info.applicationInfo.sourceDir); @@ -2104,7 +2117,7 @@ public final class Pm { System.err.println(" pm list features"); System.err.println(" pm list libraries"); System.err.println(" pm list users"); - System.err.println(" pm path PACKAGE"); + System.err.println(" pm path [--user USER_ID] PACKAGE"); System.err.println(" pm dump PACKAGE"); System.err.println(" pm install [-lrtsfd] [-i PACKAGE] [--user USER_ID] [PATH]"); System.err.println(" pm install-create [-lrtsfdp] [-i PACKAGE] [-S BYTES]"); |