|
31 | 31 | import android.os.Message; |
32 | 32 | import android.os.PowerManager; |
33 | 33 | import android.os.RemoteException; |
| 34 | +import android.os.UserHandle; |
34 | 35 | import android.util.Log; |
35 | 36 | import android.view.View; |
36 | 37 |
|
@@ -214,7 +215,7 @@ public boolean handleMessage(Message msg) { |
214 | 215 | handleServiceDisconnected(); |
215 | 216 | break; |
216 | 217 | case MSG_UNLOCK: |
217 | | - handleUnlock(); |
| 218 | + handleUnlock(msg.arg1); |
218 | 219 | break; |
219 | 220 | case MSG_CANCEL: |
220 | 221 | handleCancel(); |
@@ -297,11 +298,18 @@ void handleServiceDisconnected() { |
297 | 298 | /** |
298 | 299 | * Stops the Face Unlock service and tells the device to grant access to the user. |
299 | 300 | */ |
300 | | - void handleUnlock() { |
| 301 | + void handleUnlock(int authenticatedUserId) { |
301 | 302 | if (DEBUG) Log.d(TAG, "handleUnlock()"); |
302 | 303 | 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 | + } |
305 | 313 | } |
306 | 314 |
|
307 | 315 | /** |
@@ -420,7 +428,8 @@ private void stopUi() { |
420 | 428 | */ |
421 | 429 | public void unlock() { |
422 | 430 | 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); |
424 | 433 | } |
425 | 434 |
|
426 | 435 | /** |
|
0 commit comments