summaryrefslogtreecommitdiff
path: root/services/devicepolicy
diff options
context:
space:
mode:
authorPavel Grafov <pgrafov@google.com>2020-05-11 18:04:12 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-05-11 18:04:12 +0000
commitc8d5a6852513be1c4999002e164d0578e7b713d0 (patch)
tree82a35cc72e08937b4b450362fb24571cda56aa63 /services/devicepolicy
parentdc9883a0bde801476e00a310177b240249219cd5 (diff)
parent3b4aa554ac89be21686f2c5a869d6ca04804fdae (diff)
Merge "Make getPersonalAppsSuspensionReasons more robust." into rvc-dev
Diffstat (limited to 'services/devicepolicy')
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java27
1 files changed, 16 insertions, 11 deletions
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index e44f86232315..60d59b2a7558 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -984,6 +984,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
// (ACTION_DATE_CHANGED), or when manual clock adjustment is made
// (ACTION_TIME_CHANGED)
updateSystemUpdateFreezePeriodsRecord(/* saveIfChanged */ true);
+ final int userId = getManagedUserId(UserHandle.USER_SYSTEM);
+ if (userId >= 0) {
+ updatePersonalAppsSuspension(userId, mUserManager.isUserUnlocked(userId));
+ }
} else if (ACTION_PROFILE_OFF_DEADLINE.equals(action)) {
Slog.i(LOG_TAG, "Profile off deadline alarm was triggered");
final int userId = getManagedUserId(UserHandle.USER_SYSTEM);
@@ -15912,15 +15916,12 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
false /* parent */);
// DO shouldn't be able to use this method.
enforceProfileOwnerOfOrganizationOwnedDevice(admin);
- final DevicePolicyData userData =
- getUserData(getProfileParentId(mInjector.userHandleGetCallingUserId()));
- if (!userData.mAppsSuspended) {
- return PERSONAL_APPS_NOT_SUSPENDED;
- } else {
- final long deadline = admin.mProfileOffDeadline;
- return makeSuspensionReasons(admin.mSuspendPersonalApps,
- deadline != 0 && System.currentTimeMillis() > deadline);
- }
+ final long deadline = admin.mProfileOffDeadline;
+ final int result = makeSuspensionReasons(admin.mSuspendPersonalApps,
+ deadline != 0 && mInjector.systemCurrentTimeMillis() > deadline);
+ Slog.d(LOG_TAG, String.format("getPersonalAppsSuspendedReasons user: %d; result: %d",
+ mInjector.userHandleGetCallingUserId(), result));
+ return result;
}
}
@@ -16033,8 +16034,12 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
int profileUserId, ActiveAdmin profileOwner, boolean unlocked) {
final long now = mInjector.systemCurrentTimeMillis();
if (profileOwner.mProfileOffDeadline != 0 && now > profileOwner.mProfileOffDeadline) {
- // Profile off deadline is already reached.
- Slog.i(LOG_TAG, "Profile off deadline has been reached.");
+ Slog.i(LOG_TAG, "Profile off deadline has been reached, unlocked: " + unlocked);
+ if (profileOwner.mProfileOffDeadline != -1) {
+ // Move the deadline far to the past so that it cannot be rolled back by TZ change.
+ profileOwner.mProfileOffDeadline = -1;
+ saveSettingsLocked(profileUserId);
+ }
return PROFILE_OFF_DEADLINE_REACHED;
}
boolean shouldSaveSettings = false;