From 4266feeb93fae4603e8a43d065160430a4c784a5 Mon Sep 17 00:00:00 2001 From: Ricky Wai Date: Mon, 23 May 2016 15:33:04 +0100 Subject: [PATCH] Unlock work profile storage even work mode is off Bug: 28860823 Change-Id: Ic89027f163e4c4e1ba9e8c24174475b6a4a983a4 --- .../android/server/LockSettingsService.java | 7 ------ .../com/android/server/am/UserController.java | 24 +++++++++---------- 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/services/core/java/com/android/server/LockSettingsService.java b/services/core/java/com/android/server/LockSettingsService.java index cec32291cb302..596fd441d928b 100644 --- a/services/core/java/com/android/server/LockSettingsService.java +++ b/services/core/java/com/android/server/LockSettingsService.java @@ -706,12 +706,6 @@ public class LockSettingsService extends ILockSettings.Stub { } }; - // Turn off quite mode if it's enabled, only managed profile can return true for now, it - // will return false if it is not a managed profile. - if (mUserManager.isQuietModeEnabled(new UserHandle(userId))) { - mUserManager.setQuietModeEnabled(userId, false); - } - try { ActivityManagerNative.getDefault().unlockUser(userId, token, secret, listener); } catch (RemoteException e) { @@ -730,7 +724,6 @@ public class LockSettingsService extends ILockSettings.Stub { // Unlock managed profile with unified lock if (pi.isManagedProfile() && !mLockPatternUtils.isSeparateProfileChallengeEnabled(pi.id) - && !pi.isQuietModeEnabled() && mStorage.hasChildProfileLock(pi.id)) { unlockChildProfile(pi.id); } diff --git a/services/core/java/com/android/server/am/UserController.java b/services/core/java/com/android/server/am/UserController.java index 595d086abf358..67f96d888e3b8 100644 --- a/services/core/java/com/android/server/am/UserController.java +++ b/services/core/java/com/android/server/am/UserController.java @@ -938,6 +938,17 @@ final class UserController { boolean unlockUserCleared(final int userId, byte[] token, byte[] secret, IProgressListener listener) { synchronized (mService) { + // TODO Move this block outside of synchronized if it causes lock contention + if (!StorageManager.isUserKeyUnlocked(userId)) { + final UserInfo userInfo = getUserInfo(userId); + final IMountService mountService = getMountService(); + try { + // We always want to unlock user storage, even user is not started yet + mountService.unlockUserKey(userId, userInfo.serialNumber, token, secret); + } catch (RemoteException | RuntimeException e) { + Slog.w(TAG, "Failed to unlock: " + e.getMessage()); + } + } // Bail if user isn't actually running, otherwise register the given // listener to watch for unlock progress final UserState uss = mStartedUsers.get(userId); @@ -948,19 +959,6 @@ final class UserController { uss.mUnlockProgress.addListener(listener); } - // TODO Move this block outside of synchronized if it causes lock contention - if (!StorageManager.isUserKeyUnlocked(userId)) { - final UserInfo userInfo = getUserInfo(userId); - final IMountService mountService = getMountService(); - try { - mountService.unlockUserKey(userId, userInfo.serialNumber, token, secret); - } catch (RemoteException | RuntimeException e) { - Slog.w(TAG, "Failed to unlock: " + e.getMessage()); - notifyFinished(userId, listener); - return false; - } - } - finishUserUnlocking(uss); // We just unlocked a user, so let's now attempt to unlock any