diff options
author | Kenny Guy <kennyguy@google.com> | 2016-04-19 13:09:18 +0100 |
---|---|---|
committer | Kenny Guy <kennyguy@google.com> | 2016-04-19 20:10:56 +0100 |
commit | 38dcca51a739d3273b24e84ba5e89e505f45960c (patch) | |
tree | 44f032b881815aa7e28670424c308b1c74daa7ef /cmds/dpm/src | |
parent | 882a0802a7f7268750b15adb8747dd3904f935b0 (diff) |
Add test method to remove admins.
Add test method to remove admins that declare
FLAG_TEST_APP without informing them.
The method will also remove the device and profile
owner status of the admin.
Bug: 28027468
Change-Id: Idb4d3299a9c6595c94bfb424546cd8a384131835
Diffstat (limited to 'cmds/dpm/src')
-rw-r--r-- | cmds/dpm/src/com/android/commands/dpm/Dpm.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/cmds/dpm/src/com/android/commands/dpm/Dpm.java b/cmds/dpm/src/com/android/commands/dpm/Dpm.java index b83484d99824..31c742153f24 100644 --- a/cmds/dpm/src/com/android/commands/dpm/Dpm.java +++ b/cmds/dpm/src/com/android/commands/dpm/Dpm.java @@ -44,6 +44,7 @@ public final class Dpm extends BaseCommand { private static final String COMMAND_SET_ACTIVE_ADMIN = "set-active-admin"; private static final String COMMAND_SET_DEVICE_OWNER = "set-device-owner"; private static final String COMMAND_SET_PROFILE_OWNER = "set-profile-owner"; + private static final String COMMAND_REMOVE_ACTIVE_ADMIN = "remove-active-admin"; private IDevicePolicyManager mDevicePolicyManager; private int mUserId = UserHandle.USER_SYSTEM; @@ -60,6 +61,8 @@ public final class Dpm extends BaseCommand { "[ --name <NAME> ] <COMPONENT>\n" + "usage: dpm set-profile-owner [ --user <USER_ID> | current ] [ --name <NAME> ] " + "<COMPONENT>\n" + + "usage: dpm remove-active-admin [ --user <USER_ID> | current ] [ --name <NAME> ] " + + "<COMPONENT>\n" + "\n" + "dpm set-active-admin: Sets the given component as active admin" + " for an existing user.\n" + @@ -68,7 +71,11 @@ public final class Dpm extends BaseCommand { " package as device owner.\n" + "\n" + "dpm set-profile-owner: Sets the given component as active admin and profile" + - " owner for an existing user.\n"); + " owner for an existing user.\n" + + "\n" + + "dpm remove-active-admin: Disables an active admin, the admin must have declared" + + " android:testOnly in the application in its manifest. This will also remove" + + " device and profile owners\n"); } @Override @@ -91,6 +98,9 @@ public final class Dpm extends BaseCommand { case COMMAND_SET_PROFILE_OWNER: runSetProfileOwner(); break; + case COMMAND_REMOVE_ACTIVE_ADMIN: + runRemoveActiveAdmin(); + break; default: throw new IllegalArgumentException ("unknown command '" + command + "'"); } @@ -152,6 +162,12 @@ public final class Dpm extends BaseCommand { System.out.println("Active admin set to component " + mComponent.toShortString()); } + private void runRemoveActiveAdmin() throws RemoteException { + parseArgs(/*canHaveName=*/ false); + mDevicePolicyManager.forceRemoveActiveAdmin(mComponent, mUserId); + System.out.println("Success: Admin removed " + mComponent); + } + private void runSetProfileOwner() throws RemoteException { parseArgs(/*canHaveName=*/ true); mDevicePolicyManager.setActiveAdmin(mComponent, true /*refreshing*/, mUserId); |