From 655d0e2029e6ae77a47e922dce4c4989818b8dd1 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Wed, 12 Jun 2013 14:19:10 -0700 Subject: Single-user restrictions Introduces a new "blocked" state for each package. This is used to temporarily disable an app via Settings->Restrictions. PIN creation and challenge activities for use by Settings and other apps. PIN is stored by the User Manager and it manages the interval for retry attempts across reboots. Change-Id: I4915329d1f72399bbcaf93a9ca9c0d2e69d098dd --- cmds/pm/src/com/android/commands/pm/Pm.java | 42 +++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (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 6f57ae0..d1ded10 100644 --- a/cmds/pm/src/com/android/commands/pm/Pm.java +++ b/cmds/pm/src/com/android/commands/pm/Pm.java @@ -147,6 +147,16 @@ public final class Pm { return; } + if ("block".equals(op)) { + runSetBlockedSetting(true); + return; + } + + if ("unblock".equals(op)) { + runSetBlockedSetting(false); + return; + } + if ("grant".equals(op)) { runGrantRevokePermission(true); return; @@ -1256,6 +1266,36 @@ public final class Pm { } } + private void runSetBlockedSetting(boolean state) { + int userId = 0; + 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; + } else { + userId = Integer.parseInt(optionData); + } + } + + String pkg = nextArg(); + if (pkg == null) { + System.err.println("Error: no package or component specified"); + showUsage(); + return; + } + try { + mPm.setApplicationBlockedSettingAsUser(pkg, state, userId); + System.err.println("Package " + pkg + " new blocked state: " + + mPm.getApplicationBlockedSettingAsUser(pkg, userId)); + } catch (RemoteException e) { + System.err.println(e.toString()); + System.err.println(PM_NOT_RUNNING_ERR); + } + } + private void runGrantRevokePermission(boolean grant) { String pkg = nextArg(); if (pkg == null) { @@ -1482,6 +1522,8 @@ public final class Pm { System.err.println(" pm disable [--user USER_ID] PACKAGE_OR_COMPONENT"); System.err.println(" pm disable-user [--user USER_ID] PACKAGE_OR_COMPONENT"); System.err.println(" pm disable-until-used [--user USER_ID] PACKAGE_OR_COMPONENT"); + System.err.println(" pm block [--user USER_ID] PACKAGE_OR_COMPONENT"); + System.err.println(" pm unblock [--user USER_ID] PACKAGE_OR_COMPONENT"); System.err.println(" pm grant PACKAGE PERMISSION"); System.err.println(" pm revoke PACKAGE PERMISSION"); System.err.println(" pm set-install-location [0/auto] [1/internal] [2/external]"); -- cgit v1.1