Fix click and long click lock behavior
Accessibility clicks should unlock the phone and long presses should
disable trust agents.
Fixes: 131059420
Fixes: 130326686
Test: long press with trust agent
Test: double tap with TalkBack on lock screen
Test: double tap with TalkBack on bouncer
Change-Id: Ib2df54c540ebed0adf6c3cbcb82376c02e54d540
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
index 6101593..be0923f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java
@@ -54,7 +54,9 @@
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
import com.android.systemui.statusbar.phone.LockIcon;
import com.android.systemui.statusbar.phone.LockscreenGestureLogger;
+import com.android.systemui.statusbar.phone.ShadeController;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
+import com.android.systemui.statusbar.policy.AccessibilityController;
import com.android.systemui.statusbar.policy.UserInfoController;
import com.android.systemui.util.wakelock.SettableWakeLock;
import com.android.systemui.util.wakelock.WakeLock;
@@ -77,6 +79,8 @@
private static final long TRANSIENT_BIOMETRIC_ERROR_TIMEOUT = 1300;
private final Context mContext;
+ private final ShadeController mShadeController;
+ private final AccessibilityController mAccessibilityController;
private ViewGroup mIndicationArea;
private KeyguardIndicationTextView mTextView;
private KeyguardIndicationTextView mDisclosure;
@@ -116,7 +120,9 @@
public KeyguardIndicationController(Context context, ViewGroup indicationArea,
LockIcon lockIcon) {
this(context, indicationArea, lockIcon, new LockPatternUtils(context),
- WakeLock.createPartial(context, "Doze:KeyguardIndication"));
+ WakeLock.createPartial(context, "Doze:KeyguardIndication"),
+ Dependency.get(ShadeController.class),
+ Dependency.get(AccessibilityController.class));
registerCallbacks(KeyguardUpdateMonitor.getInstance(context));
}
@@ -126,7 +132,8 @@
*/
@VisibleForTesting
KeyguardIndicationController(Context context, ViewGroup indicationArea, LockIcon lockIcon,
- LockPatternUtils lockPatternUtils, WakeLock wakeLock) {
+ LockPatternUtils lockPatternUtils, WakeLock wakeLock, ShadeController shadeController,
+ AccessibilityController accessibilityController) {
mContext = context;
mIndicationArea = indicationArea;
mTextView = indicationArea.findViewById(R.id.keyguard_indication_text);
@@ -134,9 +141,12 @@
mTextView.getTextColors() : ColorStateList.valueOf(Color.WHITE);
mDisclosure = indicationArea.findViewById(R.id.keyguard_indication_enterprise_disclosure);
mLockIcon = lockIcon;
+ mShadeController = shadeController;
+ mAccessibilityController = accessibilityController;
// lock icon is not used on all form factors.
if (mLockIcon != null) {
- mLockIcon.setOnLongClickListener(this::handleTrustCircleClick);
+ mLockIcon.setOnLongClickListener(this::handleLockLongClick);
+ mLockIcon.setOnClickListener(this::handleLockClick);
}
mWakeLock = new SettableWakeLock(wakeLock, TAG);
mLockPatternUtils = lockPatternUtils;
@@ -173,7 +183,7 @@
Dependency.get(StatusBarStateController.class).removeCallback(this);
}
- private boolean handleTrustCircleClick(View view) {
+ private boolean handleLockLongClick(View view) {
mLockscreenGestureLogger.write(MetricsProto.MetricsEvent.ACTION_LS_LOCK,
0 /* lengthDp - N/A */, 0 /* velocityDp - N/A */);
showTransientIndication(R.string.keyguard_indication_trust_disabled);
@@ -182,6 +192,13 @@
return true;
}
+ private void handleLockClick(View view) {
+ if (!mAccessibilityController.isAccessibilityEnabled()) {
+ return;
+ }
+ mShadeController.showBouncer(false /* scrimmed */);
+ }
+
/**
* Gets the {@link KeyguardUpdateMonitorCallback} instance associated with this
* {@link KeyguardIndicationController}.
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java
index 6121ae6..586e82c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LockIcon.java
@@ -248,10 +248,8 @@
boolean canLock = mUnlockMethodCache.isMethodSecure()
&& mUnlockMethodCache.canSkipBouncer();
boolean clickToUnlock = mAccessibilityController.isAccessibilityEnabled();
- boolean clickToForceLock = canLock && !clickToUnlock;
- boolean longClickToForceLock = canLock && !clickToForceLock;
- setClickable(clickToForceLock || clickToUnlock);
- setLongClickable(longClickToForceLock);
+ setClickable(clickToUnlock);
+ setLongClickable(canLock && !clickToUnlock);
setFocusable(mAccessibilityController.isAccessibilityEnabled());
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 3f33ba6..f08d7ed 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -3326,7 +3326,11 @@
@Override
public void showBouncer(boolean scrimmed) {
- mStatusBarKeyguardViewManager.showBouncer(scrimmed);
+ if (!mIsOccluded && !scrimmed && mState == StatusBarState.KEYGUARD) {
+ animateCollapsePanels(CommandQueue.FLAG_EXCLUDE_NONE, true /* force */);
+ } else {
+ mStatusBarKeyguardViewManager.showBouncer(scrimmed);
+ }
}
@Override
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java
index 80c51cf..375b6e5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java
@@ -20,6 +20,8 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
@@ -46,11 +48,14 @@
import com.android.systemui.SysuiTestCase;
import com.android.systemui.statusbar.phone.KeyguardIndicationTextView;
import com.android.systemui.statusbar.phone.LockIcon;
+import com.android.systemui.statusbar.phone.ShadeController;
+import com.android.systemui.statusbar.policy.AccessibilityController;
import com.android.systemui.util.wakelock.WakeLockFake;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -72,6 +77,10 @@
private LockIcon mLockIcon;
@Mock
private LockPatternUtils mLockPatternUtils;
+ @Mock
+ private ShadeController mShadeController;
+ @Mock
+ private AccessibilityController mAccessibilityController;
private KeyguardIndicationTextView mTextView;
private KeyguardIndicationController mController;
@@ -102,7 +111,7 @@
Looper.prepare();
}
mController = new KeyguardIndicationController(mContext, mIndicationArea, mLockIcon,
- mLockPatternUtils, mWakeLock);
+ mLockPatternUtils, mWakeLock, mShadeController, mAccessibilityController);
}
@Test
@@ -222,4 +231,23 @@
assertThat(mTextView.getCurrentTextColor()).isEqualTo(Color.WHITE);
assertThat(mTextView.getAlpha()).isEqualTo(1f);
}
+
+ @Test
+ public void lockIcon_click() {
+ createController();
+
+ ArgumentCaptor<View.OnLongClickListener> longClickCaptor = ArgumentCaptor.forClass(
+ View.OnLongClickListener.class);
+ ArgumentCaptor<View.OnClickListener> clickCaptor = ArgumentCaptor.forClass(
+ View.OnClickListener.class);
+ verify(mLockIcon).setOnLongClickListener(longClickCaptor.capture());
+ verify(mLockIcon).setOnClickListener(clickCaptor.capture());
+
+ when(mAccessibilityController.isAccessibilityEnabled()).thenReturn(true);
+ clickCaptor.getValue().onClick(mLockIcon);
+ verify(mShadeController).showBouncer(eq(false));
+
+ longClickCaptor.getValue().onLongClick(mLockIcon);
+ verify(mLockPatternUtils).requireCredentialEntry(anyInt());
+ }
}