Remove lock contention when unlocking users am: 6f4d7b39c1
am: 584e9b13ac
Change-Id: Iaf122afd622e20e2e8b77f73a07d01f6fdac0062
This commit is contained in:
@@ -279,6 +279,7 @@ final class UserController {
|
||||
*/
|
||||
private void finishUserUnlocking(final UserState uss) {
|
||||
final int userId = uss.mHandle.getIdentifier();
|
||||
boolean proceedWithUnlock = false;
|
||||
synchronized (mService) {
|
||||
// Bail if we ended up with a stale user
|
||||
if (mStartedUsers.get(uss.mHandle.getIdentifier()) != uss) return;
|
||||
@@ -288,20 +289,24 @@ final class UserController {
|
||||
|
||||
if (uss.setState(STATE_RUNNING_LOCKED, STATE_RUNNING_UNLOCKING)) {
|
||||
getUserManagerInternal().setUserState(userId, uss.state);
|
||||
uss.mUnlockProgress.start();
|
||||
|
||||
// Prepare app storage before we go any further
|
||||
uss.mUnlockProgress.setProgress(5,
|
||||
mService.mContext.getString(R.string.android_start_title));
|
||||
mUserManager.onBeforeUnlockUser(userId);
|
||||
uss.mUnlockProgress.setProgress(20);
|
||||
|
||||
// Dispatch unlocked to system services; when fully dispatched,
|
||||
// that calls through to the next "unlocked" phase
|
||||
mHandler.obtainMessage(SYSTEM_USER_UNLOCK_MSG, userId, 0, uss)
|
||||
.sendToTarget();
|
||||
proceedWithUnlock = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (proceedWithUnlock) {
|
||||
uss.mUnlockProgress.start();
|
||||
|
||||
// Prepare app storage before we go any further
|
||||
uss.mUnlockProgress.setProgress(5,
|
||||
mService.mContext.getString(R.string.android_start_title));
|
||||
mUserManager.onBeforeUnlockUser(userId);
|
||||
uss.mUnlockProgress.setProgress(20);
|
||||
|
||||
// Dispatch unlocked to system services; when fully dispatched,
|
||||
// that calls through to the next "unlocked" phase
|
||||
mHandler.obtainMessage(SYSTEM_USER_UNLOCK_MSG, userId, 0, uss)
|
||||
.sendToTarget();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -962,6 +967,7 @@ final class UserController {
|
||||
|
||||
boolean unlockUserCleared(final int userId, byte[] token, byte[] secret,
|
||||
IProgressListener listener) {
|
||||
UserState uss;
|
||||
synchronized (mService) {
|
||||
// TODO Move this block outside of synchronized if it causes lock contention
|
||||
if (!StorageManager.isUserKeyUnlocked(userId)) {
|
||||
@@ -976,7 +982,7 @@ final class UserController {
|
||||
}
|
||||
// Bail if user isn't actually running, otherwise register the given
|
||||
// listener to watch for unlock progress
|
||||
final UserState uss = mStartedUsers.get(userId);
|
||||
uss = mStartedUsers.get(userId);
|
||||
if (uss == null) {
|
||||
notifyFinished(userId, listener);
|
||||
return false;
|
||||
@@ -984,8 +990,12 @@ final class UserController {
|
||||
uss.mUnlockProgress.addListener(listener);
|
||||
uss.tokenProvided = (token != null);
|
||||
}
|
||||
}
|
||||
|
||||
finishUserUnlocking(uss);
|
||||
finishUserUnlocking(uss);
|
||||
|
||||
final ArraySet<Integer> childProfilesToUnlock = new ArraySet<>();
|
||||
synchronized (mService) {
|
||||
|
||||
// We just unlocked a user, so let's now attempt to unlock any
|
||||
// managed profiles under that user.
|
||||
@@ -995,11 +1005,16 @@ final class UserController {
|
||||
if (parent != null && parent.id == userId && testUserId != userId) {
|
||||
Slog.d(TAG, "User " + testUserId + " (parent " + parent.id
|
||||
+ "): attempting unlock because parent was just unlocked");
|
||||
maybeUnlockUser(testUserId);
|
||||
childProfilesToUnlock.add(testUserId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final int size = childProfilesToUnlock.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
maybeUnlockUser(childProfilesToUnlock.valueAt(i));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user