From dfc2156e39b2ac666e27b74b2d20610b88ebf635 Mon Sep 17 00:00:00 2001 From: Aaron Liu Date: Wed, 31 Aug 2022 13:45:53 -0700 Subject: [PATCH] [Bouncer] Separate keyguard message areas. Separate keyguard message area between bouncer and alt bouncer. Ensure that the separation is clear and understandable. Insert keyguard message area for bouncer into the security view so the layout is better. Fixes: 242186543, 240328688 Test: Add unit tests and tested on multiple devices and view modes. Change-Id: Iff34f1ebe108649c454691d14054072af46bfad8 --- .../layout/keyguard_bouncer_message_area.xml | 28 ++++++++ .../layout/keyguard_password_view.xml | 1 + .../layout/keyguard_pattern_view.xml | 1 + .../res-keyguard/layout/keyguard_pin_view.xml | 3 +- .../layout/keyguard_sim_pin_view.xml | 17 ++--- .../layout/keyguard_sim_puk_view.xml | 10 +-- .../res/layout/super_notification_shade.xml | 2 +- .../res/values-sw720dp-port/dimens.xml | 2 +- .../keyguard/AuthKeyguardMessageArea.kt | 33 +++++++++ .../keyguard/BouncerKeyguardMessageArea.kt | 61 ++++++++++++++++ .../KeyguardAbsKeyInputViewController.java | 11 +-- .../keyguard/KeyguardInputViewController.java | 17 ++++- .../android/keyguard/KeyguardMessageArea.java | 69 +++---------------- .../KeyguardMessageAreaController.java | 24 +++---- .../android/keyguard/KeyguardPatternView.java | 4 +- .../KeyguardPatternViewController.java | 13 ++-- .../keyguard/KeyguardSecurityContainer.java | 4 +- ...KeyguardSecurityViewFlipperController.java | 3 +- .../keyguard/SecurityMessageDisplay.java | 3 +- ...NotificationShadeWindowViewController.java | 8 +++ .../KeyguardIndicationController.java | 6 +- .../statusbar/phone/CentralSurfaces.java | 4 ++ .../statusbar/phone/CentralSurfacesImpl.java | 6 ++ .../phone/StatusBarKeyguardViewManager.java | 13 ++-- ....java => AuthKeyguardMessageAreaTest.java} | 8 +-- ...KeyguardAbsKeyInputViewControllerTest.java | 4 +- .../KeyguardMessageAreaControllerTest.java | 4 +- .../KeyguardPasswordViewControllerTest.kt | 8 ++- .../KeyguardPatternViewControllerTest.kt | 8 ++- ...yguardPinBasedInputViewControllerTest.java | 4 +- ...yguardSecurityContainerControllerTest.java | 8 ++- ...tificationShadeWindowViewControllerTest.kt | 14 ++++ .../KeyguardIndicationControllerTest.java | 2 +- 33 files changed, 261 insertions(+), 142 deletions(-) create mode 100644 packages/SystemUI/res-keyguard/layout/keyguard_bouncer_message_area.xml create mode 100644 packages/SystemUI/src/com/android/keyguard/AuthKeyguardMessageArea.kt create mode 100644 packages/SystemUI/src/com/android/keyguard/BouncerKeyguardMessageArea.kt rename packages/SystemUI/tests/src/com/android/keyguard/{KeyguardMessageAreaTest.java => AuthKeyguardMessageAreaTest.java} (90%) diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_bouncer_message_area.xml b/packages/SystemUI/res-keyguard/layout/keyguard_bouncer_message_area.xml new file mode 100644 index 0000000000000..57b3acd6557ab --- /dev/null +++ b/packages/SystemUI/res-keyguard/layout/keyguard_bouncer_message_area.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_password_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_password_view.xml index e77e084c48e8f..5486adbd2b8ed 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_password_view.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_password_view.xml @@ -28,6 +28,7 @@ android:layout_gravity="center_horizontal|bottom" android:gravity="bottom" > + + + - - - - - + + - - - - - diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_sim_puk_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_sim_puk_view.xml index 74f78201e6776..a21ec29267fe6 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_sim_puk_view.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_sim_puk_view.xml @@ -27,12 +27,12 @@ android:layout_height="match_parent" androidprv:layout_maxWidth="@dimen/keyguard_security_width" android:layout_gravity="center_horizontal|bottom"> + - + - 124dp 80dp 80dp - 90dp + 200dp 24dp 40dp diff --git a/packages/SystemUI/src/com/android/keyguard/AuthKeyguardMessageArea.kt b/packages/SystemUI/src/com/android/keyguard/AuthKeyguardMessageArea.kt new file mode 100644 index 0000000000000..82ce1ca3bbb43 --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/AuthKeyguardMessageArea.kt @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.keyguard + +import android.content.Context +import android.content.res.ColorStateList +import android.graphics.Color +import android.util.AttributeSet + +/** + * Displays security messages for auth outside of the security method (pin, password, pattern), like + * biometric auth. + */ +class AuthKeyguardMessageArea(context: Context?, attrs: AttributeSet?) : + KeyguardMessageArea(context, attrs) { + override fun updateTextColor() { + setTextColor(ColorStateList.valueOf(Color.WHITE)) + } +} diff --git a/packages/SystemUI/src/com/android/keyguard/BouncerKeyguardMessageArea.kt b/packages/SystemUI/src/com/android/keyguard/BouncerKeyguardMessageArea.kt new file mode 100644 index 0000000000000..0075ddd73cd36 --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/BouncerKeyguardMessageArea.kt @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.keyguard + +import android.content.Context +import android.content.res.ColorStateList +import android.content.res.TypedArray +import android.graphics.Color +import android.util.AttributeSet +import com.android.settingslib.Utils + +/** Displays security messages for the keyguard bouncer. */ +class BouncerKeyguardMessageArea(context: Context?, attrs: AttributeSet?) : + KeyguardMessageArea(context, attrs) { + private val DEFAULT_COLOR = -1 + private var mDefaultColorState: ColorStateList? = null + private var mNextMessageColorState: ColorStateList? = ColorStateList.valueOf(DEFAULT_COLOR) + + override fun updateTextColor() { + var colorState = mDefaultColorState + mNextMessageColorState?.defaultColor?.let { color -> + if (color != DEFAULT_COLOR) { + colorState = mNextMessageColorState + mNextMessageColorState = ColorStateList.valueOf(DEFAULT_COLOR) + } + } + setTextColor(colorState) + } + + override fun setNextMessageColor(colorState: ColorStateList?) { + mNextMessageColorState = colorState + } + + override fun onThemeChanged() { + val array: TypedArray = + mContext.obtainStyledAttributes(intArrayOf(android.R.attr.textColorPrimary)) + val newTextColors: ColorStateList = ColorStateList.valueOf(array.getColor(0, Color.RED)) + array.recycle() + mDefaultColorState = newTextColors + super.onThemeChanged() + } + + override fun reloadColor() { + mDefaultColorState = Utils.getColorAttr(context, android.R.attr.textColorPrimary) + super.reloadColor() + } +} diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java index b8fcb103402d6..92ba619e7eb92 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardAbsKeyInputViewController.java @@ -50,7 +50,6 @@ public abstract class KeyguardAbsKeyInputViewController mPendingLockCheck; protected boolean mResumed; @@ -80,14 +79,13 @@ public abstract class KeyguardAbsKeyInputViewController private final EmergencyButton mEmergencyButton; private final EmergencyButtonController mEmergencyButtonController; private boolean mPaused; + protected KeyguardMessageAreaController mMessageAreaController; // The following is used to ignore callbacks from SecurityViews that are no longer current // (e.g. face unlock). This avoids unwanted asynchronous events from messing with the @@ -71,12 +74,24 @@ public abstract class KeyguardInputViewController protected KeyguardInputViewController(T view, SecurityMode securityMode, KeyguardSecurityCallback keyguardSecurityCallback, - EmergencyButtonController emergencyButtonController) { + EmergencyButtonController emergencyButtonController, + @Nullable KeyguardMessageAreaController.Factory messageAreaControllerFactory) { super(view); mSecurityMode = securityMode; mKeyguardSecurityCallback = keyguardSecurityCallback; mEmergencyButton = view == null ? null : view.findViewById(R.id.emergency_call_button); mEmergencyButtonController = emergencyButtonController; + if (messageAreaControllerFactory != null) { + try { + BouncerKeyguardMessageArea kma = view.requireViewById(R.id.bouncer_message_area); + mMessageAreaController = messageAreaControllerFactory.create(kma); + mMessageAreaController.init(); + mMessageAreaController.setIsVisible(true); + } catch (IllegalArgumentException exception) { + Log.e("KeyguardInputViewController", + "Ensure that a BouncerKeyguardMessageArea is included in the layout"); + } + } } @Override diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java index 5ab2fd0aff09c..c79fc2c27f0e1 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageArea.java @@ -17,9 +17,7 @@ package com.android.keyguard; import android.content.Context; -import android.content.res.ColorStateList; import android.content.res.TypedArray; -import android.graphics.Color; import android.os.Handler; import android.os.Looper; import android.os.SystemClock; @@ -33,7 +31,6 @@ import android.widget.TextView; import androidx.annotation.Nullable; import com.android.internal.policy.SystemBarUtils; -import com.android.settingslib.Utils; import com.android.systemui.R; import java.lang.ref.WeakReference; @@ -41,7 +38,7 @@ import java.lang.ref.WeakReference; /*** * Manages a number of views inside of the given layout. See below for a list of widgets. */ -public class KeyguardMessageArea extends TextView implements SecurityMessageDisplay { +public abstract class KeyguardMessageArea extends TextView implements SecurityMessageDisplay { /** Handler token posted with accessibility announcement runnables. */ private static final Object ANNOUNCE_TOKEN = new Object(); @@ -50,15 +47,11 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp * lift-to-type from interrupting itself. */ private static final long ANNOUNCEMENT_DELAY = 250; - private static final int DEFAULT_COLOR = -1; private final Handler mHandler; - private ColorStateList mDefaultColorState; private CharSequence mMessage; - private ColorStateList mNextMessageColorState = ColorStateList.valueOf(DEFAULT_COLOR); - private boolean mBouncerShowing; - private boolean mAltBouncerShowing; + private boolean mIsVisible; /** * Container that wraps the KeyguardMessageArea - may be null if current view hierarchy doesn't * contain {@link R.id.keyguard_message_area_container}. @@ -96,23 +89,11 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp mContainer.setLayoutParams(lp); } - @Override - public void setNextMessageColor(ColorStateList colorState) { - mNextMessageColorState = colorState; - } - - void onThemeChanged() { - TypedArray array = mContext.obtainStyledAttributes(new int[] { - android.R.attr.textColorPrimary - }); - ColorStateList newTextColors = ColorStateList.valueOf(array.getColor(0, Color.RED)); - array.recycle(); - mDefaultColorState = newTextColors; + protected void onThemeChanged() { update(); } - void reloadColor() { - mDefaultColorState = Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary); + protected void reloadColor() { update(); } @@ -151,17 +132,6 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp setMessage(message); } - public static KeyguardMessageArea findSecurityMessageDisplay(View v) { - KeyguardMessageArea messageArea = v.findViewById(R.id.keyguard_message_area); - if (messageArea == null) { - messageArea = v.getRootView().findViewById(R.id.keyguard_message_area); - } - if (messageArea == null) { - throw new RuntimeException("Can't find keyguard_message_area in " + v.getClass()); - } - return messageArea; - } - private void securityMessageChanged(CharSequence message) { mMessage = message; update(); @@ -177,40 +147,23 @@ public class KeyguardMessageArea extends TextView implements SecurityMessageDisp void update() { CharSequence status = mMessage; - setVisibility(TextUtils.isEmpty(status) || (!mBouncerShowing && !mAltBouncerShowing) - ? INVISIBLE : VISIBLE); + setVisibility(TextUtils.isEmpty(status) || (!mIsVisible) ? INVISIBLE : VISIBLE); setText(status); - ColorStateList colorState = mDefaultColorState; - if (mNextMessageColorState.getDefaultColor() != DEFAULT_COLOR) { - colorState = mNextMessageColorState; - mNextMessageColorState = ColorStateList.valueOf(DEFAULT_COLOR); - } - if (mAltBouncerShowing) { - // alt bouncer has a black scrim, so always show the text in white - colorState = ColorStateList.valueOf(Color.WHITE); - } - setTextColor(colorState); + updateTextColor(); } /** * Set whether the bouncer is fully showing */ - public void setBouncerShowing(boolean bouncerShowing) { - if (mBouncerShowing != bouncerShowing) { - mBouncerShowing = bouncerShowing; + public void setIsVisible(boolean isVisible) { + if (mIsVisible != isVisible) { + mIsVisible = isVisible; update(); } } - /** - * Set whether the alt bouncer is showing - */ - void setAltBouncerShowing(boolean showing) { - if (mAltBouncerShowing != showing) { - mAltBouncerShowing = showing; - update(); - } - } + /** Set the text color */ + protected abstract void updateTextColor(); /** * Runnable used to delay accessibility announcements. diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java index 3ec8ce918a4d7..c2802f7b68434 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardMessageAreaController.java @@ -26,11 +26,14 @@ import com.android.systemui.util.ViewController; import javax.inject.Inject; -/** Controller for a {@link KeyguardMessageAreaController}. */ -public class KeyguardMessageAreaController extends ViewController { +/** + * Controller for a {@link KeyguardMessageAreaController}. + * @param A subclass of KeyguardMessageArea. + */ +public class KeyguardMessageAreaController + extends ViewController { private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final ConfigurationController mConfigurationController; - private boolean mAltBouncerShowing; private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() { public void onFinishedGoingToSleep(int why) { @@ -59,7 +62,7 @@ public class KeyguardMessageAreaController extends ViewController mView.onDevicePostureChanged(posture); - - private KeyguardMessageAreaController mMessageAreaController; private LockPatternView mLockPatternView; private CountDownTimer mCountdownTimer; private AsyncTask mPendingLockCheck; @@ -201,15 +198,13 @@ public class KeyguardPatternViewController EmergencyButtonController emergencyButtonController, KeyguardMessageAreaController.Factory messageAreaControllerFactory, DevicePostureController postureController) { - super(view, securityMode, keyguardSecurityCallback, emergencyButtonController); + super(view, securityMode, keyguardSecurityCallback, emergencyButtonController, + messageAreaControllerFactory); mKeyguardUpdateMonitor = keyguardUpdateMonitor; mLockPatternUtils = lockPatternUtils; mLatencyTracker = latencyTracker; mFalsingCollector = falsingCollector; mEmergencyButtonController = emergencyButtonController; - mMessageAreaControllerFactory = messageAreaControllerFactory; - KeyguardMessageArea kma = KeyguardMessageArea.findSecurityMessageDisplay(mView); - mMessageAreaController = mMessageAreaControllerFactory.create(kma); mLockPatternView = mView.findViewById(R.id.lockPatternView); mPostureController = postureController; } @@ -217,7 +212,6 @@ public class KeyguardPatternViewController @Override public void onInit() { super.onInit(); - mMessageAreaController.init(); } @Override @@ -346,6 +340,9 @@ public class KeyguardPatternViewController @Override public void showMessage(CharSequence message, ColorStateList colorState) { + if (mMessageAreaController == null) { + return; + } if (colorState != null) { mMessageAreaController.setNextMessageColor(colorState); } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java index d0baf3dad79da..f73c98e4971b2 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -665,7 +665,8 @@ public class KeyguardSecurityContainer extends FrameLayout { // When using EXACTLY spec, measure will use the layout width if > 0. Set before // measuring the child lp.width = MeasureSpec.getSize(updatedWidthMeasureSpec); - measureChildWithMargins(view, updatedWidthMeasureSpec, 0, heightMeasureSpec, 0); + measureChildWithMargins(view, updatedWidthMeasureSpec, 0, + heightMeasureSpec, 0); maxWidth = Math.max(maxWidth, view.getMeasuredWidth() + lp.leftMargin + lp.rightMargin); @@ -1306,7 +1307,6 @@ public class KeyguardSecurityContainer extends FrameLayout { int yTrans = mResources.getDimensionPixelSize(R.dimen.bouncer_user_switcher_y_trans); if (mResources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { mUserSwitcherViewGroup.setTranslationY(yTrans); - mViewFlipper.setTranslationY(-yTrans); } else { // Attempt to reposition a bit higher to make up for this frame being a bit lower // on the device diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java index 51b68b72da30d..bddf4b09ebb3d 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java @@ -146,7 +146,8 @@ public class KeyguardSecurityViewFlipperController protected NullKeyguardInputViewController(SecurityMode securityMode, KeyguardSecurityCallback keyguardSecurityCallback, EmergencyButtonController emergencyButtonController) { - super(null, securityMode, keyguardSecurityCallback, emergencyButtonController); + super(null, securityMode, keyguardSecurityCallback, emergencyButtonController, + null); } @Override diff --git a/packages/SystemUI/src/com/android/keyguard/SecurityMessageDisplay.java b/packages/SystemUI/src/com/android/keyguard/SecurityMessageDisplay.java index 7c86a1dfb7971..777bd19864bf0 100644 --- a/packages/SystemUI/src/com/android/keyguard/SecurityMessageDisplay.java +++ b/packages/SystemUI/src/com/android/keyguard/SecurityMessageDisplay.java @@ -20,7 +20,8 @@ import android.content.res.ColorStateList; public interface SecurityMessageDisplay { - void setNextMessageColor(ColorStateList colorState); + /** Set text color for the next security message. */ + default void setNextMessageColor(ColorStateList colorState) {} void setMessage(CharSequence msg); diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java index e93f60596280b..abafecce29653 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationShadeWindowViewController.java @@ -29,6 +29,7 @@ import android.view.View; import android.view.ViewGroup; import com.android.internal.annotations.VisibleForTesting; +import com.android.keyguard.AuthKeyguardMessageArea; import com.android.keyguard.LockIconViewController; import com.android.systemui.R; import com.android.systemui.classifier.FalsingCollector; @@ -138,6 +139,13 @@ public class NotificationShadeWindowViewController { return mView.findViewById(R.id.keyguard_bouncer_container); } + /** + * @return Location where to place the KeyguardMessageArea + */ + public AuthKeyguardMessageArea getKeyguardMessageArea() { + return mView.findViewById(R.id.keyguard_message_area); + } + /** Inflates the {@link R.layout#status_bar_expanded} layout and sets it up. */ public void setupExpandedStatusBar() { mStackScrollLayout = mView.findViewById(R.id.notification_stack_scroller); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java index 2251ab5460d5e..cf5b2d1ae6214 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/KeyguardIndicationController.java @@ -932,7 +932,7 @@ public class KeyguardIndicationController { return; // udfps affordance is highlighted, no need to show action to unlock } else if (mKeyguardUpdateMonitor.isFaceEnrolled()) { String message = mContext.getString(R.string.keyguard_retry); - mStatusBarKeyguardViewManager.showBouncerMessage(message, mInitialTextColorState); + mStatusBarKeyguardViewManager.setKeyguardMessage(message, mInitialTextColorState); } } else { final boolean canSkipBouncer = mKeyguardUpdateMonitor.getUserCanSkipBouncer( @@ -1080,7 +1080,7 @@ public class KeyguardIndicationController { } return; } else if (mStatusBarKeyguardViewManager.isBouncerShowing()) { - mStatusBarKeyguardViewManager.showBouncerMessage(helpString, + mStatusBarKeyguardViewManager.setKeyguardMessage(helpString, mInitialTextColorState); } else if (mScreenLifecycle.getScreenState() == SCREEN_ON) { if (isCoExFaceAcquisitionMessage && msgId == FACE_ACQUIRED_TOO_DARK) { @@ -1155,7 +1155,7 @@ public class KeyguardIndicationController { showActionToUnlock(); } } else if (mStatusBarKeyguardViewManager.isBouncerShowing()) { - mStatusBarKeyguardViewManager.showBouncerMessage(errString, mInitialTextColorState); + mStatusBarKeyguardViewManager.setKeyguardMessage(errString, mInitialTextColorState); } else if (mScreenLifecycle.getScreenState() == SCREEN_ON) { showBiometricMessage(errString); } else { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java index 20b6d0b49fbc4..4c0764ebd3141 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java @@ -40,6 +40,7 @@ import androidx.lifecycle.LifecycleOwner; import com.android.internal.annotations.VisibleForTesting; import com.android.internal.statusbar.RegisterStatusBarResult; +import com.android.keyguard.AuthKeyguardMessageArea; import com.android.keyguard.FaceAuthApiRequestReason; import com.android.systemui.Dumpable; import com.android.systemui.animation.ActivityLaunchAnimator; @@ -220,6 +221,9 @@ public interface CentralSurfaces extends Dumpable, ActivityStarter, LifecycleOwn ViewGroup getBouncerContainer(); + /** Get the Keyguard Message Area that displays auth messages. */ + AuthKeyguardMessageArea getKeyguardMessageArea(); + int getStatusBarHeight(); void updateQsExpansionEnabled(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 6426aef43799a..7158fd9455ce9 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -120,6 +120,7 @@ import com.android.internal.logging.UiEventLoggerImpl; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.statusbar.IStatusBarService; import com.android.internal.statusbar.RegisterStatusBarResult; +import com.android.keyguard.AuthKeyguardMessageArea; import com.android.keyguard.FaceAuthApiRequestReason; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; @@ -1581,6 +1582,11 @@ public class CentralSurfacesImpl extends CoreStartable implements return mNotificationShadeWindowViewController.getBouncerContainer(); } + @Override + public AuthKeyguardMessageArea getKeyguardMessageArea() { + return mNotificationShadeWindowViewController.getKeyguardMessageArea(); + } + @Override public int getStatusBarHeight() { return mStatusBarWindowController.getStatusBarHeight(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index f106e54a091b4..c0c385b6251eb 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -44,7 +44,7 @@ import androidx.annotation.VisibleForTesting; import com.android.internal.util.LatencyTracker; import com.android.internal.widget.LockPatternUtils; -import com.android.keyguard.KeyguardMessageArea; +import com.android.keyguard.AuthKeyguardMessageArea; import com.android.keyguard.KeyguardMessageAreaController; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; @@ -122,7 +122,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private final DreamOverlayStateController mDreamOverlayStateController; @Nullable private final FoldAodAnimationController mFoldAodAnimationController; - private KeyguardMessageAreaController mKeyguardMessageAreaController; + private KeyguardMessageAreaController mKeyguardMessageAreaController; private final Lazy mShadeController; private final BouncerExpansionCallback mExpansionCallback = new BouncerExpansionCallback() { @@ -311,7 +311,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mBypassController = bypassController; mNotificationContainer = notificationContainer; mKeyguardMessageAreaController = mKeyguardMessageAreaFactory.create( - KeyguardMessageArea.findSecurityMessageDisplay(container)); + centralSurfaces.getKeyguardMessageArea()); registerListeners(); } @@ -616,7 +616,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private void updateAlternateAuthShowing(boolean updateScrim) { final boolean isShowingAltAuth = isShowingAlternateAuth(); if (mKeyguardMessageAreaController != null) { - mKeyguardMessageAreaController.setAltBouncerShowing(isShowingAltAuth); + mKeyguardMessageAreaController.setIsVisible(isShowingAltAuth); + mKeyguardMessageAreaController.setMessage(""); } mBypassController.setAltBouncerShowing(isShowingAltAuth); mKeyguardUpdateManager.setUdfpsBouncerShowing(isShowingAltAuth); @@ -1043,7 +1044,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb if (bouncerShowing != mLastBouncerShowing || mFirstUpdate) { mNotificationShadeWindowController.setBouncerShowing(bouncerShowing); mCentralSurfaces.setBouncerShowing(bouncerShowing); - mKeyguardMessageAreaController.setBouncerShowing(bouncerShowing); } if (occluded != mLastOccluded || mFirstUpdate) { @@ -1192,7 +1192,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb } } - public void showBouncerMessage(String message, ColorStateList colorState) { + /** Display security message to relevant KeyguardMessageArea. */ + public void setKeyguardMessage(String message, ColorStateList colorState) { if (isShowingAlternateAuth()) { if (mKeyguardMessageAreaController != null) { mKeyguardMessageAreaController.setMessage(message); diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardMessageAreaTest.java b/packages/SystemUI/tests/src/com/android/keyguard/AuthKeyguardMessageAreaTest.java similarity index 90% rename from packages/SystemUI/tests/src/com/android/keyguard/KeyguardMessageAreaTest.java rename to packages/SystemUI/tests/src/com/android/keyguard/AuthKeyguardMessageAreaTest.java index 013c298d69d79..0a9c745525c2d 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardMessageAreaTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/AuthKeyguardMessageAreaTest.java @@ -33,14 +33,14 @@ import org.mockito.MockitoAnnotations; @SmallTest @RunWith(AndroidTestingRunner.class) @RunWithLooper -public class KeyguardMessageAreaTest extends SysuiTestCase { +public class AuthKeyguardMessageAreaTest extends SysuiTestCase { private KeyguardMessageArea mKeyguardMessageArea; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); - mKeyguardMessageArea = new KeyguardMessageArea(mContext, null); - mKeyguardMessageArea.setBouncerShowing(true); + mKeyguardMessageArea = new AuthKeyguardMessageArea(mContext, null); + mKeyguardMessageArea.setIsVisible(true); } @Test @@ -53,7 +53,7 @@ public class KeyguardMessageAreaTest extends SysuiTestCase { @Test public void testHiddenWhenBouncerHidden() { - mKeyguardMessageArea.setBouncerShowing(false); + mKeyguardMessageArea.setIsVisible(false); mKeyguardMessageArea.setVisibility(View.INVISIBLE); mKeyguardMessageArea.setMessage("oobleck"); assertThat(mKeyguardMessageArea.getVisibility()).isEqualTo(View.INVISIBLE); diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardAbsKeyInputViewControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardAbsKeyInputViewControllerTest.java index 90f7fda696638..8bbaf3dff1e50 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardAbsKeyInputViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardAbsKeyInputViewControllerTest.java @@ -56,7 +56,7 @@ public class KeyguardAbsKeyInputViewControllerTest extends SysuiTestCase { @Mock private PasswordTextView mPasswordEntry; @Mock - private KeyguardMessageArea mKeyguardMessageArea; + private BouncerKeyguardMessageArea mKeyguardMessageArea; @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Mock @@ -85,7 +85,7 @@ public class KeyguardAbsKeyInputViewControllerTest extends SysuiTestCase { when(mAbsKeyInputView.getPasswordTextViewId()).thenReturn(1); when(mAbsKeyInputView.findViewById(1)).thenReturn(mPasswordEntry); when(mAbsKeyInputView.isAttachedToWindow()).thenReturn(true); - when(mAbsKeyInputView.findViewById(R.id.keyguard_message_area)) + when(mAbsKeyInputView.requireViewById(R.id.bouncer_message_area)) .thenReturn(mKeyguardMessageArea); mKeyguardAbsKeyInputViewController = new KeyguardAbsKeyInputViewController(mAbsKeyInputView, mKeyguardUpdateMonitor, mSecurityMode, mLockPatternUtils, mKeyguardSecurityCallback, diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardMessageAreaControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardMessageAreaControllerTest.java index 8293cc21f3d1c..69524e5a4537d 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardMessageAreaControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardMessageAreaControllerTest.java @@ -89,8 +89,8 @@ public class KeyguardMessageAreaControllerTest extends SysuiTestCase { @Test public void testSetBouncerVisible() { - mMessageAreaController.setBouncerShowing(true); - verify(mKeyguardMessageArea).setBouncerShowing(true); + mMessageAreaController.setIsVisible(true); + verify(mKeyguardMessageArea).setIsVisible(true); } @Test diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPasswordViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPasswordViewControllerTest.kt index ec856031c23c8..b89dbd98968af 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPasswordViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPasswordViewControllerTest.kt @@ -64,9 +64,10 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() { @Mock lateinit var keyguardViewController: KeyguardViewController @Mock - private lateinit var mKeyguardMessageArea: KeyguardMessageArea + private lateinit var mKeyguardMessageArea: BouncerKeyguardMessageArea @Mock - private lateinit var mKeyguardMessageAreaController: KeyguardMessageAreaController + private lateinit var mKeyguardMessageAreaController: + KeyguardMessageAreaController private lateinit var keyguardPasswordViewController: KeyguardPasswordViewController @@ -74,7 +75,8 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() { fun setup() { MockitoAnnotations.initMocks(this) Mockito.`when`( - keyguardPasswordView.findViewById(R.id.keyguard_message_area) + keyguardPasswordView + .requireViewById(R.id.bouncer_message_area) ).thenReturn(mKeyguardMessageArea) Mockito.`when`(messageAreaControllerFactory.create(mKeyguardMessageArea)) .thenReturn(mKeyguardMessageAreaController) diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPatternViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPatternViewControllerTest.kt index 616a1056d161a..3262a77b7711f 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPatternViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPatternViewControllerTest.kt @@ -66,10 +66,11 @@ class KeyguardPatternViewControllerTest : SysuiTestCase() { var mKeyguardMessageAreaControllerFactory: KeyguardMessageAreaController.Factory @Mock - private lateinit var mKeyguardMessageArea: KeyguardMessageArea + private lateinit var mKeyguardMessageArea: BouncerKeyguardMessageArea @Mock - private lateinit var mKeyguardMessageAreaController: KeyguardMessageAreaController + private lateinit var mKeyguardMessageAreaController: + KeyguardMessageAreaController @Mock private lateinit var mLockPatternView: LockPatternView @@ -83,7 +84,8 @@ class KeyguardPatternViewControllerTest : SysuiTestCase() { fun setup() { MockitoAnnotations.initMocks(this) `when`(mKeyguardPatternView.isAttachedToWindow).thenReturn(true) - `when`(mKeyguardPatternView.findViewById(R.id.keyguard_message_area)) + `when`(mKeyguardPatternView + .requireViewById(R.id.bouncer_message_area)) .thenReturn(mKeyguardMessageArea) `when`(mKeyguardPatternView.findViewById(R.id.lockPatternView)) .thenReturn(mLockPatternView) diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewControllerTest.java index 7bc8e8a722f08..97d556b04aa4c 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardPinBasedInputViewControllerTest.java @@ -51,7 +51,7 @@ public class KeyguardPinBasedInputViewControllerTest extends SysuiTestCase { @Mock private PasswordTextView mPasswordEntry; @Mock - private KeyguardMessageArea mKeyguardMessageArea; + private BouncerKeyguardMessageArea mKeyguardMessageArea; @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Mock @@ -90,7 +90,7 @@ public class KeyguardPinBasedInputViewControllerTest extends SysuiTestCase { when(mPinBasedInputView.findViewById(1)).thenReturn(mPasswordEntry); when(mPinBasedInputView.isAttachedToWindow()).thenReturn(true); when(mPinBasedInputView.getButtons()).thenReturn(mButtons); - when(mPinBasedInputView.findViewById(R.id.keyguard_message_area)) + when(mPinBasedInputView.requireViewById(R.id.bouncer_message_area)) .thenReturn(mKeyguardMessageArea); when(mPinBasedInputView.findViewById(R.id.delete_button)) .thenReturn(mDeleteButton); diff --git a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java index d68e8bd36c40c..c6ebaa8bb46c8 100644 --- a/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/keyguard/KeyguardSecurityContainerControllerTest.java @@ -41,6 +41,7 @@ import android.content.res.Resources; import android.hardware.biometrics.BiometricSourceType; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; +import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.WindowInsetsController; @@ -117,7 +118,7 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase { @Mock private KeyguardMessageAreaController mKeyguardMessageAreaController; @Mock - private KeyguardMessageArea mKeyguardMessageArea; + private BouncerKeyguardMessageArea mKeyguardMessageArea; @Mock private ConfigurationController mConfigurationController; @Mock @@ -163,9 +164,10 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase { when(mAdminSecondaryLockScreenControllerFactory.create(any(KeyguardSecurityCallback.class))) .thenReturn(mAdminSecondaryLockScreenController); when(mSecurityViewFlipper.getWindowInsetsController()).thenReturn(mWindowInsetsController); - mKeyguardPasswordView = spy(new KeyguardPasswordView(getContext())); + mKeyguardPasswordView = spy((KeyguardPasswordView) LayoutInflater.from(mContext).inflate( + R.layout.keyguard_password_view, null)); when(mKeyguardPasswordView.getRootView()).thenReturn(mSecurityViewFlipper); - when(mKeyguardPasswordView.findViewById(R.id.keyguard_message_area)) + when(mKeyguardPasswordView.requireViewById(R.id.bouncer_message_area)) .thenReturn(mKeyguardMessageArea); when(mKeyguardMessageAreaControllerFactory.create(any(KeyguardMessageArea.class))) .thenReturn(mKeyguardMessageAreaController); diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt index 43fc8983011d4..2adc389a964e7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationShadeWindowViewControllerTest.kt @@ -19,8 +19,10 @@ package com.android.systemui.shade import android.testing.AndroidTestingRunner import android.testing.TestableLooper.RunWithLooper import android.view.MotionEvent +import android.view.ViewGroup import androidx.test.filters.SmallTest import com.android.keyguard.LockIconViewController +import com.android.systemui.R import com.android.systemui.SysuiTestCase import com.android.systemui.classifier.FalsingCollectorFake import com.android.systemui.dock.DockManager @@ -246,6 +248,18 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() { verify(phoneStatusBarViewController).sendTouchToView(nextEvent) assertThat(returnVal).isTrue() } + + @Test + fun testGetBouncerContainer() { + underTest.bouncerContainer + verify(view).findViewById(R.id.keyguard_bouncer_container) + } + + @Test + fun testGetKeyguardMessageArea() { + underTest.keyguardMessageArea + verify(view).findViewById(R.id.keyguard_message_area) + } } private val downEv = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0) 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 d73d07ca1423c..f4204ac56c249 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/KeyguardIndicationControllerTest.java @@ -639,7 +639,7 @@ public class KeyguardIndicationControllerTest extends SysuiTestCase { mController.getKeyguardCallback().onBiometricError(FACE_ERROR_TIMEOUT, "A message", BiometricSourceType.FACE); - verify(mStatusBarKeyguardViewManager).showBouncerMessage(eq(message), any()); + verify(mStatusBarKeyguardViewManager).setKeyguardMessage(eq(message), any()); } @Test