Merge "Clarify time units for setManagedProfileMaximumTimeOff argument." into rvc-dev am: 75e2ea6bb4 am: eb839a050b am: 437581f95d
Change-Id: I7057a6329226408cc11be2eef2097856d32bf561
This commit is contained in:
@@ -11984,17 +11984,17 @@ public class DevicePolicyManager {
|
||||
* must handle this intent.
|
||||
*
|
||||
* @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.
|
||||
* @throws IllegalStateException if the profile owner doesn't have an activity that handles
|
||||
* {@link #ACTION_CHECK_POLICY_COMPLIANCE}
|
||||
* @see #setPersonalAppsSuspended
|
||||
*/
|
||||
public void setManagedProfileMaximumTimeOff(@NonNull ComponentName admin, long timeoutMs) {
|
||||
public void setManagedProfileMaximumTimeOff(@NonNull ComponentName admin, long timeoutMillis) {
|
||||
throwIfParentInstance("setManagedProfileMaximumTimeOff");
|
||||
if (mService != null) {
|
||||
try {
|
||||
mService.setManagedProfileMaximumTimeOff(admin, timeoutMs);
|
||||
mService.setManagedProfileMaximumTimeOff(admin, timeoutMillis);
|
||||
} catch (RemoteException re) {
|
||||
throw re.rethrowFromSystemServer();
|
||||
}
|
||||
|
||||
@@ -1199,7 +1199,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
// Whether the admin explicitly requires personal apps to be suspended
|
||||
boolean mSuspendPersonalApps = false;
|
||||
// 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().
|
||||
long mProfileOffDeadline = 0;
|
||||
|
||||
@@ -1440,10 +1440,11 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
if (mSuspendPersonalApps) {
|
||||
writeAttributeValueToXml(out, TAG_SUSPEND_PERSONAL_APPS, mSuspendPersonalApps);
|
||||
}
|
||||
if (mProfileMaximumTimeOff != 0) {
|
||||
writeAttributeValueToXml(out, TAG_PROFILE_MAXIMUM_TIME_OFF, mProfileMaximumTimeOff);
|
||||
if (mProfileMaximumTimeOffMillis != 0) {
|
||||
writeAttributeValueToXml(out, TAG_PROFILE_MAXIMUM_TIME_OFF,
|
||||
mProfileMaximumTimeOffMillis);
|
||||
}
|
||||
if (mProfileMaximumTimeOff != 0) {
|
||||
if (mProfileMaximumTimeOffMillis != 0) {
|
||||
writeAttributeValueToXml(out, TAG_PROFILE_OFF_DEADLINE, mProfileOffDeadline);
|
||||
}
|
||||
if (!TextUtils.isEmpty(mAlwaysOnVpnPackage)) {
|
||||
@@ -1692,7 +1693,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
mSuspendPersonalApps = Boolean.parseBoolean(
|
||||
parser.getAttributeValue(null, ATTR_VALUE));
|
||||
} else if (TAG_PROFILE_MAXIMUM_TIME_OFF.equals(tag)) {
|
||||
mProfileMaximumTimeOff =
|
||||
mProfileMaximumTimeOffMillis =
|
||||
Long.parseLong(parser.getAttributeValue(null, ATTR_VALUE));
|
||||
} else if (TAG_PROFILE_OFF_DEADLINE.equals(tag)) {
|
||||
mProfileOffDeadline =
|
||||
@@ -1930,8 +1931,8 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
pw.println(mCrossProfilePackages);
|
||||
pw.print("mSuspendPersonalApps=");
|
||||
pw.println(mSuspendPersonalApps);
|
||||
pw.print("mProfileMaximumTimeOff=");
|
||||
pw.println(mProfileMaximumTimeOff);
|
||||
pw.print("mProfileMaximumTimeOffMillis=");
|
||||
pw.println(mProfileMaximumTimeOffMillis);
|
||||
pw.print("mProfileOffDeadline=");
|
||||
pw.println(mProfileOffDeadline);
|
||||
pw.print("mAlwaysOnVpnPackage=");
|
||||
@@ -15725,18 +15726,18 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
}
|
||||
boolean shouldSaveSettings = false;
|
||||
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
|
||||
// the deadline.
|
||||
Slog.i(LOG_TAG, "Profile off deadline is reset to zero");
|
||||
profileOwner.mProfileOffDeadline = 0;
|
||||
shouldSaveSettings = true;
|
||||
} 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
|
||||
// deadline.
|
||||
Slog.i(LOG_TAG, "Profile off deadline is set.");
|
||||
profileOwner.mProfileOffDeadline = now + profileOwner.mProfileMaximumTimeOff;
|
||||
profileOwner.mProfileOffDeadline = now + profileOwner.mProfileMaximumTimeOffMillis;
|
||||
shouldSaveSettings = true;
|
||||
}
|
||||
|
||||
@@ -15837,7 +15838,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManagedProfileMaximumTimeOff(ComponentName who, long timeoutMs) {
|
||||
public void setManagedProfileMaximumTimeOff(ComponentName who, long timeoutMillis) {
|
||||
final int userId = mInjector.userHandleGetCallingUserId();
|
||||
synchronized (getLockObject()) {
|
||||
final ActiveAdmin admin = getActiveAdminForCallerLocked(who,
|
||||
@@ -15846,10 +15847,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
// DO shouldn't be able to use this method.
|
||||
enforceProfileOwnerOfOrganizationOwnedDevice(admin);
|
||||
enforceHandlesCheckPolicyComplianceIntent(userId, admin.info.getPackageName());
|
||||
if (admin.mProfileMaximumTimeOff == timeoutMs) {
|
||||
if (admin.mProfileMaximumTimeOffMillis == timeoutMillis) {
|
||||
return;
|
||||
}
|
||||
admin.mProfileMaximumTimeOff = timeoutMs;
|
||||
admin.mProfileMaximumTimeOffMillis = timeoutMillis;
|
||||
saveSettingsLocked(userId);
|
||||
}
|
||||
|
||||
@@ -15859,7 +15860,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
DevicePolicyEventLogger
|
||||
.createEvent(DevicePolicyEnums.SET_MANAGED_PROFILE_MAXIMUM_TIME_OFF)
|
||||
.setAdmin(who)
|
||||
.setTimePeriod(timeoutMs)
|
||||
.setTimePeriod(timeoutMillis)
|
||||
.write();
|
||||
}
|
||||
|
||||
@@ -15883,7 +15884,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
|
||||
false /* parent */);
|
||||
// DO shouldn't be able to use this method.
|
||||
enforceProfileOwnerOfOrganizationOwnedDevice(admin);
|
||||
return admin.mProfileMaximumTimeOff;
|
||||
return admin.mProfileMaximumTimeOffMillis;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user