summaryrefslogtreecommitdiff
path: root/cmds/dpm/src
diff options
context:
space:
mode:
authorRubin Xu <rubinxu@google.com>2018-01-11 09:24:02 +0000
committerRubin Xu <rubinxu@google.com>2018-01-26 23:07:59 +0000
commit29b9a7d1f4168d888ee2f4a0ff3882523f655e6b (patch)
treeba28f86d10bcffe2f68ee659c0dee4ac2bc406c7 /cmds/dpm/src
parent906ee677c071118126c3a849d973be7bb94be95f (diff)
Add freeze period support in SystemUpdatePolicy
Freeze period is defined as a pair of calendar dates (recurring annually) during which the system should block any incoming system updates, including security patches. They are set on top of existing system udpate policy types (automatic, windowed, postpone) such that outside the freeze periods existing policy semantics will still apply. They are created to allow admin to keep their device fleet from any destabilizing changes during critical period of the year, for example during Christmas sales period. Device Owner can set several freeze periods, although to prevent the device from not receiving OTAs indefinitely, each single freeze period is restricted to be at most 90 days, and adjacent freeze periods need to be at least 60 days apart. To properly enforce these restrictions, any freeze periods the device previously experienced is tracked by DevicePolicyManager and are validated against any new policy. This is to deal with corner cases such as the admin repeatedly set a short but overlapping freeze period on a rolling basis, hence bypassing the 90-day freeze period restriction. Test: runtest -c com.android.server.devicepolicy.SystemUpdatePolicyTest frameworks-services Bug: 64813061 Change-Id: I2864192797dc194edd9c183b881da6cfe3fdba5e
Diffstat (limited to 'cmds/dpm/src')
-rw-r--r--cmds/dpm/src/com/android/commands/dpm/Dpm.java15
1 files changed, 14 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 3ac70d668198..47581e10e937 100644
--- a/cmds/dpm/src/com/android/commands/dpm/Dpm.java
+++ b/cmds/dpm/src/com/android/commands/dpm/Dpm.java
@@ -45,6 +45,7 @@ public final class Dpm extends BaseCommand {
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 static final String COMMAND_CLEAR_FREEZE_PERIOD_RECORD = "clear-freeze-period-record";
private IDevicePolicyManager mDevicePolicyManager;
private int mUserId = UserHandle.USER_SYSTEM;
@@ -75,7 +76,11 @@ 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");
}
@Override
@@ -101,6 +106,9 @@ public final class Dpm extends BaseCommand {
case COMMAND_REMOVE_ACTIVE_ADMIN:
runRemoveActiveAdmin();
break;
+ case COMMAND_CLEAR_FREEZE_PERIOD_RECORD:
+ runClearFreezePeriodRecord();
+ break;
default:
throw new IllegalArgumentException ("unknown command '" + command + "'");
}
@@ -190,6 +198,11 @@ public final class Dpm extends BaseCommand {
+ mComponent.toShortString() + " for user " + mUserId);
}
+ private void runClearFreezePeriodRecord() throws RemoteException {
+ mDevicePolicyManager.clearSystemUpdatePolicyFreezePeriodRecord();
+ System.out.println("Success");
+ }
+
private ComponentName parseComponentName(String component) {
ComponentName cn = ComponentName.unflattenFromString(component);
if (cn == null) {