Merge "Call unlockUserKey in a synchronized section" into nyc-dev

am: 735fa43314

* commit '735fa43314b3779df4af15cc679d00aa9de9c14c':
  Call unlockUserKey in a synchronized section

Change-Id: Ie168a80aaa2385c989067b04a4a54d0fdde277d2
This commit is contained in:
Fyodor Kupolov
2016-05-04 23:15:21 +00:00
committed by android-build-merger

View File

@@ -927,32 +927,30 @@ final class UserController {
boolean unlockUserCleared(final int userId, byte[] token, byte[] secret,
IProgressListener listener) {
final UserState uss;
synchronized (mService) {
// Bail if user isn't actually running, otherwise register the given
// listener to watch for unlock progress
uss = mStartedUsers.get(userId);
final UserState uss = mStartedUsers.get(userId);
if (uss == null) {
notifyFinished(userId, listener);
return false;
} else {
uss.mUnlockProgress.addListener(listener);
}
}
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;
// 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;
}
}
}
synchronized (mService) {
finishUserUnlocking(uss);
// We just unlocked a user, so let's now attempt to unlock any