Merge "Clarify time units for setManagedProfileMaximumTimeOff argument." into rvc-dev am: 75e2ea6bb4 am: eb839a050b am: 437581f95d

Change-Id: I7057a6329226408cc11be2eef2097856d32bf561
This commit is contained in:
Automerger Merge Worker
2020-03-13 15:24:33 +00:00
2 changed files with 19 additions and 18 deletions

View File

@@ -11984,17 +11984,17 @@ public class DevicePolicyManager {
* must handle this intent. * must handle this intent.
* *
* @param admin Which {@link DeviceAdminReceiver} this request is associated with * @param admin Which {@link DeviceAdminReceiver} this request is associated with
* @param timeoutMs Maximum time the profile is allowed to be off in milliseconds or 0 if * @param timeoutMillis Maximum time the profile is allowed to be off in milliseconds or 0 if
* not limited. * not limited.
* @throws IllegalStateException if the profile owner doesn't have an activity that handles * @throws IllegalStateException if the profile owner doesn't have an activity that handles
* {@link #ACTION_CHECK_POLICY_COMPLIANCE} * {@link #ACTION_CHECK_POLICY_COMPLIANCE}
* @see #setPersonalAppsSuspended * @see #setPersonalAppsSuspended
*/ */
public void setManagedProfileMaximumTimeOff(@NonNull ComponentName admin, long timeoutMs) { public void setManagedProfileMaximumTimeOff(@NonNull ComponentName admin, long timeoutMillis) {
throwIfParentInstance("setManagedProfileMaximumTimeOff"); throwIfParentInstance("setManagedProfileMaximumTimeOff");
if (mService != null) { if (mService != null) {
try { try {
mService.setManagedProfileMaximumTimeOff(admin, timeoutMs); mService.setManagedProfileMaximumTimeOff(admin, timeoutMillis);
} catch (RemoteException re) { } catch (RemoteException re) {
throw re.rethrowFromSystemServer(); throw re.rethrowFromSystemServer();
} }

View File

@@ -1199,7 +1199,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
// Whether the admin explicitly requires personal apps to be suspended // Whether the admin explicitly requires personal apps to be suspended
boolean mSuspendPersonalApps = false; boolean mSuspendPersonalApps = false;
// Maximum time the profile owned by this admin can be off. // Maximum time the profile owned by this admin can be off.
long mProfileMaximumTimeOff = 0; long mProfileMaximumTimeOffMillis = 0;
// Time by which the profile should be turned on according to System.currentTimeMillis(). // Time by which the profile should be turned on according to System.currentTimeMillis().
long mProfileOffDeadline = 0; long mProfileOffDeadline = 0;
@@ -1440,10 +1440,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
if (mSuspendPersonalApps) { if (mSuspendPersonalApps) {
writeAttributeValueToXml(out, TAG_SUSPEND_PERSONAL_APPS, mSuspendPersonalApps); writeAttributeValueToXml(out, TAG_SUSPEND_PERSONAL_APPS, mSuspendPersonalApps);
} }
if (mProfileMaximumTimeOff != 0) { if (mProfileMaximumTimeOffMillis != 0) {
writeAttributeValueToXml(out, TAG_PROFILE_MAXIMUM_TIME_OFF, mProfileMaximumTimeOff); writeAttributeValueToXml(out, TAG_PROFILE_MAXIMUM_TIME_OFF,
mProfileMaximumTimeOffMillis);
} }
if (mProfileMaximumTimeOff != 0) { if (mProfileMaximumTimeOffMillis != 0) {
writeAttributeValueToXml(out, TAG_PROFILE_OFF_DEADLINE, mProfileOffDeadline); writeAttributeValueToXml(out, TAG_PROFILE_OFF_DEADLINE, mProfileOffDeadline);
} }
if (!TextUtils.isEmpty(mAlwaysOnVpnPackage)) { if (!TextUtils.isEmpty(mAlwaysOnVpnPackage)) {
@@ -1692,7 +1693,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
mSuspendPersonalApps = Boolean.parseBoolean( mSuspendPersonalApps = Boolean.parseBoolean(
parser.getAttributeValue(null, ATTR_VALUE)); parser.getAttributeValue(null, ATTR_VALUE));
} else if (TAG_PROFILE_MAXIMUM_TIME_OFF.equals(tag)) { } else if (TAG_PROFILE_MAXIMUM_TIME_OFF.equals(tag)) {
mProfileMaximumTimeOff = mProfileMaximumTimeOffMillis =
Long.parseLong(parser.getAttributeValue(null, ATTR_VALUE)); Long.parseLong(parser.getAttributeValue(null, ATTR_VALUE));
} else if (TAG_PROFILE_OFF_DEADLINE.equals(tag)) { } else if (TAG_PROFILE_OFF_DEADLINE.equals(tag)) {
mProfileOffDeadline = mProfileOffDeadline =
@@ -1930,8 +1931,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
pw.println(mCrossProfilePackages); pw.println(mCrossProfilePackages);
pw.print("mSuspendPersonalApps="); pw.print("mSuspendPersonalApps=");
pw.println(mSuspendPersonalApps); pw.println(mSuspendPersonalApps);
pw.print("mProfileMaximumTimeOff="); pw.print("mProfileMaximumTimeOffMillis=");
pw.println(mProfileMaximumTimeOff); pw.println(mProfileMaximumTimeOffMillis);
pw.print("mProfileOffDeadline="); pw.print("mProfileOffDeadline=");
pw.println(mProfileOffDeadline); pw.println(mProfileOffDeadline);
pw.print("mAlwaysOnVpnPackage="); pw.print("mAlwaysOnVpnPackage=");
@@ -15725,18 +15726,18 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
} }
boolean shouldSaveSettings = false; boolean shouldSaveSettings = false;
if (profileOwner.mProfileOffDeadline != 0 if (profileOwner.mProfileOffDeadline != 0
&& (profileOwner.mProfileMaximumTimeOff == 0 || unlocked)) { && (profileOwner.mProfileMaximumTimeOffMillis == 0 || unlocked)) {
// There is a deadline but either there is no policy or the profile is unlocked -> clear // There is a deadline but either there is no policy or the profile is unlocked -> clear
// the deadline. // the deadline.
Slog.i(LOG_TAG, "Profile off deadline is reset to zero"); Slog.i(LOG_TAG, "Profile off deadline is reset to zero");
profileOwner.mProfileOffDeadline = 0; profileOwner.mProfileOffDeadline = 0;
shouldSaveSettings = true; shouldSaveSettings = true;
} else if (profileOwner.mProfileOffDeadline == 0 } else if (profileOwner.mProfileOffDeadline == 0
&& (profileOwner.mProfileMaximumTimeOff != 0 && !unlocked)) { && (profileOwner.mProfileMaximumTimeOffMillis != 0 && !unlocked)) {
// There profile is locked and there is a policy, but the deadline is not set -> set the // There profile is locked and there is a policy, but the deadline is not set -> set the
// deadline. // deadline.
Slog.i(LOG_TAG, "Profile off deadline is set."); Slog.i(LOG_TAG, "Profile off deadline is set.");
profileOwner.mProfileOffDeadline = now + profileOwner.mProfileMaximumTimeOff; profileOwner.mProfileOffDeadline = now + profileOwner.mProfileMaximumTimeOffMillis;
shouldSaveSettings = true; shouldSaveSettings = true;
} }
@@ -15837,7 +15838,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
} }
@Override @Override
public void setManagedProfileMaximumTimeOff(ComponentName who, long timeoutMs) { public void setManagedProfileMaximumTimeOff(ComponentName who, long timeoutMillis) {
final int userId = mInjector.userHandleGetCallingUserId(); final int userId = mInjector.userHandleGetCallingUserId();
synchronized (getLockObject()) { synchronized (getLockObject()) {
final ActiveAdmin admin = getActiveAdminForCallerLocked(who, final ActiveAdmin admin = getActiveAdminForCallerLocked(who,
@@ -15846,10 +15847,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
// DO shouldn't be able to use this method. // DO shouldn't be able to use this method.
enforceProfileOwnerOfOrganizationOwnedDevice(admin); enforceProfileOwnerOfOrganizationOwnedDevice(admin);
enforceHandlesCheckPolicyComplianceIntent(userId, admin.info.getPackageName()); enforceHandlesCheckPolicyComplianceIntent(userId, admin.info.getPackageName());
if (admin.mProfileMaximumTimeOff == timeoutMs) { if (admin.mProfileMaximumTimeOffMillis == timeoutMillis) {
return; return;
} }
admin.mProfileMaximumTimeOff = timeoutMs; admin.mProfileMaximumTimeOffMillis = timeoutMillis;
saveSettingsLocked(userId); saveSettingsLocked(userId);
} }
@@ -15859,7 +15860,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
DevicePolicyEventLogger DevicePolicyEventLogger
.createEvent(DevicePolicyEnums.SET_MANAGED_PROFILE_MAXIMUM_TIME_OFF) .createEvent(DevicePolicyEnums.SET_MANAGED_PROFILE_MAXIMUM_TIME_OFF)
.setAdmin(who) .setAdmin(who)
.setTimePeriod(timeoutMs) .setTimePeriod(timeoutMillis)
.write(); .write();
} }
@@ -15883,7 +15884,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
false /* parent */); false /* parent */);
// DO shouldn't be able to use this method. // DO shouldn't be able to use this method.
enforceProfileOwnerOfOrganizationOwnedDevice(admin); enforceProfileOwnerOfOrganizationOwnedDevice(admin);
return admin.mProfileMaximumTimeOff; return admin.mProfileMaximumTimeOffMillis;
} }
} }