Skip to content

Commit 5eb83aa

Browse files
author
Brian Colonna
committed
Ignoring FUL unlock signal if user changed fixes b/7572354
Prior to this fix, one user could log into another user's account by waiting for FUL to recognize them on their account, and then switching to another account at a very precise time - after FUL has recognized the user but before the device has unlocked. This was caused by the FUL unlock() callback telling the device to unlock even though the user had changed. The fix is to only unlock the device if the current user ID matches the user ID used to run FUL. Change-Id: I516b52d99ab7609b836939e4aae6e7df77a9e047
1 parent 2656abe commit 5eb83aa

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

policy/src/com/android/internal/policy/impl/keyguard/FaceUnlock.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import android.os.Message;
3232
import android.os.PowerManager;
3333
import android.os.RemoteException;
34+
import android.os.UserHandle;
3435
import android.util.Log;
3536
import android.view.View;
3637

@@ -214,7 +215,7 @@ public boolean handleMessage(Message msg) {
214215
handleServiceDisconnected();
215216
break;
216217
case MSG_UNLOCK:
217-
handleUnlock();
218+
handleUnlock(msg.arg1);
218219
break;
219220
case MSG_CANCEL:
220221
handleCancel();
@@ -297,11 +298,18 @@ void handleServiceDisconnected() {
297298
/**
298299
* Stops the Face Unlock service and tells the device to grant access to the user.
299300
*/
300-
void handleUnlock() {
301+
void handleUnlock(int authenticatedUserId) {
301302
if (DEBUG) Log.d(TAG, "handleUnlock()");
302303
stop();
303-
mKeyguardScreenCallback.reportSuccessfulUnlockAttempt();
304-
mKeyguardScreenCallback.dismiss(true);
304+
int currentUserId = mLockPatternUtils.getCurrentUser();
305+
if (authenticatedUserId == currentUserId) {
306+
if (DEBUG) Log.d(TAG, "Unlocking for user " + authenticatedUserId);
307+
mKeyguardScreenCallback.reportSuccessfulUnlockAttempt();
308+
mKeyguardScreenCallback.dismiss(true);
309+
} else {
310+
Log.d(TAG, "Ignoring unlock for authenticated user (" + authenticatedUserId +
311+
") because the current user is " + currentUserId);
312+
}
305313
}
306314

307315
/**
@@ -420,7 +428,8 @@ private void stopUi() {
420428
*/
421429
public void unlock() {
422430
if (DEBUG) Log.d(TAG, "unlock()");
423-
mHandler.sendEmptyMessage(MSG_UNLOCK);
431+
Message message = mHandler.obtainMessage(MSG_UNLOCK, UserHandle.getCallingUserId(), -1);
432+
mHandler.sendMessage(message);
424433
}
425434

426435
/**

0 commit comments

Comments
 (0)