Merge "[Bouncer] Separate keyguard message areas." into tm-qpr-dev

This commit is contained in:
Aaron Liu
2022-09-09 16:21:54 +00:00
committed by Android (Google) Code Review
33 changed files with 261 additions and 142 deletions

View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ 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
-->
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<com.android.keyguard.BouncerKeyguardMessageArea
android:id="@+id/bouncer_message_area"
style="@style/Keyguard.TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/keyguard_lock_padding"
android:ellipsize="marquee"
android:focusable="true"
android:gravity="center"
android:singleLine="true" />
</merge>

View File

@@ -28,6 +28,7 @@
android:layout_gravity="center_horizontal|bottom"
android:gravity="bottom"
>
<include layout="@layout/keyguard_bouncer_message_area"/>
<Space
android:layout_width="match_parent"

View File

@@ -31,6 +31,7 @@
android:layout_gravity="center_horizontal|bottom"
android:clipChildren="false"
android:clipToPadding="false">
<include layout="@layout/keyguard_bouncer_message_area"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/pattern_container"

View File

@@ -27,6 +27,7 @@
android:clipToPadding="false"
android:orientation="vertical"
androidprv:layout_maxWidth="@dimen/keyguard_security_width">
<include layout="@layout/keyguard_bouncer_message_area"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/pin_container"
@@ -189,8 +190,6 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<include layout="@layout/keyguard_eca"
android:id="@+id/keyguard_selector_fade_container"
android:layout_width="match_parent"

View File

@@ -26,20 +26,17 @@
android:layout_height="match_parent"
androidprv:layout_maxWidth="@dimen/keyguard_security_width"
android:layout_gravity="center_horizontal|bottom">
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<include layout="@layout/keyguard_bouncer_message_area" />
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<ImageView
android:id="@+id/keyguard_sim"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:tint="@color/background_protected"
android:src="@drawable/ic_lockscreen_sim"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
@@ -52,14 +49,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eca_overlap" />
<RelativeLayout
android:id="@+id/row0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="4dp"
>
<com.android.keyguard.PasswordTextView
android:id="@+id/simPinEntry"
style="@style/Widget.TextView.Password"
@@ -195,7 +190,6 @@
/>
</LinearLayout>
</LinearLayout>
<include layout="@layout/keyguard_eca"
android:id="@+id/keyguard_selector_fade_container"
android:layout_width="match_parent"
@@ -205,5 +199,4 @@
android:layout_marginTop="@dimen/keyguard_eca_top_margin"
android:layout_marginBottom="2dp"
android:gravity="center_horizontal"/>
</com.android.keyguard.KeyguardSimPinView>

View File

@@ -27,12 +27,12 @@
android:layout_height="match_parent"
androidprv:layout_maxWidth="@dimen/keyguard_security_width"
android:layout_gravity="center_horizontal|bottom">
<include layout="@layout/keyguard_bouncer_message_area"/>
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
/>
<Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<ImageView
android:id="@+id/keyguard_sim"

View File

@@ -88,7 +88,7 @@
android:layout_marginTop="@dimen/status_bar_height"
android:layout_gravity="top|center_horizontal"
android:gravity="center_horizontal">
<com.android.keyguard.KeyguardMessageArea
<com.android.keyguard.AuthKeyguardMessageArea
android:id="@+id/keyguard_message_area"
style="@style/Keyguard.TextView"
android:layout_width="wrap_content"

View File

@@ -23,7 +23,7 @@
<dimen name="status_view_margin_horizontal">124dp</dimen>
<dimen name="keyguard_clock_top_margin">80dp</dimen>
<dimen name="keyguard_status_view_bottom_margin">80dp</dimen>
<dimen name="bouncer_user_switcher_y_trans">90dp</dimen>
<dimen name="bouncer_user_switcher_y_trans">200dp</dimen>
<dimen name="large_screen_shade_header_left_padding">24dp</dimen>
<dimen name="qqs_layout_padding_bottom">40dp</dimen>

View File

@@ -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))
}
}

View File

@@ -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()
}
}

View File

@@ -50,7 +50,6 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
private final FalsingCollector mFalsingCollector;
private final EmergencyButtonController mEmergencyButtonController;
private CountDownTimer mCountdownTimer;
protected KeyguardMessageAreaController mMessageAreaController;
private boolean mDismissing;
protected AsyncTask<?, ?, ?> mPendingLockCheck;
protected boolean mResumed;
@@ -80,14 +79,13 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
KeyguardMessageAreaController.Factory messageAreaControllerFactory,
LatencyTracker latencyTracker, FalsingCollector falsingCollector,
EmergencyButtonController emergencyButtonController) {
super(view, securityMode, keyguardSecurityCallback, emergencyButtonController);
super(view, securityMode, keyguardSecurityCallback, emergencyButtonController,
messageAreaControllerFactory);
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mLockPatternUtils = lockPatternUtils;
mLatencyTracker = latencyTracker;
mFalsingCollector = falsingCollector;
mEmergencyButtonController = emergencyButtonController;
KeyguardMessageArea kma = KeyguardMessageArea.findSecurityMessageDisplay(mView);
mMessageAreaController = messageAreaControllerFactory.create(kma);
}
abstract void resetState();
@@ -95,7 +93,6 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
@Override
public void onInit() {
super.onInit();
mMessageAreaController.init();
}
@Override
@@ -134,6 +131,10 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
@Override
public void showMessage(CharSequence message, ColorStateList colorState) {
if (mMessageAreaController == null) {
return;
}
if (colorState != null) {
mMessageAreaController.setNextMessageColor(colorState);
}

View File

@@ -17,9 +17,11 @@
package com.android.keyguard;
import android.annotation.CallSuper;
import android.annotation.Nullable;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.inputmethod.InputMethodManager;
import com.android.internal.util.LatencyTracker;
@@ -44,6 +46,7 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
private final EmergencyButton mEmergencyButton;
private final EmergencyButtonController mEmergencyButtonController;
private boolean mPaused;
protected KeyguardMessageAreaController<BouncerKeyguardMessageArea> 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<T extends KeyguardInputView>
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

View File

@@ -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.

View File

@@ -26,11 +26,14 @@ import com.android.systemui.util.ViewController;
import javax.inject.Inject;
/** Controller for a {@link KeyguardMessageAreaController}. */
public class KeyguardMessageAreaController extends ViewController<KeyguardMessageArea> {
/**
* Controller for a {@link KeyguardMessageAreaController}.
* @param <T> A subclass of KeyguardMessageArea.
*/
public class KeyguardMessageAreaController<T extends KeyguardMessageArea>
extends ViewController<T> {
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<KeyguardMessag
}
};
private KeyguardMessageAreaController(KeyguardMessageArea view,
protected KeyguardMessageAreaController(T view,
KeyguardUpdateMonitor keyguardUpdateMonitor,
ConfigurationController configurationController) {
super(view);
@@ -83,17 +86,10 @@ public class KeyguardMessageAreaController extends ViewController<KeyguardMessag
}
/**
* Set whether alt bouncer is showing
* Indicate that view is visible and can display messages.
*/
public void setAltBouncerShowing(boolean showing) {
mView.setAltBouncerShowing(showing);
}
/**
* Set bouncer is fully showing
*/
public void setBouncerShowing(boolean showing) {
mView.setBouncerShowing(showing);
public void setIsVisible(boolean isVisible) {
mView.setIsVisible(isVisible);
}
public void setMessage(CharSequence s) {

View File

@@ -71,7 +71,7 @@ public class KeyguardPatternView extends KeyguardInputView
*/
private long mLastPokeTime = -UNLOCK_PATTERN_WAKE_INTERVAL_MS;
KeyguardMessageArea mSecurityMessageDisplay;
BouncerKeyguardMessageArea mSecurityMessageDisplay;
private View mEcaView;
private ConstraintLayout mContainer;
@@ -120,7 +120,7 @@ public class KeyguardPatternView extends KeyguardInputView
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
mSecurityMessageDisplay = KeyguardMessageArea.findSecurityMessageDisplay(this);
mSecurityMessageDisplay = findViewById(R.id.bouncer_message_area);
}
@Override

View File

@@ -59,12 +59,9 @@ public class KeyguardPatternViewController
private final LatencyTracker mLatencyTracker;
private final FalsingCollector mFalsingCollector;
private final EmergencyButtonController mEmergencyButtonController;
private final KeyguardMessageAreaController.Factory mMessageAreaControllerFactory;
private final DevicePostureController mPostureController;
private final DevicePostureController.Callback mPostureCallback =
posture -> 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);
}

View File

@@ -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

View File

@@ -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

View File

@@ -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);

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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();

View File

@@ -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();

View File

@@ -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<AuthKeyguardMessageArea> mKeyguardMessageAreaController;
private final Lazy<com.android.systemui.shade.ShadeController> 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);

View File

@@ -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);

View File

@@ -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,

View File

@@ -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

View File

@@ -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<BouncerKeyguardMessageArea>
private lateinit var keyguardPasswordViewController: KeyguardPasswordViewController
@@ -74,7 +75,8 @@ class KeyguardPasswordViewControllerTest : SysuiTestCase() {
fun setup() {
MockitoAnnotations.initMocks(this)
Mockito.`when`(
keyguardPasswordView.findViewById<KeyguardMessageArea>(R.id.keyguard_message_area)
keyguardPasswordView
.requireViewById<BouncerKeyguardMessageArea>(R.id.bouncer_message_area)
).thenReturn(mKeyguardMessageArea)
Mockito.`when`(messageAreaControllerFactory.create(mKeyguardMessageArea))
.thenReturn(mKeyguardMessageAreaController)

View File

@@ -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<BouncerKeyguardMessageArea>
@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<KeyguardMessageArea>(R.id.keyguard_message_area))
`when`(mKeyguardPatternView
.requireViewById<BouncerKeyguardMessageArea>(R.id.bouncer_message_area))
.thenReturn(mKeyguardMessageArea)
`when`(mKeyguardPatternView.findViewById<LockPatternView>(R.id.lockPatternView))
.thenReturn(mLockPatternView)

View File

@@ -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);

View File

@@ -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);

View File

@@ -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<ViewGroup>(R.id.keyguard_bouncer_container)
}
@Test
fun testGetKeyguardMessageArea() {
underTest.keyguardMessageArea
verify(view).findViewById<ViewGroup>(R.id.keyguard_message_area)
}
}
private val downEv = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0)

View File

@@ -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