summaryrefslogtreecommitdiffstats
path: root/cmds/pm
diff options
context:
space:
mode:
Diffstat (limited to 'cmds/pm')
-rw-r--r--cmds/pm/src/com/android/commands/pm/Pm.java27
1 files changed, 20 insertions, 7 deletions
diff --git a/cmds/pm/src/com/android/commands/pm/Pm.java b/cmds/pm/src/com/android/commands/pm/Pm.java
index 7a01701..89dd079 100644
--- a/cmds/pm/src/com/android/commands/pm/Pm.java
+++ b/cmds/pm/src/com/android/commands/pm/Pm.java
@@ -48,7 +48,6 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.IUserManager;
-import android.os.Process;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.UserHandle;
@@ -893,6 +892,8 @@ public final class Pm {
installFlags |= PackageManager.INSTALL_INTERNAL;
} else if (opt.equals("-d")) {
installFlags |= PackageManager.INSTALL_ALLOW_DOWNGRADE;
+ } else if (opt.equals("-g")) {
+ installFlags |= PackageManager.INSTALL_GRANT_RUNTIME_PERMISSIONS;
} else if (opt.equals("--originating-uri")) {
originatingUriString = nextOptionData();
if (originatingUriString == null) {
@@ -1518,6 +1519,15 @@ public final class Pm {
}
private int runGrantRevokePermission(boolean grant) {
+ int userId = UserHandle.USER_CURRENT;
+
+ String opt = null;
+ while ((opt = nextOption()) != null) {
+ if (opt.equals("--user")) {
+ userId = Integer.parseInt(nextArg());
+ }
+ }
+
String pkg = nextArg();
if (pkg == null) {
System.err.println("Error: no package specified");
@@ -1530,11 +1540,12 @@ public final class Pm {
showUsage();
return 1;
}
+
try {
if (grant) {
- mPm.grantPermission(pkg, perm);
+ mPm.grantPermission(pkg, perm, userId);
} else {
- mPm.revokePermission(pkg, perm);
+ mPm.revokePermission(pkg, perm, userId);
}
return 0;
} catch (RemoteException e) {
@@ -1816,8 +1827,8 @@ public final class Pm {
System.err.println(" pm disable-until-used [--user USER_ID] PACKAGE_OR_COMPONENT");
System.err.println(" pm hide [--user USER_ID] PACKAGE_OR_COMPONENT");
System.err.println(" pm unhide [--user USER_ID] PACKAGE_OR_COMPONENT");
- System.err.println(" pm grant PACKAGE PERMISSION");
- System.err.println(" pm revoke PACKAGE PERMISSION");
+ System.err.println(" pm grant [--user USER_ID] PACKAGE PERMISSION");
+ System.err.println(" pm revoke [--user USER_ID] PACKAGE PERMISSION");
System.err.println(" pm set-install-location [0/auto] [1/internal] [2/external]");
System.err.println(" pm get-install-location");
System.err.println(" pm set-permission-enforced PERMISSION [true|false]");
@@ -1869,6 +1880,7 @@ public final class Pm {
System.err.println(" -f: install application on internal flash");
System.err.println(" -d: allow version code downgrade");
System.err.println(" -p: partial application install");
+ System.err.println(" -g: grant all runtime permissions");
System.err.println(" -S: size in bytes of entire session");
System.err.println("");
System.err.println("pm install-write: write a package into existing session; path may");
@@ -1890,8 +1902,9 @@ public final class Pm {
System.err.println(" as \"package/class\").");
System.err.println("");
System.err.println("pm grant, revoke: these commands either grant or revoke permissions");
- System.err.println(" to applications. Only optional permissions the application has");
- System.err.println(" declared can be granted or revoked.");
+ System.err.println(" to apps. The permissions must be declared as used in the app's");
+ System.err.println(" manifest, be runtime permissions (protection level dangerous),");
+ System.err.println(" and the app targeting SDK greater than Lollipop MR1.");
System.err.println("");
System.err.println("pm get-install-location: returns the current install location.");
System.err.println(" 0 [auto]: Let system decide the best location");