From 657f88516ab3c8e5f0f56534c1ab43819ece37fa Mon Sep 17 00:00:00 2001 From: Toni Barzic Date: Thu, 4 Feb 2016 15:14:49 -0800 Subject: [PATCH] Try to dismiss Keyguard bypassing bouncer only for active users Some bouncers might allow showing keyguards for users that are not currently active (e.g. before any user is signed in, in which case the system user is active). Make sure that keyguard is not dismissed without showing bouncer in these cases. Change-Id: I0e037b2d4e095d49c1f0d06a9fe1b9a6233421b0 (cherry picked from commit aa69fd417f32435d7d7c06f8d033efa7fa21475a) --- .../statusbar/phone/KeyguardBouncer.java | 30 ++++++++++++++----- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java index b9e1ad2e41c21..aecef140d2bf3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java @@ -16,7 +16,10 @@ package com.android.systemui.statusbar.phone; +import android.app.ActivityManager; import android.content.Context; +import android.os.UserHandle; +import android.util.Slog; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; @@ -42,6 +45,8 @@ import static com.android.keyguard.KeyguardSecurityModel.SecurityMode; */ public class KeyguardBouncer { + final static private String TAG = "KeyguardBouncer"; + protected Context mContext; protected ViewMediatorCallback mCallback; protected LockPatternUtils mLockPatternUtils; @@ -84,14 +89,25 @@ public class KeyguardBouncer { return; } - // Try to dismiss the Keyguard. If no security pattern is set, this will dismiss the whole - // Keyguard. If we need to authenticate, show the bouncer. - if (!mKeyguardView.dismiss()) { - mShowingSoon = true; - - // Split up the work over multiple frames. - DejankUtils.postAfterTraversal(mShowRunnable); + final int activeUserId = ActivityManager.getCurrentUser(); + final int keyguardUserId = KeyguardUpdateMonitor.getCurrentUser(); + final boolean allowDismissKeyguard = activeUserId != UserHandle.USER_SYSTEM + && activeUserId == keyguardUserId; + // If allowed, try to dismiss the Keyguard. If no security auth (password/pin/pattern) is + // set, this will dismiss the whole Keyguard. Otherwise, show the bouncer. + if (allowDismissKeyguard && mKeyguardView.dismiss()) { + return; } + + // This condition may indicate an error on Android, so log it. + if (!allowDismissKeyguard) { + Slog.w(TAG, "User can't dismiss keyguard: " + activeUserId + " != " + keyguardUserId); + } + + mShowingSoon = true; + + // Split up the work over multiple frames. + DejankUtils.postAfterTraversal(mShowRunnable); } private final Runnable mShowRunnable = new Runnable() {