diff options
author | Pavel Grafov <pgrafov@google.com> | 2018-01-31 21:06:24 +0000 |
---|---|---|
committer | Pavel Grafov <pgrafov@google.com> | 2018-02-02 14:20:41 +0000 |
commit | 5bb5a6219dae39d929bca08623c23fc5800dd3b7 (patch) | |
tree | a01f42a28e80fd1fbe3b16ae40c2668098642372 /cmds/dpm/src | |
parent | cb6854eb8fc65b74630baac76edc25b6212b4235 (diff) |
Introduce "adb shell dpm force-security-logs"
This command fetches the most recent batch of the logs
and makes them available to the DPC. Primary purpose is
to make security logging testable in CTS without having
to either wait for 2 hours or relying on implementation
details.
To prevent the user from abusing the command and
annoying the DPC, it is throttled if run more than once
per 10 seconds. Waiting happens in Dpm command.
Test: adb shell dpm force-security-logs
Bug: 70886042
Bug: 62251154
Change-Id: Ic5acd5a3e5c3b060881385c472df2b972961b626
Diffstat (limited to 'cmds/dpm/src')
-rw-r--r-- | cmds/dpm/src/com/android/commands/dpm/Dpm.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/cmds/dpm/src/com/android/commands/dpm/Dpm.java b/cmds/dpm/src/com/android/commands/dpm/Dpm.java index 47581e10e937..7c1a5557a1e9 100644 --- a/cmds/dpm/src/com/android/commands/dpm/Dpm.java +++ b/cmds/dpm/src/com/android/commands/dpm/Dpm.java @@ -46,6 +46,7 @@ public final class Dpm extends BaseCommand { private static final String COMMAND_SET_PROFILE_OWNER = "set-profile-owner"; private static final String COMMAND_REMOVE_ACTIVE_ADMIN = "remove-active-admin"; private static final String COMMAND_CLEAR_FREEZE_PERIOD_RECORD = "clear-freeze-period-record"; + private static final String COMMAND_FORCE_SECURITY_LOGS = "force-security-logs"; private IDevicePolicyManager mDevicePolicyManager; private int mUserId = UserHandle.USER_SYSTEM; @@ -76,11 +77,15 @@ public final class Dpm extends BaseCommand { "\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" + + " device and profile owners.\n" + "\n" + "dpm " + COMMAND_CLEAR_FREEZE_PERIOD_RECORD + ": clears framework-maintained " + "record of past freeze periods that the device went through. For use during " + - "feature development to prevent triggering restriction on setting freeze periods"); + "feature development to prevent triggering restriction on setting freeze " + + "periods.\n" + + "\n" + + "dpm " + COMMAND_FORCE_SECURITY_LOGS + ": makes all security logs available to " + + "the DPC and triggers DeviceAdminReceiver.onSecurityLogsAvailable() if needed."); } @Override @@ -109,11 +114,26 @@ public final class Dpm extends BaseCommand { case COMMAND_CLEAR_FREEZE_PERIOD_RECORD: runClearFreezePeriodRecord(); break; + case COMMAND_FORCE_SECURITY_LOGS: + runForceSecurityLogs(); + break; default: throw new IllegalArgumentException ("unknown command '" + command + "'"); } } + private void runForceSecurityLogs() throws RemoteException, InterruptedException { + while (true) { + final long toWait = mDevicePolicyManager.forceSecurityLogs(); + if (toWait == 0) { + break; + } + System.out.println("We have to wait for " + toWait + " milliseconds..."); + Thread.sleep(toWait); + } + System.out.println("Success"); + } + private void parseArgs(boolean canHaveName) { String opt; while ((opt = nextOption()) != null) { |