Merge "[Bouncer] Remove KeyguardBouncer.java" into tm-qpr-dev

This commit is contained in:
Aaron Liu
2023-01-26 16:41:49 +00:00
committed by Android (Google) Code Review
15 changed files with 53 additions and 2077 deletions

View File

@@ -20,13 +20,13 @@ import android.view.ViewGroup;
import com.android.keyguard.KeyguardHostViewController; import com.android.keyguard.KeyguardHostViewController;
import com.android.systemui.dagger.qualifiers.RootView; import com.android.systemui.dagger.qualifiers.RootView;
import com.android.systemui.statusbar.phone.KeyguardBouncer; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerInteractor;
import dagger.BindsInstance; import dagger.BindsInstance;
import dagger.Subcomponent; import dagger.Subcomponent;
/** /**
* Dagger Subcomponent for the {@link KeyguardBouncer}. * Dagger Subcomponent for the {@link PrimaryBouncerInteractor}.
*/ */
@Subcomponent(modules = {KeyguardBouncerModule.class}) @Subcomponent(modules = {KeyguardBouncerModule.class})
@KeyguardBouncerScope @KeyguardBouncerScope

View File

@@ -29,7 +29,7 @@ import com.android.keyguard.KeyguardSecurityViewFlipper;
import com.android.systemui.R; import com.android.systemui.R;
import com.android.systemui.biometrics.SideFpsController; import com.android.systemui.biometrics.SideFpsController;
import com.android.systemui.dagger.qualifiers.RootView; import com.android.systemui.dagger.qualifiers.RootView;
import com.android.systemui.statusbar.phone.KeyguardBouncer; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerInteractor;
import java.util.Optional; import java.util.Optional;
@@ -39,7 +39,7 @@ import dagger.Module;
import dagger.Provides; import dagger.Provides;
/** /**
* Module to create and access view related to the {@link KeyguardBouncer}. * Module to create and access view related to the {@link PrimaryBouncerInteractor}.
*/ */
@Module @Module
public interface KeyguardBouncerModule { public interface KeyguardBouncerModule {

View File

@@ -32,7 +32,6 @@ import com.android.systemui.dump.DumpManager
import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerInteractor import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerInteractor
import com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants import com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants
import com.android.systemui.lifecycle.repeatWhenAttached import com.android.systemui.lifecycle.repeatWhenAttached
@@ -149,21 +148,6 @@ constructor(
} }
} }
private val mPrimaryBouncerExpansionCallback: PrimaryBouncerExpansionCallback =
object : PrimaryBouncerExpansionCallback {
override fun onExpansionChanged(expansion: Float) {
inputBouncerHiddenAmount = expansion
updateAlpha()
updatePauseAuth()
}
override fun onVisibilityChanged(isVisible: Boolean) {
updateBouncerHiddenAmount()
updateAlpha()
updatePauseAuth()
}
}
private val configurationListener: ConfigurationController.ConfigurationListener = private val configurationListener: ConfigurationController.ConfigurationListener =
object : ConfigurationController.ConfigurationListener { object : ConfigurationController.ConfigurationListener {
override fun onUiModeChanged() { override fun onUiModeChanged() {
@@ -315,14 +299,6 @@ constructor(
statusBarState = statusBarStateController.state statusBarState = statusBarStateController.state
qsExpansion = keyguardViewManager.qsExpansion qsExpansion = keyguardViewManager.qsExpansion
keyguardViewManager.addCallback(statusBarKeyguardViewManagerCallback) keyguardViewManager.addCallback(statusBarKeyguardViewManagerCallback)
if (!isModernBouncerEnabled) {
val bouncer = keyguardViewManager.primaryBouncer
bouncer?.expansion?.let {
mPrimaryBouncerExpansionCallback.onExpansionChanged(it)
bouncer.addBouncerExpansionCallback(mPrimaryBouncerExpansionCallback)
}
updateBouncerHiddenAmount()
}
configurationController.addCallback(configurationListener) configurationController.addCallback(configurationListener)
shadeExpansionStateManager.addExpansionListener(shadeExpansionListener) shadeExpansionStateManager.addExpansionListener(shadeExpansionListener)
updateScaleFactor() updateScaleFactor()
@@ -352,11 +328,6 @@ constructor(
} }
activityLaunchAnimator.removeListener(activityLaunchAnimatorListener) activityLaunchAnimator.removeListener(activityLaunchAnimatorListener)
keyguardViewManager.removeCallback(statusBarKeyguardViewManagerCallback) keyguardViewManager.removeCallback(statusBarKeyguardViewManagerCallback)
if (!isModernBouncerEnabled) {
keyguardViewManager.primaryBouncer?.removeBouncerExpansionCallback(
mPrimaryBouncerExpansionCallback
)
}
} }
override fun dump(pw: PrintWriter, args: Array<String>) { override fun dump(pw: PrintWriter, args: Array<String>) {

View File

@@ -40,8 +40,6 @@ import com.android.systemui.dreams.dagger.DreamOverlayModule;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback;
import com.android.systemui.statusbar.BlurUtils; import com.android.systemui.statusbar.BlurUtils;
import com.android.systemui.statusbar.phone.KeyguardBouncer;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.util.ViewController; import com.android.systemui.util.ViewController;
import com.android.systemui.util.concurrency.DelayableExecutor; import com.android.systemui.util.concurrency.DelayableExecutor;
@@ -56,7 +54,6 @@ import javax.inject.Named;
@DreamOverlayComponent.DreamOverlayScope @DreamOverlayComponent.DreamOverlayScope
public class DreamOverlayContainerViewController extends ViewController<DreamOverlayContainerView> { public class DreamOverlayContainerViewController extends ViewController<DreamOverlayContainerView> {
private final DreamOverlayStatusBarViewController mStatusBarViewController; private final DreamOverlayStatusBarViewController mStatusBarViewController;
private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
private final BlurUtils mBlurUtils; private final BlurUtils mBlurUtils;
private final DreamOverlayAnimationsController mDreamOverlayAnimationsController; private final DreamOverlayAnimationsController mDreamOverlayAnimationsController;
private final DreamOverlayStateController mStateController; private final DreamOverlayStateController mStateController;
@@ -133,7 +130,6 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve
ComplicationHostViewController complicationHostViewController, ComplicationHostViewController complicationHostViewController,
@Named(DreamOverlayModule.DREAM_OVERLAY_CONTENT_VIEW) ViewGroup contentView, @Named(DreamOverlayModule.DREAM_OVERLAY_CONTENT_VIEW) ViewGroup contentView,
DreamOverlayStatusBarViewController statusBarViewController, DreamOverlayStatusBarViewController statusBarViewController,
StatusBarKeyguardViewManager statusBarKeyguardViewManager,
BlurUtils blurUtils, BlurUtils blurUtils,
@Main Handler handler, @Main Handler handler,
@Main Resources resources, @Main Resources resources,
@@ -147,7 +143,6 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve
super(containerView); super(containerView);
mDreamOverlayContentView = contentView; mDreamOverlayContentView = contentView;
mStatusBarViewController = statusBarViewController; mStatusBarViewController = statusBarViewController;
mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
mBlurUtils = blurUtils; mBlurUtils = blurUtils;
mDreamOverlayAnimationsController = animationsController; mDreamOverlayAnimationsController = animationsController;
mStateController = stateController; mStateController = stateController;
@@ -179,10 +174,6 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve
protected void onViewAttached() { protected void onViewAttached() {
mJitterStartTimeMillis = System.currentTimeMillis(); mJitterStartTimeMillis = System.currentTimeMillis();
mHandler.postDelayed(this::updateBurnInOffsets, mBurnInProtectionUpdateInterval); mHandler.postDelayed(this::updateBurnInOffsets, mBurnInProtectionUpdateInterval);
final KeyguardBouncer bouncer = mStatusBarKeyguardViewManager.getPrimaryBouncer();
if (bouncer != null) {
bouncer.addBouncerExpansionCallback(mBouncerExpansionCallback);
}
mPrimaryBouncerCallbackInteractor.addBouncerExpansionCallback(mBouncerExpansionCallback); mPrimaryBouncerCallbackInteractor.addBouncerExpansionCallback(mBouncerExpansionCallback);
// Start dream entry animations. Skip animations for low light clock. // Start dream entry animations. Skip animations for low light clock.
@@ -194,10 +185,6 @@ public class DreamOverlayContainerViewController extends ViewController<DreamOve
@Override @Override
protected void onViewDetached() { protected void onViewDetached() {
mHandler.removeCallbacks(this::updateBurnInOffsets); mHandler.removeCallbacks(this::updateBurnInOffsets);
final KeyguardBouncer bouncer = mStatusBarKeyguardViewManager.getPrimaryBouncer();
if (bouncer != null) {
bouncer.removeBouncerExpansionCallback(mBouncerExpansionCallback);
}
mPrimaryBouncerCallbackInteractor.removeBouncerExpansionCallback(mBouncerExpansionCallback); mPrimaryBouncerCallbackInteractor.removeBouncerExpansionCallback(mBouncerExpansionCallback);
mDreamOverlayAnimationsController.cancelAnimations(); mDreamOverlayAnimationsController.cancelAnimations();

View File

@@ -26,7 +26,6 @@ import com.android.systemui.keyguard.shared.model.KeyguardBouncerModel
import com.android.systemui.log.dagger.BouncerLog import com.android.systemui.log.dagger.BouncerLog
import com.android.systemui.log.table.TableLogBuffer import com.android.systemui.log.table.TableLogBuffer
import com.android.systemui.log.table.logDiffsForTable import com.android.systemui.log.table.logDiffsForTable
import com.android.systemui.statusbar.phone.KeyguardBouncer
import com.android.systemui.util.time.SystemClock import com.android.systemui.util.time.SystemClock
import javax.inject.Inject import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope

View File

@@ -25,4 +25,5 @@ object KeyguardBouncerConstants {
*/ */
const val EXPANSION_HIDDEN = 1f const val EXPANSION_HIDDEN = 1f
const val EXPANSION_VISIBLE = 0f const val EXPANSION_VISIBLE = 0f
const val ALPHA_EXPANSION_THRESHOLD = 0.95f
} }

View File

@@ -142,6 +142,7 @@ import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteracto
import com.android.systemui.keyguard.domain.interactor.KeyguardBottomAreaInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardBottomAreaInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor; import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
import com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants;
import com.android.systemui.keyguard.shared.model.TransitionState; import com.android.systemui.keyguard.shared.model.TransitionState;
import com.android.systemui.keyguard.shared.model.TransitionStep; import com.android.systemui.keyguard.shared.model.TransitionStep;
import com.android.systemui.keyguard.ui.binder.KeyguardLongPressViewBinder; import com.android.systemui.keyguard.ui.binder.KeyguardLongPressViewBinder;
@@ -207,7 +208,6 @@ import com.android.systemui.statusbar.phone.HeadsUpManagerPhone;
import com.android.systemui.statusbar.phone.HeadsUpTouchHelper; import com.android.systemui.statusbar.phone.HeadsUpTouchHelper;
import com.android.systemui.statusbar.phone.KeyguardBottomAreaView; import com.android.systemui.statusbar.phone.KeyguardBottomAreaView;
import com.android.systemui.statusbar.phone.KeyguardBottomAreaViewController; import com.android.systemui.statusbar.phone.KeyguardBottomAreaViewController;
import com.android.systemui.statusbar.phone.KeyguardBouncer;
import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.KeyguardBypassController;
import com.android.systemui.statusbar.phone.KeyguardClockPositionAlgorithm; import com.android.systemui.statusbar.phone.KeyguardClockPositionAlgorithm;
import com.android.systemui.statusbar.phone.KeyguardStatusBarView; import com.android.systemui.statusbar.phone.KeyguardStatusBarView;
@@ -3786,7 +3786,8 @@ public final class NotificationPanelViewController implements Dumpable {
// change due to "unlock hint animation." In this case, fading out the bottom area // change due to "unlock hint animation." In this case, fading out the bottom area
// would also hide the message that says "swipe to unlock," we don't want to do that. // would also hide the message that says "swipe to unlock," we don't want to do that.
float expansionAlpha = MathUtils.map( float expansionAlpha = MathUtils.map(
isUnlockHintRunning() ? 0 : KeyguardBouncer.ALPHA_EXPANSION_THRESHOLD, 1f, 0f, 1f, isUnlockHintRunning() ? 0 : KeyguardBouncerConstants.ALPHA_EXPANSION_THRESHOLD, 1f,
0f, 1f,
getExpandedFraction()); getExpandedFraction());
float alpha = Math.min(expansionAlpha, 1 - computeQsExpansionFraction()); float alpha = Math.min(expansionAlpha, 1 - computeQsExpansionFraction());
alpha *= mBottomAreaShadeAlpha; alpha *= mBottomAreaShadeAlpha;

View File

@@ -1,708 +0,0 @@
/*
* Copyright (C) 2014 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.systemui.statusbar.phone;
import static com.android.keyguard.KeyguardSecurityModel.SecurityMode;
import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_HIDDEN;
import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_VISIBLE;
import static com.android.systemui.plugins.ActivityStarter.OnDismissAction;
import android.content.Context;
import android.content.res.ColorStateList;
import android.hardware.biometrics.BiometricSourceType;
import android.os.Handler;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import com.android.internal.policy.SystemBarUtils;
import com.android.keyguard.KeyguardHostViewController;
import com.android.keyguard.KeyguardSecurityModel;
import com.android.keyguard.KeyguardSecurityView;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.keyguard.ViewMediatorCallback;
import com.android.keyguard.dagger.KeyguardBouncerComponent;
import com.android.systemui.DejankUtils;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.KeyguardResetCallback;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback;
import com.android.systemui.shared.system.SysUiStatsLog;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import com.android.systemui.util.ListenerSet;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
/**
* A class which manages the primary (pin/pattern/password) bouncer on the lockscreen.
* @deprecated Use KeyguardBouncerRepository
*/
@Deprecated
public class KeyguardBouncer {
private static final String TAG = "PrimaryKeyguardBouncer";
static final long BOUNCER_FACE_DELAY = 1200;
public static final float ALPHA_EXPANSION_THRESHOLD = 0.95f;
protected final Context mContext;
protected final ViewMediatorCallback mCallback;
protected final ViewGroup mContainer;
private final FalsingCollector mFalsingCollector;
private final DismissCallbackRegistry mDismissCallbackRegistry;
private final Handler mHandler;
private final List<PrimaryBouncerExpansionCallback> mExpansionCallbacks = new ArrayList<>();
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final KeyguardStateController mKeyguardStateController;
private final KeyguardSecurityModel mKeyguardSecurityModel;
private final KeyguardBouncerComponent.Factory mKeyguardBouncerComponentFactory;
private final KeyguardUpdateMonitorCallback mUpdateMonitorCallback =
new KeyguardUpdateMonitorCallback() {
@Override
public void onStrongAuthStateChanged(int userId) {
mBouncerPromptReason = mCallback.getBouncerPromptReason();
}
@Override
public void onLockedOutStateChanged(BiometricSourceType type) {
if (type == BiometricSourceType.FINGERPRINT) {
mBouncerPromptReason = mCallback.getBouncerPromptReason();
}
}
@Override
public void onNonStrongBiometricAllowedChanged(int userId) {
mBouncerPromptReason = mCallback.getBouncerPromptReason();
}
};
private final Runnable mRemoveViewRunnable = this::removeView;
private final KeyguardBypassController mKeyguardBypassController;
private KeyguardHostViewController mKeyguardViewController;
private final ListenerSet<KeyguardResetCallback> mResetCallbacks = new ListenerSet<>();
private final Runnable mResetRunnable = ()-> {
if (mKeyguardViewController != null) {
mKeyguardViewController.resetSecurityContainer();
for (KeyguardResetCallback callback : mResetCallbacks) {
callback.onKeyguardReset();
}
}
};
private int mStatusBarHeight;
private float mExpansion = EXPANSION_HIDDEN;
private boolean mShowingSoon;
private int mBouncerPromptReason;
private boolean mIsAnimatingAway;
private boolean mIsScrimmed;
private boolean mInitialized;
private KeyguardBouncer(Context context, ViewMediatorCallback callback,
ViewGroup container,
DismissCallbackRegistry dismissCallbackRegistry, FalsingCollector falsingCollector,
PrimaryBouncerExpansionCallback expansionCallback,
KeyguardStateController keyguardStateController,
KeyguardUpdateMonitor keyguardUpdateMonitor,
KeyguardBypassController keyguardBypassController, @Main Handler handler,
KeyguardSecurityModel keyguardSecurityModel,
KeyguardBouncerComponent.Factory keyguardBouncerComponentFactory) {
mContext = context;
mCallback = callback;
mContainer = container;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mFalsingCollector = falsingCollector;
mDismissCallbackRegistry = dismissCallbackRegistry;
mHandler = handler;
mKeyguardStateController = keyguardStateController;
mKeyguardSecurityModel = keyguardSecurityModel;
mKeyguardBouncerComponentFactory = keyguardBouncerComponentFactory;
mKeyguardUpdateMonitor.registerCallback(mUpdateMonitorCallback);
mKeyguardBypassController = keyguardBypassController;
mExpansionCallbacks.add(expansionCallback);
}
/**
* Get the KeyguardBouncer expansion
* @return 1=HIDDEN, 0=SHOWING, in between 0 and 1 means the bouncer is in transition.
*/
public float getExpansion() {
return mExpansion;
}
/**
* Enable/disable only the back button
*/
public void setBackButtonEnabled(boolean enabled) {
int vis = mContainer.getSystemUiVisibility();
if (enabled) {
vis &= ~View.STATUS_BAR_DISABLE_BACK;
} else {
vis |= View.STATUS_BAR_DISABLE_BACK;
}
mContainer.setSystemUiVisibility(vis);
}
public void show(boolean resetSecuritySelection) {
show(resetSecuritySelection, true /* scrimmed */);
}
/**
* Shows the bouncer.
*
* @param resetSecuritySelection Cleans keyguard view
* @param isScrimmed true when the bouncer show show scrimmed, false when the user will be
* dragging it and translation should be deferred.
*/
public void show(boolean resetSecuritySelection, boolean isScrimmed) {
final int keyguardUserId = KeyguardUpdateMonitor.getCurrentUser();
if (keyguardUserId == UserHandle.USER_SYSTEM && UserManager.isSplitSystemUser()) {
// In split system user mode, we never unlock system user.
return;
}
try {
Trace.beginSection("KeyguardBouncer#show");
ensureView();
mIsScrimmed = isScrimmed;
// On the keyguard, we want to show the bouncer when the user drags up, but it's
// not correct to end the falsing session. We still need to verify if those touches
// are valid.
// Later, at the end of the animation, when the bouncer is at the top of the screen,
// onFullyShown() will be called and FalsingManager will stop recording touches.
if (isScrimmed) {
setExpansion(EXPANSION_VISIBLE);
}
if (resetSecuritySelection) {
// showPrimarySecurityScreen() updates the current security method. This is needed
// in case we are already showing and the current security method changed.
showPrimarySecurityScreen();
}
if (mContainer.getVisibility() == View.VISIBLE || mShowingSoon) {
// Calls to reset must resume the ViewControllers when in fullscreen mode
if (needsFullscreenBouncer()) {
mKeyguardViewController.onResume();
}
return;
}
final int activeUserId = KeyguardUpdateMonitor.getCurrentUser();
final boolean isSystemUser =
UserManager.isSplitSystemUser() && activeUserId == UserHandle.USER_SYSTEM;
final boolean allowDismissKeyguard = !isSystemUser && 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 && mKeyguardViewController.dismiss(activeUserId)) {
return;
}
// This condition may indicate an error on Android, so log it.
if (!allowDismissKeyguard) {
Log.w(TAG, "User can't dismiss keyguard: " + activeUserId + " != "
+ keyguardUserId);
}
mShowingSoon = true;
// Split up the work over multiple frames.
DejankUtils.removeCallbacks(mResetRunnable);
if (mKeyguardStateController.isFaceAuthEnabled()
&& !mKeyguardUpdateMonitor.getCachedIsUnlockWithFingerprintPossible(
KeyguardUpdateMonitor.getCurrentUser())
&& !needsFullscreenBouncer()
&& mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed(
BiometricSourceType.FACE)
&& !mKeyguardBypassController.getBypassEnabled()) {
mHandler.postDelayed(mShowRunnable, BOUNCER_FACE_DELAY);
} else {
DejankUtils.postAfterTraversal(mShowRunnable);
}
mKeyguardStateController.notifyBouncerShowing(true /* showing */);
dispatchStartingToShow();
} finally {
Trace.endSection();
}
}
public boolean isScrimmed() {
return mIsScrimmed;
}
/**
* This method must be called at the end of the bouncer animation when
* the translation is performed manually by the user, otherwise FalsingManager
* will never be notified and its internal state will be out of sync.
*/
private void onFullyShown() {
mFalsingCollector.onBouncerShown();
if (mKeyguardViewController == null) {
Log.e(TAG, "onFullyShown when view was null");
} else {
mKeyguardViewController.onResume();
mContainer.announceForAccessibility(
mKeyguardViewController.getAccessibilityTitleForCurrentMode());
}
}
/**
* @see #onFullyShown()
*/
private void onFullyHidden() {
}
private void setVisibility(@View.Visibility int visibility) {
mContainer.setVisibility(visibility);
if (mKeyguardViewController != null) {
mKeyguardViewController.onBouncerVisibilityChanged(visibility);
}
dispatchVisibilityChanged();
}
private final Runnable mShowRunnable = new Runnable() {
@Override
public void run() {
setVisibility(View.VISIBLE);
showPromptReason(mBouncerPromptReason);
final CharSequence customMessage = mCallback.consumeCustomMessage();
if (customMessage != null) {
mKeyguardViewController.showErrorMessage(customMessage);
}
mKeyguardViewController.appear(mStatusBarHeight);
mShowingSoon = false;
if (mExpansion == EXPANSION_VISIBLE) {
mKeyguardViewController.onResume();
mKeyguardViewController.resetSecurityContainer();
showPromptReason(mBouncerPromptReason);
}
}
};
/**
* Show a string explaining why the security view needs to be solved.
*
* @param reason a flag indicating which string should be shown, see
* {@link KeyguardSecurityView#PROMPT_REASON_NONE}
* and {@link KeyguardSecurityView#PROMPT_REASON_RESTART}
*/
public void showPromptReason(int reason) {
if (mKeyguardViewController != null) {
mKeyguardViewController.showPromptReason(reason);
} else {
Log.w(TAG, "Trying to show prompt reason on empty bouncer");
}
}
public void showMessage(String message, ColorStateList colorState) {
if (mKeyguardViewController != null) {
mKeyguardViewController.showMessage(message, colorState);
} else {
Log.w(TAG, "Trying to show message on empty bouncer");
}
}
private void cancelShowRunnable() {
DejankUtils.removeCallbacks(mShowRunnable);
mHandler.removeCallbacks(mShowRunnable);
mShowingSoon = false;
}
public void showWithDismissAction(OnDismissAction r, Runnable cancelAction) {
ensureView();
setDismissAction(r, cancelAction);
show(false /* resetSecuritySelection */);
}
/**
* Set the actions to run when the keyguard is dismissed or when the dismiss is cancelled. Those
* actions will still be run even if this bouncer is not shown, for instance when authenticating
* with an alternate authenticator like the UDFPS.
*/
public void setDismissAction(OnDismissAction r, Runnable cancelAction) {
mKeyguardViewController.setOnDismissAction(r, cancelAction);
}
public void hide(boolean destroyView) {
Trace.beginSection("KeyguardBouncer#hide");
if (isShowing()) {
SysUiStatsLog.write(SysUiStatsLog.KEYGUARD_BOUNCER_STATE_CHANGED,
SysUiStatsLog.KEYGUARD_BOUNCER_STATE_CHANGED__STATE__HIDDEN);
mDismissCallbackRegistry.notifyDismissCancelled();
}
mIsScrimmed = false;
mFalsingCollector.onBouncerHidden();
mKeyguardStateController.notifyBouncerShowing(false /* showing */);
cancelShowRunnable();
if (mKeyguardViewController != null) {
mKeyguardViewController.cancelDismissAction();
mKeyguardViewController.cleanUp();
}
mIsAnimatingAway = false;
setVisibility(View.INVISIBLE);
if (destroyView) {
// We have a ViewFlipper that unregisters a broadcast when being detached, which may
// be slow because of AM lock contention during unlocking. We can delay it a bit.
mHandler.postDelayed(mRemoveViewRunnable, 50);
}
Trace.endSection();
}
/**
* See {@link StatusBarKeyguardViewManager#startPreHideAnimation}.
*/
public void startPreHideAnimation(Runnable runnable) {
mIsAnimatingAway = true;
if (mKeyguardViewController != null) {
mKeyguardViewController.startDisappearAnimation(runnable);
} else if (runnable != null) {
runnable.run();
}
}
/**
* Reset the state of the view.
*/
public void reset() {
cancelShowRunnable();
inflateView();
mFalsingCollector.onBouncerHidden();
}
public void onScreenTurnedOff() {
if (mKeyguardViewController != null && mContainer.getVisibility() == View.VISIBLE) {
mKeyguardViewController.onPause();
}
}
public boolean isShowing() {
return (mShowingSoon || mContainer.getVisibility() == View.VISIBLE)
&& mExpansion == EXPANSION_VISIBLE && !isAnimatingAway();
}
/**
* {@link #show(boolean)} was called but we're not showing yet, or being dragged.
*/
public boolean inTransit() {
return mShowingSoon || mExpansion != EXPANSION_HIDDEN && mExpansion != EXPANSION_VISIBLE;
}
/**
* @return {@code true} when bouncer's pre-hide animation already started but isn't completely
* hidden yet, {@code false} otherwise.
*/
public boolean isAnimatingAway() {
return mIsAnimatingAway;
}
public void prepare() {
boolean wasInitialized = mInitialized;
ensureView();
if (wasInitialized) {
showPrimarySecurityScreen();
}
mBouncerPromptReason = mCallback.getBouncerPromptReason();
}
private void showPrimarySecurityScreen() {
mKeyguardViewController.showPrimarySecurityScreen();
}
/**
* Current notification panel expansion
* @param fraction 0 when notification panel is collapsed and 1 when expanded.
* @see StatusBarKeyguardViewManager#onPanelExpansionChanged
*/
public void setExpansion(float fraction) {
float oldExpansion = mExpansion;
boolean expansionChanged = mExpansion != fraction;
mExpansion = fraction;
if (mKeyguardViewController != null && !mIsAnimatingAway) {
mKeyguardViewController.setExpansion(fraction);
}
if (fraction == EXPANSION_VISIBLE && oldExpansion != EXPANSION_VISIBLE) {
onFullyShown();
dispatchFullyShown();
} else if (fraction == EXPANSION_HIDDEN && oldExpansion != EXPANSION_HIDDEN) {
DejankUtils.postAfterTraversal(mResetRunnable);
/*
* There are cases where #hide() was not invoked, such as when
* NotificationPanelViewController controls the hide animation. Make sure the state gets
* updated by calling #hide() directly.
*/
hide(false /* destroyView */);
dispatchFullyHidden();
} else if (fraction != EXPANSION_VISIBLE && oldExpansion == EXPANSION_VISIBLE) {
dispatchStartingToHide();
if (mKeyguardViewController != null) {
mKeyguardViewController.onStartingToHide();
}
}
if (expansionChanged) {
dispatchExpansionChanged();
}
}
public boolean willDismissWithAction() {
return mKeyguardViewController != null && mKeyguardViewController.hasDismissActions();
}
public int getTop() {
if (mKeyguardViewController == null) {
return 0;
}
return mKeyguardViewController.getTop();
}
protected void ensureView() {
// Removal of the view might be deferred to reduce unlock latency,
// in this case we need to force the removal, otherwise we'll
// end up in an unpredictable state.
boolean forceRemoval = mHandler.hasCallbacks(mRemoveViewRunnable);
if (!mInitialized || forceRemoval) {
inflateView();
}
}
protected void inflateView() {
removeView();
mHandler.removeCallbacks(mRemoveViewRunnable);
KeyguardBouncerComponent component = mKeyguardBouncerComponentFactory.create(mContainer);
mKeyguardViewController = component.getKeyguardHostViewController();
mKeyguardViewController.init();
mStatusBarHeight = SystemBarUtils.getStatusBarHeight(mContext);
setVisibility(View.INVISIBLE);
final WindowInsets rootInsets = mContainer.getRootWindowInsets();
if (rootInsets != null) {
mContainer.dispatchApplyWindowInsets(rootInsets);
}
mInitialized = true;
}
protected void removeView() {
mContainer.removeAllViews();
mInitialized = false;
}
/**
* @return True if and only if the security method should be shown before showing the
* notifications on Keyguard, like SIM PIN/PUK.
*/
public boolean needsFullscreenBouncer() {
SecurityMode mode = mKeyguardSecurityModel.getSecurityMode(
KeyguardUpdateMonitor.getCurrentUser());
return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
}
/**
* Like {@link #needsFullscreenBouncer}, but uses the currently visible security method, which
* makes this method much faster.
*/
public boolean isFullscreenBouncer() {
if (mKeyguardViewController != null) {
SecurityMode mode = mKeyguardViewController.getCurrentSecurityMode();
return mode == SecurityMode.SimPin || mode == SecurityMode.SimPuk;
}
return false;
}
/**
* WARNING: This method might cause Binder calls.
*/
public boolean isSecure() {
return mKeyguardSecurityModel.getSecurityMode(
KeyguardUpdateMonitor.getCurrentUser()) != SecurityMode.None;
}
public boolean shouldDismissOnMenuPressed() {
return mKeyguardViewController.shouldEnableMenuKey();
}
public boolean interceptMediaKey(KeyEvent event) {
ensureView();
return mKeyguardViewController.interceptMediaKey(event);
}
/**
* @return true if the pre IME back event should be handled
*/
public boolean dispatchBackKeyEventPreIme() {
ensureView();
return mKeyguardViewController.dispatchBackKeyEventPreIme();
}
public void notifyKeyguardAuthenticated(boolean strongAuth) {
ensureView();
mKeyguardViewController.finish(strongAuth, KeyguardUpdateMonitor.getCurrentUser());
}
private void dispatchFullyShown() {
for (PrimaryBouncerExpansionCallback callback : mExpansionCallbacks) {
callback.onFullyShown();
}
}
private void dispatchStartingToHide() {
for (PrimaryBouncerExpansionCallback callback : mExpansionCallbacks) {
callback.onStartingToHide();
}
}
private void dispatchStartingToShow() {
for (PrimaryBouncerExpansionCallback callback : mExpansionCallbacks) {
callback.onStartingToShow();
}
}
private void dispatchFullyHidden() {
for (PrimaryBouncerExpansionCallback callback : mExpansionCallbacks) {
callback.onFullyHidden();
}
}
private void dispatchExpansionChanged() {
for (PrimaryBouncerExpansionCallback callback : mExpansionCallbacks) {
callback.onExpansionChanged(mExpansion);
}
}
private void dispatchVisibilityChanged() {
for (PrimaryBouncerExpansionCallback callback : mExpansionCallbacks) {
callback.onVisibilityChanged(mContainer.getVisibility() == View.VISIBLE);
}
}
/**
* Apply keyguard configuration from the currently active resources. This can be called when the
* device configuration changes, to re-apply some resources that are qualified on the device
* configuration.
*/
public void updateResources() {
if (mKeyguardViewController != null) {
mKeyguardViewController.updateResources();
}
}
public void dump(PrintWriter pw) {
pw.println("KeyguardBouncer");
pw.println(" isShowing(): " + isShowing());
pw.println(" mStatusBarHeight: " + mStatusBarHeight);
pw.println(" mExpansion: " + mExpansion);
pw.println(" mKeyguardViewController; " + mKeyguardViewController);
pw.println(" mShowingSoon: " + mShowingSoon);
pw.println(" mBouncerPromptReason: " + mBouncerPromptReason);
pw.println(" mIsAnimatingAway: " + mIsAnimatingAway);
pw.println(" mInitialized: " + mInitialized);
}
/** Update keyguard position based on a tapped X coordinate. */
public void updateKeyguardPosition(float x) {
if (mKeyguardViewController != null) {
mKeyguardViewController.updateKeyguardPosition(x);
}
}
public void addKeyguardResetCallback(KeyguardResetCallback callback) {
mResetCallbacks.addIfAbsent(callback);
}
public void removeKeyguardResetCallback(KeyguardResetCallback callback) {
mResetCallbacks.remove(callback);
}
/**
* Adds a callback to listen to bouncer expansion updates.
*/
public void addBouncerExpansionCallback(PrimaryBouncerExpansionCallback callback) {
if (!mExpansionCallbacks.contains(callback)) {
mExpansionCallbacks.add(callback);
}
}
/**
* Removes a previously added callback. If the callback was never added, this methood
* does nothing.
*/
public void removeBouncerExpansionCallback(PrimaryBouncerExpansionCallback callback) {
mExpansionCallbacks.remove(callback);
}
/** Create a {@link KeyguardBouncer} once a container and bouncer callback are available. */
public static class Factory {
private final Context mContext;
private final ViewMediatorCallback mCallback;
private final DismissCallbackRegistry mDismissCallbackRegistry;
private final FalsingCollector mFalsingCollector;
private final KeyguardStateController mKeyguardStateController;
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private final KeyguardBypassController mKeyguardBypassController;
private final Handler mHandler;
private final KeyguardSecurityModel mKeyguardSecurityModel;
private final KeyguardBouncerComponent.Factory mKeyguardBouncerComponentFactory;
@Inject
public Factory(Context context, ViewMediatorCallback callback,
DismissCallbackRegistry dismissCallbackRegistry, FalsingCollector falsingCollector,
KeyguardStateController keyguardStateController,
KeyguardUpdateMonitor keyguardUpdateMonitor,
KeyguardBypassController keyguardBypassController, @Main Handler handler,
KeyguardSecurityModel keyguardSecurityModel,
KeyguardBouncerComponent.Factory keyguardBouncerComponentFactory) {
mContext = context;
mCallback = callback;
mDismissCallbackRegistry = dismissCallbackRegistry;
mFalsingCollector = falsingCollector;
mKeyguardStateController = keyguardStateController;
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
mKeyguardBypassController = keyguardBypassController;
mHandler = handler;
mKeyguardSecurityModel = keyguardSecurityModel;
mKeyguardBouncerComponentFactory = keyguardBouncerComponentFactory;
}
/**
* Construct a KeyguardBouncer that will exist in the given container.
*/
public KeyguardBouncer create(ViewGroup container,
PrimaryBouncerExpansionCallback expansionCallback) {
return new KeyguardBouncer(mContext, mCallback, container,
mDismissCallbackRegistry, mFalsingCollector, expansionCallback,
mKeyguardStateController, mKeyguardUpdateMonitor,
mKeyguardBypassController, mHandler, mKeyguardSecurityModel,
mKeyguardBouncerComponentFactory);
}
}
}

View File

@@ -129,7 +129,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
private final ConfigurationController mConfigurationController; private final ConfigurationController mConfigurationController;
private final NavigationModeController mNavigationModeController; private final NavigationModeController mNavigationModeController;
private final NotificationShadeWindowController mNotificationShadeWindowController; private final NotificationShadeWindowController mNotificationShadeWindowController;
private final KeyguardBouncer.Factory mKeyguardBouncerFactory;
private final KeyguardMessageAreaController.Factory mKeyguardMessageAreaFactory; private final KeyguardMessageAreaController.Factory mKeyguardMessageAreaFactory;
private final DreamOverlayStateController mDreamOverlayStateController; private final DreamOverlayStateController mDreamOverlayStateController;
@Nullable @Nullable
@@ -206,28 +205,28 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
Log.d(TAG, "onBackInvokedCallback() called, invoking onBackPressed()"); Log.d(TAG, "onBackInvokedCallback() called, invoking onBackPressed()");
} }
onBackPressed(); onBackPressed();
if (shouldPlayBackAnimation()) { if (shouldPlayBackAnimation() && mPrimaryBouncerView.getDelegate() != null) {
mPrimaryBouncerView.getDelegate().getBackCallback().onBackInvoked(); mPrimaryBouncerView.getDelegate().getBackCallback().onBackInvoked();
} }
} }
@Override @Override
public void onBackProgressed(BackEvent event) { public void onBackProgressed(BackEvent event) {
if (shouldPlayBackAnimation()) { if (shouldPlayBackAnimation() && mPrimaryBouncerView.getDelegate() != null) {
mPrimaryBouncerView.getDelegate().getBackCallback().onBackProgressed(event); mPrimaryBouncerView.getDelegate().getBackCallback().onBackProgressed(event);
} }
} }
@Override @Override
public void onBackCancelled() { public void onBackCancelled() {
if (shouldPlayBackAnimation()) { if (shouldPlayBackAnimation() && mPrimaryBouncerView.getDelegate() != null) {
mPrimaryBouncerView.getDelegate().getBackCallback().onBackCancelled(); mPrimaryBouncerView.getDelegate().getBackCallback().onBackCancelled();
} }
} }
@Override @Override
public void onBackStarted(BackEvent event) { public void onBackStarted(BackEvent event) {
if (shouldPlayBackAnimation()) { if (shouldPlayBackAnimation() && mPrimaryBouncerView.getDelegate() != null) {
mPrimaryBouncerView.getDelegate().getBackCallback().onBackStarted(event); mPrimaryBouncerView.getDelegate().getBackCallback().onBackStarted(event);
} }
} }
@@ -256,7 +255,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
private View mNotificationContainer; private View mNotificationContainer;
@Nullable protected KeyguardBouncer mPrimaryBouncer;
protected boolean mRemoteInputActive; protected boolean mRemoteInputActive;
private boolean mGlobalActionsVisible = false; private boolean mGlobalActionsVisible = false;
private boolean mLastGlobalActionsVisible = false; private boolean mLastGlobalActionsVisible = false;
@@ -281,7 +279,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
private boolean mLastScreenOffAnimationPlaying; private boolean mLastScreenOffAnimationPlaying;
private float mQsExpansion; private float mQsExpansion;
final Set<KeyguardViewManagerCallback> mCallbacks = new HashSet<>(); final Set<KeyguardViewManagerCallback> mCallbacks = new HashSet<>();
private boolean mIsModernBouncerEnabled;
private boolean mIsUnoccludeTransitionFlagEnabled; private boolean mIsUnoccludeTransitionFlagEnabled;
private boolean mIsModernAlternateBouncerEnabled; private boolean mIsModernAlternateBouncerEnabled;
private boolean mIsBackAnimationEnabled; private boolean mIsBackAnimationEnabled;
@@ -329,7 +326,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
NotificationShadeWindowController notificationShadeWindowController, NotificationShadeWindowController notificationShadeWindowController,
KeyguardStateController keyguardStateController, KeyguardStateController keyguardStateController,
NotificationMediaManager notificationMediaManager, NotificationMediaManager notificationMediaManager,
KeyguardBouncer.Factory keyguardBouncerFactory,
KeyguardMessageAreaController.Factory keyguardMessageAreaFactory, KeyguardMessageAreaController.Factory keyguardMessageAreaFactory,
Optional<SysUIUnfoldComponent> sysUIUnfoldComponent, Optional<SysUIUnfoldComponent> sysUIUnfoldComponent,
Lazy<ShadeController> shadeController, Lazy<ShadeController> shadeController,
@@ -352,7 +348,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
mKeyguardUpdateManager = keyguardUpdateMonitor; mKeyguardUpdateManager = keyguardUpdateMonitor;
mStatusBarStateController = sysuiStatusBarStateController; mStatusBarStateController = sysuiStatusBarStateController;
mDockManager = dockManager; mDockManager = dockManager;
mKeyguardBouncerFactory = keyguardBouncerFactory;
mKeyguardMessageAreaFactory = keyguardMessageAreaFactory; mKeyguardMessageAreaFactory = keyguardMessageAreaFactory;
mShadeController = shadeController; mShadeController = shadeController;
mLatencyTracker = latencyTracker; mLatencyTracker = latencyTracker;
@@ -362,7 +357,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
mPrimaryBouncerView = primaryBouncerView; mPrimaryBouncerView = primaryBouncerView;
mFoldAodAnimationController = sysUIUnfoldComponent mFoldAodAnimationController = sysUIUnfoldComponent
.map(SysUIUnfoldComponent::getFoldAodAnimationController).orElse(null); .map(SysUIUnfoldComponent::getFoldAodAnimationController).orElse(null);
mIsModernBouncerEnabled = featureFlags.isEnabled(Flags.MODERN_BOUNCER);
mIsUnoccludeTransitionFlagEnabled = featureFlags.isEnabled(Flags.UNOCCLUSION_TRANSITION); mIsUnoccludeTransitionFlagEnabled = featureFlags.isEnabled(Flags.UNOCCLUSION_TRANSITION);
mIsModernAlternateBouncerEnabled = featureFlags.isEnabled(Flags.MODERN_ALTERNATE_BOUNCER); mIsModernAlternateBouncerEnabled = featureFlags.isEnabled(Flags.MODERN_ALTERNATE_BOUNCER);
mAlternateBouncerInteractor = alternateBouncerInteractor; mAlternateBouncerInteractor = alternateBouncerInteractor;
@@ -381,11 +375,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
mBiometricUnlockController = biometricUnlockController; mBiometricUnlockController = biometricUnlockController;
ViewGroup container = mCentralSurfaces.getBouncerContainer(); ViewGroup container = mCentralSurfaces.getBouncerContainer();
if (mIsModernBouncerEnabled) { mPrimaryBouncerCallbackInteractor.addBouncerExpansionCallback(mExpansionCallback);
mPrimaryBouncerCallbackInteractor.addBouncerExpansionCallback(mExpansionCallback);
} else {
mPrimaryBouncer = mKeyguardBouncerFactory.create(container, mExpansionCallback);
}
mNotificationPanelViewController = notificationPanelViewController; mNotificationPanelViewController = notificationPanelViewController;
if (shadeExpansionStateManager != null) { if (shadeExpansionStateManager != null) {
shadeExpansionStateManager.addExpansionListener(this); shadeExpansionStateManager.addExpansionListener(this);
@@ -552,11 +542,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
* show if any subsequent events are to be handled. * show if any subsequent events are to be handled.
*/ */
if (beginShowingBouncer(event)) { if (beginShowingBouncer(event)) {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.show(/* isScrimmed= */false);
mPrimaryBouncer.show(false /* resetSecuritySelection */, false /* scrimmed */);
} else {
mPrimaryBouncerInteractor.show(/* isScrimmed= */false);
}
} }
if (!primaryBouncerIsOrWillBeShowing()) { if (!primaryBouncerIsOrWillBeShowing()) {
@@ -564,17 +550,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
} }
if (mKeyguardStateController.isShowing()) { if (mKeyguardStateController.isShowing()) {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.setPanelExpansion(fraction);
mPrimaryBouncer.setExpansion(fraction);
} else {
mPrimaryBouncerInteractor.setPanelExpansion(fraction);
}
} else { } else {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.setPanelExpansion(EXPANSION_HIDDEN);
mPrimaryBouncer.setExpansion(EXPANSION_HIDDEN);
} else {
mPrimaryBouncerInteractor.setPanelExpansion(EXPANSION_HIDDEN);
}
} }
} }
@@ -604,24 +582,17 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
/** /**
* Shows the notification keyguard or the bouncer depending on * Shows the notification keyguard or the bouncer depending on
* {@link KeyguardBouncer#needsFullscreenBouncer()}. * {@link #needsFullscreenBouncer()}.
*/ */
protected void showBouncerOrKeyguard(boolean hideBouncerWhenShowing) { protected void showBouncerOrKeyguard(boolean hideBouncerWhenShowing) {
if (needsFullscreenBouncer() && !mDozing) { if (needsFullscreenBouncer() && !mDozing) {
// The keyguard might be showing (already). So we need to hide it. // The keyguard might be showing (already). So we need to hide it.
mCentralSurfaces.hideKeyguard(); mCentralSurfaces.hideKeyguard();
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.show(true);
mPrimaryBouncer.show(true /* resetSecuritySelection */);
} else {
mPrimaryBouncerInteractor.show(true);
}
} else { } else {
mCentralSurfaces.showKeyguard(); mCentralSurfaces.showKeyguard();
if (hideBouncerWhenShowing) { if (hideBouncerWhenShowing) {
hideBouncer(false /* destroyView */); hideBouncer(false /* destroyView */);
if (mPrimaryBouncer != null) {
mPrimaryBouncer.prepare();
}
} }
} }
updateStates(); updateStates();
@@ -648,11 +619,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
*/ */
@VisibleForTesting @VisibleForTesting
void hideBouncer(boolean destroyView) { void hideBouncer(boolean destroyView) {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.hide();
mPrimaryBouncer.hide(destroyView);
} else {
mPrimaryBouncerInteractor.hide();
}
if (mKeyguardStateController.isShowing()) { if (mKeyguardStateController.isShowing()) {
// If we were showing the bouncer and then aborting, we need to also clear out any // If we were showing the bouncer and then aborting, we need to also clear out any
// potential actions unless we actually unlocked. // potential actions unless we actually unlocked.
@@ -671,11 +638,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
hideAlternateBouncer(false); hideAlternateBouncer(false);
if (mKeyguardStateController.isShowing() && !isBouncerShowing()) { if (mKeyguardStateController.isShowing() && !isBouncerShowing()) {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.show(scrimmed);
mPrimaryBouncer.show(false /* resetSecuritySelection */, scrimmed);
} else {
mPrimaryBouncerInteractor.show(scrimmed);
}
} }
updateStates(); updateStates();
} }
@@ -708,13 +671,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
// instead of the bouncer. // instead of the bouncer.
if (mAlternateBouncerInteractor.canShowAlternateBouncerForFingerprint()) { if (mAlternateBouncerInteractor.canShowAlternateBouncerForFingerprint()) {
if (!afterKeyguardGone) { if (!afterKeyguardGone) {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.setDismissAction(mAfterKeyguardGoneAction,
mPrimaryBouncer.setDismissAction(mAfterKeyguardGoneAction, mKeyguardGoneCancelAction);
mKeyguardGoneCancelAction);
} else {
mPrimaryBouncerInteractor.setDismissAction(mAfterKeyguardGoneAction,
mKeyguardGoneCancelAction);
}
mAfterKeyguardGoneAction = null; mAfterKeyguardGoneAction = null;
mKeyguardGoneCancelAction = null; mKeyguardGoneCancelAction = null;
} }
@@ -726,22 +684,13 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
if (afterKeyguardGone) { if (afterKeyguardGone) {
// we'll handle the dismiss action after keyguard is gone, so just show the // we'll handle the dismiss action after keyguard is gone, so just show the
// bouncer // bouncer
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.show(/* isScrimmed= */true);
mPrimaryBouncer.show(false /* resetSecuritySelection */);
} else {
mPrimaryBouncerInteractor.show(/* isScrimmed= */true);
}
} else { } else {
// after authentication success, run dismiss action with the option to defer // after authentication success, run dismiss action with the option to defer
// hiding the keyguard based on the return value of the OnDismissAction // hiding the keyguard based on the return value of the OnDismissAction
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.setDismissAction(
mPrimaryBouncer.showWithDismissAction(mAfterKeyguardGoneAction, mAfterKeyguardGoneAction, mKeyguardGoneCancelAction);
mKeyguardGoneCancelAction); mPrimaryBouncerInteractor.show(/* isScrimmed= */true);
} else {
mPrimaryBouncerInteractor.setDismissAction(
mAfterKeyguardGoneAction, mKeyguardGoneCancelAction);
mPrimaryBouncerInteractor.show(/* isScrimmed= */true);
}
// bouncer will handle the dismiss action, so we no longer need to track it here // bouncer will handle the dismiss action, so we no longer need to track it here
mAfterKeyguardGoneAction = null; mAfterKeyguardGoneAction = null;
mKeyguardGoneCancelAction = null; mKeyguardGoneCancelAction = null;
@@ -841,11 +790,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
@Override @Override
public void onFinishedGoingToSleep() { public void onFinishedGoingToSleep() {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.onScreenTurnedOff();
mPrimaryBouncer.onScreenTurnedOff();
} else {
mPrimaryBouncerInteractor.onScreenTurnedOff();
}
} }
@Override @Override
@@ -939,11 +884,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
@Override @Override
public void startPreHideAnimation(Runnable finishRunnable) { public void startPreHideAnimation(Runnable finishRunnable) {
if (primaryBouncerIsShowing()) { if (primaryBouncerIsShowing()) {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.startDisappearAnimation(finishRunnable);
mPrimaryBouncer.startPreHideAnimation(finishRunnable);
} else {
mPrimaryBouncerInteractor.startDisappearAnimation(finishRunnable);
}
mNotificationPanelViewController.startBouncerPreHideAnimation(); mNotificationPanelViewController.startBouncerPreHideAnimation();
// We update the state (which will show the keyguard) only if an animation will run on // We update the state (which will show the keyguard) only if an animation will run on
@@ -1051,17 +992,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
} }
public void onThemeChanged() { public void onThemeChanged() {
if (mIsModernBouncerEnabled) { updateResources();
updateResources();
return;
}
boolean wasShowing = primaryBouncerIsShowing();
boolean wasScrimmed = primaryBouncerIsScrimmed();
hideBouncer(true /* destroyView */);
mPrimaryBouncer.prepare();
if (wasShowing) showPrimaryBouncer(wasScrimmed);
} }
public void onKeyguardFadedAway() { public void onKeyguardFadedAway() {
@@ -1106,10 +1037,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
* WARNING: This method might cause Binder calls. * WARNING: This method might cause Binder calls.
*/ */
public boolean isSecure() { public boolean isSecure() {
if (mPrimaryBouncer != null) {
return mPrimaryBouncer.isSecure();
}
return mKeyguardSecurityModel.getSecurityMode( return mKeyguardSecurityModel.getSecurityMode(
KeyguardUpdateMonitor.getCurrentUser()) != KeyguardSecurityModel.SecurityMode.None; KeyguardUpdateMonitor.getCurrentUser()) != KeyguardSecurityModel.SecurityMode.None;
} }
@@ -1164,10 +1091,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
} }
public boolean isFullscreenBouncer() { public boolean isFullscreenBouncer() {
if (mPrimaryBouncerView.getDelegate() != null) { return mPrimaryBouncerView.getDelegate() != null
return mPrimaryBouncerView.getDelegate().isFullScreenBouncer(); && mPrimaryBouncerView.getDelegate().isFullScreenBouncer();
}
return mPrimaryBouncer != null && mPrimaryBouncer.isFullscreenBouncer();
} }
/** /**
@@ -1223,17 +1148,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
!= (mLastBouncerDismissible || !mLastShowing || mLastRemoteInputActive) != (mLastBouncerDismissible || !mLastShowing || mLastRemoteInputActive)
|| mFirstUpdate) { || mFirstUpdate) {
if (primaryBouncerDismissible || !showing || remoteInputActive) { if (primaryBouncerDismissible || !showing || remoteInputActive) {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.setBackButtonEnabled(true);
mPrimaryBouncer.setBackButtonEnabled(true);
} else {
mPrimaryBouncerInteractor.setBackButtonEnabled(true);
}
} else { } else {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.setBackButtonEnabled(false);
mPrimaryBouncer.setBackButtonEnabled(false);
} else {
mPrimaryBouncerInteractor.setBackButtonEnabled(false);
}
} }
} }
@@ -1327,27 +1244,21 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
} }
public boolean shouldDismissOnMenuPressed() { public boolean shouldDismissOnMenuPressed() {
if (mPrimaryBouncerView.getDelegate() != null) { return mPrimaryBouncerView.getDelegate() != null
return mPrimaryBouncerView.getDelegate().shouldDismissOnMenuPressed(); && mPrimaryBouncerView.getDelegate().shouldDismissOnMenuPressed();
}
return mPrimaryBouncer != null && mPrimaryBouncer.shouldDismissOnMenuPressed();
} }
public boolean interceptMediaKey(KeyEvent event) { public boolean interceptMediaKey(KeyEvent event) {
if (mPrimaryBouncerView.getDelegate() != null) { return mPrimaryBouncerView.getDelegate() != null
return mPrimaryBouncerView.getDelegate().interceptMediaKey(event); && mPrimaryBouncerView.getDelegate().interceptMediaKey(event);
}
return mPrimaryBouncer != null && mPrimaryBouncer.interceptMediaKey(event);
} }
/** /**
* @return true if the pre IME back event should be handled * @return true if the pre IME back event should be handled
*/ */
public boolean dispatchBackKeyEventPreIme() { public boolean dispatchBackKeyEventPreIme() {
if (mPrimaryBouncerView.getDelegate() != null) { return mPrimaryBouncerView.getDelegate() != null
return mPrimaryBouncerView.getDelegate().dispatchBackKeyEventPreIme(); && mPrimaryBouncerView.getDelegate().dispatchBackKeyEventPreIme();
}
return mPrimaryBouncer != null && mPrimaryBouncer.dispatchBackKeyEventPreIme();
} }
public void readyForKeyguardDone() { public void readyForKeyguardDone() {
@@ -1393,11 +1304,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
* fingerprint. * fingerprint.
*/ */
public void notifyKeyguardAuthenticated(boolean strongAuth) { public void notifyKeyguardAuthenticated(boolean strongAuth) {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.notifyKeyguardAuthenticated(strongAuth);
mPrimaryBouncer.notifyKeyguardAuthenticated(strongAuth);
} else {
mPrimaryBouncerInteractor.notifyKeyguardAuthenticated(strongAuth);
}
if (mAlternateBouncerInteractor.isVisibleState()) { if (mAlternateBouncerInteractor.isVisibleState()) {
hideAlternateBouncer(false); hideAlternateBouncer(false);
@@ -1412,11 +1319,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
mKeyguardMessageAreaController.setMessage(message); mKeyguardMessageAreaController.setMessage(message);
} }
} else { } else {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.showMessage(message, colorState);
mPrimaryBouncer.showMessage(message, colorState);
} else {
mPrimaryBouncerInteractor.showMessage(message, colorState);
}
} }
} }
@@ -1472,11 +1375,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
* configuration. * configuration.
*/ */
public void updateResources() { public void updateResources() {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.updateResources();
mPrimaryBouncer.updateResources();
} else {
mPrimaryBouncerInteractor.updateResources();
}
} }
public void dump(PrintWriter pw) { public void dump(PrintWriter pw) {
@@ -1494,11 +1393,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
pw.println(" " + callback); pw.println(" " + callback);
} }
if (mPrimaryBouncer != null) {
pw.println("PrimaryBouncer:");
mPrimaryBouncer.dump(pw);
}
if (mOccludingAppBiometricUI != null) { if (mOccludingAppBiometricUI != null) {
pw.println("mOccludingAppBiometricUI:"); pw.println("mOccludingAppBiometricUI:");
mOccludingAppBiometricUI.dump(pw); mOccludingAppBiometricUI.dump(pw);
@@ -1548,11 +1442,6 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
} }
} }
@Nullable
public KeyguardBouncer getPrimaryBouncer() {
return mPrimaryBouncer;
}
/** /**
* For any touches on the NPVC, show the primary bouncer if the alternate bouncer is currently * For any touches on the NPVC, show the primary bouncer if the alternate bouncer is currently
* showing. * showing.
@@ -1571,11 +1460,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
/** Update keyguard position based on a tapped X coordinate. */ /** Update keyguard position based on a tapped X coordinate. */
public void updateKeyguardPosition(float x) { public void updateKeyguardPosition(float x) {
if (mPrimaryBouncer != null) { mPrimaryBouncerInteractor.setKeyguardPosition(x);
mPrimaryBouncer.updateKeyguardPosition(x);
} else {
mPrimaryBouncerInteractor.setKeyguardPosition(x);
}
} }
private static class DismissWithActionRequest { private static class DismissWithActionRequest {
@@ -1615,56 +1500,35 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
* Returns if bouncer expansion is between 0 and 1 non-inclusive. * Returns if bouncer expansion is between 0 and 1 non-inclusive.
*/ */
public boolean isPrimaryBouncerInTransit() { public boolean isPrimaryBouncerInTransit() {
if (mPrimaryBouncer != null) { return mPrimaryBouncerInteractor.isInTransit();
return mPrimaryBouncer.inTransit();
} else {
return mPrimaryBouncerInteractor.isInTransit();
}
} }
/** /**
* Returns if bouncer is showing * Returns if bouncer is showing
*/ */
public boolean primaryBouncerIsShowing() { public boolean primaryBouncerIsShowing() {
if (mPrimaryBouncer != null) { return mPrimaryBouncerInteractor.isFullyShowing();
return mPrimaryBouncer.isShowing();
} else {
return mPrimaryBouncerInteractor.isFullyShowing();
}
} }
/** /**
* Returns if bouncer is scrimmed * Returns if bouncer is scrimmed
*/ */
public boolean primaryBouncerIsScrimmed() { public boolean primaryBouncerIsScrimmed() {
if (mPrimaryBouncer != null) { return mPrimaryBouncerInteractor.isScrimmed();
return mPrimaryBouncer.isScrimmed();
} else {
return mPrimaryBouncerInteractor.isScrimmed();
}
} }
/** /**
* Returns if bouncer is animating away * Returns if bouncer is animating away
*/ */
public boolean bouncerIsAnimatingAway() { public boolean bouncerIsAnimatingAway() {
if (mPrimaryBouncer != null) { return mPrimaryBouncerInteractor.isAnimatingAway();
return mPrimaryBouncer.isAnimatingAway();
} else {
return mPrimaryBouncerInteractor.isAnimatingAway();
}
} }
/** /**
* Returns if bouncer will dismiss with action * Returns if bouncer will dismiss with action
*/ */
public boolean primaryBouncerWillDismissWithAction() { public boolean primaryBouncerWillDismissWithAction() {
if (mPrimaryBouncer != null) { return mPrimaryBouncerInteractor.willDismissWithAction();
return mPrimaryBouncer.willDismissWithAction();
} else {
return mPrimaryBouncerInteractor.willDismissWithAction();
}
} }
/** /**

View File

@@ -37,7 +37,6 @@ import com.android.systemui.shade.ShadeExpansionChangeEvent;
import com.android.systemui.shade.ShadeExpansionListener; import com.android.systemui.shade.ShadeExpansionListener;
import com.android.systemui.shade.ShadeExpansionStateManager; import com.android.systemui.shade.ShadeExpansionStateManager;
import com.android.systemui.statusbar.LockscreenShadeTransitionController; import com.android.systemui.statusbar.LockscreenShadeTransitionController;
import com.android.systemui.statusbar.phone.KeyguardBouncer;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import com.android.systemui.statusbar.phone.SystemUIDialogManager; import com.android.systemui.statusbar.phone.SystemUIDialogManager;
import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController; import com.android.systemui.statusbar.phone.UnlockedScreenOffAnimationController;
@@ -71,7 +70,6 @@ public class UdfpsKeyguardViewControllerBaseTest extends SysuiTestCase {
protected @Mock SystemUIDialogManager mDialogManager; protected @Mock SystemUIDialogManager mDialogManager;
protected @Mock UdfpsController mUdfpsController; protected @Mock UdfpsController mUdfpsController;
protected @Mock ActivityLaunchAnimator mActivityLaunchAnimator; protected @Mock ActivityLaunchAnimator mActivityLaunchAnimator;
protected @Mock KeyguardBouncer mBouncer;
protected @Mock PrimaryBouncerInteractor mPrimaryBouncerInteractor; protected @Mock PrimaryBouncerInteractor mPrimaryBouncerInteractor;
protected @Mock AlternateBouncerInteractor mAlternateBouncerInteractor; protected @Mock AlternateBouncerInteractor mAlternateBouncerInteractor;
@@ -152,8 +150,6 @@ public class UdfpsKeyguardViewControllerBaseTest extends SysuiTestCase {
mFeatureFlags.set(Flags.MODERN_BOUNCER, useModernBouncer); mFeatureFlags.set(Flags.MODERN_BOUNCER, useModernBouncer);
mFeatureFlags.set(Flags.MODERN_ALTERNATE_BOUNCER, useModernBouncer); mFeatureFlags.set(Flags.MODERN_ALTERNATE_BOUNCER, useModernBouncer);
mFeatureFlags.set(Flags.UDFPS_NEW_TOUCH_DETECTION, useExpandedOverlay); mFeatureFlags.set(Flags.UDFPS_NEW_TOUCH_DETECTION, useExpandedOverlay);
when(mStatusBarKeyguardViewManager.getPrimaryBouncer()).thenReturn(
useModernBouncer ? null : mBouncer);
UdfpsKeyguardViewController controller = new UdfpsKeyguardViewController( UdfpsKeyguardViewController controller = new UdfpsKeyguardViewController(
mView, mView,
mStatusBarStateController, mStatusBarStateController,

View File

@@ -32,24 +32,17 @@ import android.view.MotionEvent;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback;
import com.android.systemui.shade.ShadeExpansionListener; import com.android.systemui.shade.ShadeExpansionListener;
import com.android.systemui.statusbar.StatusBarState; import com.android.systemui.statusbar.StatusBarState;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
@SmallTest @SmallTest
@RunWith(AndroidTestingRunner.class) @RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper(setAsMainLooper = true) @TestableLooper.RunWithLooper(setAsMainLooper = true)
public class UdfpsKeyguardViewControllerTest extends UdfpsKeyguardViewControllerBaseTest { public class UdfpsKeyguardViewControllerTest extends UdfpsKeyguardViewControllerBaseTest {
private @Captor ArgumentCaptor<PrimaryBouncerExpansionCallback>
mBouncerExpansionCallbackCaptor;
private PrimaryBouncerExpansionCallback mBouncerExpansionCallback;
@Override @Override
public UdfpsKeyguardViewController createUdfpsKeyguardViewController() { public UdfpsKeyguardViewController createUdfpsKeyguardViewController() {
return createUdfpsKeyguardViewController(/* useModernBouncer */ false, return createUdfpsKeyguardViewController(/* useModernBouncer */ false,
@@ -62,11 +55,9 @@ public class UdfpsKeyguardViewControllerTest extends UdfpsKeyguardViewController
captureStatusBarStateListeners(); captureStatusBarStateListeners();
sendStatusBarStateChanged(StatusBarState.KEYGUARD); sendStatusBarStateChanged(StatusBarState.KEYGUARD);
captureBouncerExpansionCallback();
when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(true); when(mStatusBarKeyguardViewManager.isBouncerShowing()).thenReturn(true);
when(mStatusBarKeyguardViewManager.primaryBouncerIsOrWillBeShowing()).thenReturn(true); when(mStatusBarKeyguardViewManager.primaryBouncerIsOrWillBeShowing()).thenReturn(true);
mBouncerExpansionCallback.onVisibilityChanged(true); when(mView.getUnpausedAlpha()).thenReturn(0);
assertTrue(mController.shouldPauseAuth()); assertTrue(mController.shouldPauseAuth());
} }
@@ -304,11 +295,6 @@ public class UdfpsKeyguardViewControllerTest extends UdfpsKeyguardViewController
verify(mView, atLeastOnce()).setPauseAuth(false); verify(mView, atLeastOnce()).setPauseAuth(false);
} }
private void captureBouncerExpansionCallback() {
verify(mBouncer).addBouncerExpansionCallback(mBouncerExpansionCallbackCaptor.capture());
mBouncerExpansionCallback = mBouncerExpansionCallbackCaptor.getValue();
}
@Test @Test
// TODO(b/259264861): Tracking Bug // TODO(b/259264861): Tracking Bug
public void testUdfpsExpandedOverlayOn() { public void testUdfpsExpandedOverlayOn() {

View File

@@ -39,8 +39,6 @@ import com.android.systemui.dreams.complication.ComplicationHostViewController;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback; import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback;
import com.android.systemui.statusbar.BlurUtils; import com.android.systemui.statusbar.BlurUtils;
import com.android.systemui.statusbar.phone.KeyguardBouncer;
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
@@ -80,12 +78,6 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase {
@Mock @Mock
BlurUtils mBlurUtils; BlurUtils mBlurUtils;
@Mock
StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
@Mock
KeyguardBouncer mBouncer;
@Mock @Mock
ViewRootImpl mViewRoot; ViewRootImpl mViewRoot;
@@ -106,7 +98,6 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase {
when(mDreamOverlayContainerView.getResources()).thenReturn(mResources); when(mDreamOverlayContainerView.getResources()).thenReturn(mResources);
when(mDreamOverlayContainerView.getViewTreeObserver()).thenReturn(mViewTreeObserver); when(mDreamOverlayContainerView.getViewTreeObserver()).thenReturn(mViewTreeObserver);
when(mStatusBarKeyguardViewManager.getPrimaryBouncer()).thenReturn(mBouncer);
when(mDreamOverlayContainerView.getViewRootImpl()).thenReturn(mViewRoot); when(mDreamOverlayContainerView.getViewRootImpl()).thenReturn(mViewRoot);
mController = new DreamOverlayContainerViewController( mController = new DreamOverlayContainerViewController(
@@ -114,7 +105,6 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase {
mComplicationHostViewController, mComplicationHostViewController,
mDreamOverlayContentView, mDreamOverlayContentView,
mDreamOverlayStatusBarViewController, mDreamOverlayStatusBarViewController,
mStatusBarKeyguardViewManager,
mBlurUtils, mBlurUtils,
mHandler, mHandler,
mResources, mResources,
@@ -170,7 +160,8 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase {
final ArgumentCaptor<PrimaryBouncerExpansionCallback> bouncerExpansionCaptor = final ArgumentCaptor<PrimaryBouncerExpansionCallback> bouncerExpansionCaptor =
ArgumentCaptor.forClass(PrimaryBouncerExpansionCallback.class); ArgumentCaptor.forClass(PrimaryBouncerExpansionCallback.class);
mController.onViewAttached(); mController.onViewAttached();
verify(mBouncer).addBouncerExpansionCallback(bouncerExpansionCaptor.capture()); verify(mPrimaryBouncerCallbackInteractor).addBouncerExpansionCallback(
bouncerExpansionCaptor.capture());
bouncerExpansionCaptor.getValue().onExpansionChanged(0.5f); bouncerExpansionCaptor.getValue().onExpansionChanged(0.5f);
verify(mBlurUtils, never()).applyBlur(eq(mViewRoot), anyInt(), eq(false)); verify(mBlurUtils, never()).applyBlur(eq(mViewRoot), anyInt(), eq(false));
@@ -181,7 +172,8 @@ public class DreamOverlayContainerViewControllerTest extends SysuiTestCase {
final ArgumentCaptor<PrimaryBouncerExpansionCallback> bouncerExpansionCaptor = final ArgumentCaptor<PrimaryBouncerExpansionCallback> bouncerExpansionCaptor =
ArgumentCaptor.forClass(PrimaryBouncerExpansionCallback.class); ArgumentCaptor.forClass(PrimaryBouncerExpansionCallback.class);
mController.onViewAttached(); mController.onViewAttached();
verify(mBouncer).addBouncerExpansionCallback(bouncerExpansionCaptor.capture()); verify(mPrimaryBouncerCallbackInteractor).addBouncerExpansionCallback(
bouncerExpansionCaptor.capture());
final float blurRadius = 1337f; final float blurRadius = 1337f;
when(mBlurUtils.blurRadiusOfRatio(anyFloat())).thenReturn(blurRadius); when(mBlurUtils.blurRadiusOfRatio(anyFloat())).thenReturn(blurRadius);

View File

@@ -1,526 +0,0 @@
/*
* Copyright (C) 2017 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.systemui.statusbar.phone;
import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_HIDDEN;
import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_VISIBLE;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.hardware.biometrics.BiometricSourceType;
import android.os.Handler;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.test.filters.SmallTest;
import com.android.keyguard.KeyguardHostViewController;
import com.android.keyguard.KeyguardSecurityModel;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.ViewMediatorCallback;
import com.android.keyguard.dagger.KeyguardBouncerComponent;
import com.android.systemui.DejankUtils;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback;
import com.android.systemui.plugins.ActivityStarter.OnDismissAction;
import com.android.systemui.statusbar.policy.KeyguardStateController;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
public class KeyguardBouncerTest extends SysuiTestCase {
@Mock
private FalsingCollector mFalsingCollector;
@Mock
private ViewMediatorCallback mViewMediatorCallback;
@Mock
private DismissCallbackRegistry mDismissCallbackRegistry;
@Mock
private KeyguardHostViewController mKeyguardHostViewController;
@Mock
private PrimaryBouncerExpansionCallback mExpansionCallback;
@Mock
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock
private KeyguardStateController mKeyguardStateController;
@Mock
private KeyguardBypassController mKeyguardBypassController;
@Mock
private Handler mHandler;
@Mock
private KeyguardSecurityModel mKeyguardSecurityModel;
@Mock
private KeyguardBouncerComponent.Factory mKeyguardBouncerComponentFactory;
@Mock
private KeyguardBouncerComponent mKeyguardBouncerComponent;
private ViewGroup mContainer;
@Rule
public MockitoRule mRule = MockitoJUnit.rule();
private Integer mRootVisibility = View.INVISIBLE;
private KeyguardBouncer mBouncer;
@Before
public void setup() {
allowTestableLooperAsMainThread();
when(mKeyguardSecurityModel.getSecurityMode(anyInt()))
.thenReturn(KeyguardSecurityModel.SecurityMode.None);
DejankUtils.setImmediate(true);
mContainer = spy(new FrameLayout(getContext()));
when(mKeyguardBouncerComponentFactory.create(mContainer)).thenReturn(
mKeyguardBouncerComponent);
when(mKeyguardBouncerComponent.getKeyguardHostViewController())
.thenReturn(mKeyguardHostViewController);
mBouncer = new KeyguardBouncer.Factory(getContext(), mViewMediatorCallback,
mDismissCallbackRegistry, mFalsingCollector,
mKeyguardStateController, mKeyguardUpdateMonitor,
mKeyguardBypassController, mHandler, mKeyguardSecurityModel,
mKeyguardBouncerComponentFactory)
.create(mContainer, mExpansionCallback);
}
@Test
public void testInflateView_doesntCrash() {
mBouncer.inflateView();
}
@Test
public void testShow_notifiesFalsingManager() {
mBouncer.show(true);
verify(mFalsingCollector).onBouncerShown();
mBouncer.show(true, false);
verifyNoMoreInteractions(mFalsingCollector);
}
/**
* Regression test: Invisible bouncer when occluded.
*/
@Test
public void testShow_bouncerIsVisible() {
// Expand notification panel as if we were in the keyguard.
mBouncer.ensureView();
mBouncer.setExpansion(1);
reset(mKeyguardHostViewController);
mBouncer.show(true);
verify(mKeyguardHostViewController).setExpansion(0);
}
@Test
public void testShow_notifiesVisibility() {
mBouncer.show(true);
verify(mKeyguardStateController).notifyBouncerShowing(eq(true));
verify(mExpansionCallback).onStartingToShow();
// Not called again when visible
reset(mViewMediatorCallback);
mBouncer.show(true);
verifyNoMoreInteractions(mViewMediatorCallback);
}
@Test
public void testShow_triesToDismissKeyguard() {
mBouncer.show(true);
verify(mKeyguardHostViewController).dismiss(anyInt());
}
@Test
public void testShow_resetsSecuritySelection() {
mBouncer.show(false);
verify(mKeyguardHostViewController, never()).showPrimarySecurityScreen();
mBouncer.hide(false);
mBouncer.show(true);
verify(mKeyguardHostViewController).showPrimarySecurityScreen();
}
@Test
public void testShow_animatesKeyguardView() {
mBouncer.show(true);
verify(mKeyguardHostViewController).appear(anyInt());
}
@Test
public void testShow_showsErrorMessage() {
final String errorMessage = "an error message";
when(mViewMediatorCallback.consumeCustomMessage()).thenReturn(errorMessage);
mBouncer.show(true);
verify(mKeyguardHostViewController).showErrorMessage(eq(errorMessage));
}
@Test
public void testSetExpansion_notifiesFalsingManager() {
mBouncer.ensureView();
mBouncer.setExpansion(0.5f);
mBouncer.setExpansion(EXPANSION_HIDDEN);
verify(mFalsingCollector).onBouncerHidden();
verify(mExpansionCallback).onFullyHidden();
mBouncer.setExpansion(EXPANSION_VISIBLE);
verify(mFalsingCollector).onBouncerShown();
verify(mExpansionCallback).onFullyShown();
verify(mExpansionCallback, never()).onStartingToHide();
verify(mKeyguardHostViewController, never()).onStartingToHide();
mBouncer.setExpansion(0.9f);
verify(mExpansionCallback).onStartingToHide();
verify(mKeyguardHostViewController).onStartingToHide();
}
@Test
public void testSetExpansion_notifiesKeyguardView() {
mBouncer.ensureView();
mBouncer.setExpansion(0.1f);
mBouncer.setExpansion(0);
verify(mKeyguardHostViewController).onResume();
verify(mContainer).announceForAccessibility(any());
}
@Test
public void show_notifiesKeyguardViewController() {
mBouncer.ensureView();
mBouncer.show(/* resetSecuritySelection= */ false);
verify(mKeyguardHostViewController).onBouncerVisibilityChanged(View.VISIBLE);
}
@Test
public void testHide_notifiesFalsingManager() {
mBouncer.hide(false);
verify(mFalsingCollector).onBouncerHidden();
}
@Test
public void testHide_notifiesVisibility() {
mBouncer.hide(false);
verify(mKeyguardStateController).notifyBouncerShowing(eq(false));
}
@Test
public void testHide_notifiesDismissCallbackIfVisible() {
mBouncer.hide(false);
verifyZeroInteractions(mDismissCallbackRegistry);
mBouncer.show(false);
mBouncer.hide(false);
verify(mDismissCallbackRegistry).notifyDismissCancelled();
}
@Test
public void testHide_notShowingAnymore() {
mBouncer.ensureView();
mBouncer.show(false /* resetSecuritySelection */);
mBouncer.hide(false /* destroyViews */);
Assert.assertFalse("Not showing", mBouncer.isShowing());
}
@Test
public void testShowPromptReason_propagates() {
mBouncer.ensureView();
mBouncer.showPromptReason(1);
verify(mKeyguardHostViewController).showPromptReason(eq(1));
}
@Test
public void testShowMessage_propagates() {
final String message = "a message";
mBouncer.ensureView();
mBouncer.showMessage(message, ColorStateList.valueOf(Color.GREEN));
verify(mKeyguardHostViewController).showMessage(
eq(message), eq(ColorStateList.valueOf(Color.GREEN)));
}
@Test
public void testShowOnDismissAction_showsBouncer() {
final OnDismissAction dismissAction = () -> false;
final Runnable cancelAction = () -> {};
mBouncer.showWithDismissAction(dismissAction, cancelAction);
verify(mKeyguardHostViewController).setOnDismissAction(dismissAction, cancelAction);
Assert.assertTrue("Should be showing", mBouncer.isShowing());
}
@Test
public void testStartPreHideAnimation_notifiesView() {
final boolean[] ran = {false};
final Runnable r = () -> ran[0] = true;
mBouncer.startPreHideAnimation(r);
Assert.assertTrue("Callback should have been invoked", ran[0]);
ran[0] = false;
mBouncer.ensureView();
mBouncer.startPreHideAnimation(r);
verify(mKeyguardHostViewController).startDisappearAnimation(r);
Assert.assertFalse("Callback should have been deferred", ran[0]);
}
@Test
public void testIsShowing_animated() {
Assert.assertFalse("Show wasn't invoked yet", mBouncer.isShowing());
mBouncer.show(true /* reset */);
Assert.assertTrue("Should be showing", mBouncer.isShowing());
}
@Test
public void testIsShowing_forSwipeUp() {
mBouncer.setExpansion(1f);
mBouncer.show(true /* reset */, false /* animated */);
Assert.assertFalse("Should only be showing after collapsing notification panel",
mBouncer.isShowing());
mBouncer.setExpansion(0f);
Assert.assertTrue("Should be showing", mBouncer.isShowing());
}
@Test
public void testSetExpansion() {
mBouncer.ensureView();
mBouncer.setExpansion(0.5f);
verify(mKeyguardHostViewController).setExpansion(0.5f);
}
@Test
public void testIsFullscreenBouncer_asksKeyguardView() {
mBouncer.ensureView();
mBouncer.isFullscreenBouncer();
verify(mKeyguardHostViewController).getCurrentSecurityMode();
}
@Test
public void testIsHiding_preHideOrHide() {
Assert.assertFalse("Should not be hiding on initial state", mBouncer.isAnimatingAway());
mBouncer.startPreHideAnimation(null /* runnable */);
Assert.assertTrue("Should be hiding during pre-hide", mBouncer.isAnimatingAway());
mBouncer.hide(false /* destroyView */);
Assert.assertFalse("Should be hidden after hide()", mBouncer.isAnimatingAway());
}
@Test
public void testIsHiding_skipsTranslation() {
mBouncer.show(false /* reset */);
reset(mKeyguardHostViewController);
mBouncer.startPreHideAnimation(null /* runnable */);
mBouncer.setExpansion(0.5f);
verify(mKeyguardHostViewController, never()).setExpansion(anyFloat());
}
@Test
public void testIsSecure() {
mBouncer.ensureView();
for (KeyguardSecurityModel.SecurityMode mode : KeyguardSecurityModel.SecurityMode.values()){
reset(mKeyguardSecurityModel);
when(mKeyguardSecurityModel.getSecurityMode(anyInt())).thenReturn(mode);
Assert.assertEquals("Security doesn't match for mode: " + mode,
mBouncer.isSecure(), mode != KeyguardSecurityModel.SecurityMode.None);
}
}
@Test
public void testIsShowingScrimmed_true() {
doAnswer(invocation -> {
assertThat(mBouncer.isScrimmed()).isTrue();
return null;
}).when(mExpansionCallback).onFullyShown();
mBouncer.show(false /* resetSecuritySelection */, true /* animate */);
assertThat(mBouncer.isScrimmed()).isTrue();
mBouncer.hide(false /* destroyView */);
assertThat(mBouncer.isScrimmed()).isFalse();
}
@Test
public void testIsShowingScrimmed_false() {
doAnswer(invocation -> {
assertThat(mBouncer.isScrimmed()).isFalse();
return null;
}).when(mExpansionCallback).onFullyShown();
mBouncer.show(false /* resetSecuritySelection */, false /* animate */);
assertThat(mBouncer.isScrimmed()).isFalse();
}
@Test
public void testWillDismissWithAction() {
mBouncer.ensureView();
Assert.assertFalse("Action not set yet", mBouncer.willDismissWithAction());
when(mKeyguardHostViewController.hasDismissActions()).thenReturn(true);
Assert.assertTrue("Action should exist", mBouncer.willDismissWithAction());
}
@Test
public void testShow_delaysIfFaceAuthIsRunning() {
when(mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed(BiometricSourceType.FACE))
.thenReturn(true);
when(mKeyguardStateController.isFaceAuthEnabled()).thenReturn(true);
mBouncer.show(true /* reset */);
ArgumentCaptor<Runnable> showRunnable = ArgumentCaptor.forClass(Runnable.class);
verify(mHandler).postDelayed(showRunnable.capture(),
eq(KeyguardBouncer.BOUNCER_FACE_DELAY));
mBouncer.hide(false /* destroyView */);
verify(mHandler).removeCallbacks(eq(showRunnable.getValue()));
}
@Test
public void testShow_doesNotDelaysIfFaceAuthIsNotAllowed() {
when(mKeyguardStateController.isFaceAuthEnabled()).thenReturn(true);
when(mKeyguardUpdateMonitor.isUnlockingWithBiometricAllowed(BiometricSourceType.FACE))
.thenReturn(false);
mBouncer.show(true /* reset */);
verify(mHandler, never()).postDelayed(any(), anyLong());
}
@Test
public void testShow_delaysIfFaceAuthIsRunning_unlessBypassEnabled() {
when(mKeyguardStateController.isFaceAuthEnabled()).thenReturn(true);
when(mKeyguardBypassController.getBypassEnabled()).thenReturn(true);
mBouncer.show(true /* reset */);
verify(mHandler, never()).postDelayed(any(), anyLong());
}
@Test
public void testShow_delaysIfFaceAuthIsRunning_unlessFingerprintEnrolled() {
when(mKeyguardStateController.isFaceAuthEnabled()).thenReturn(true);
when(mKeyguardUpdateMonitor.getCachedIsUnlockWithFingerprintPossible(0))
.thenReturn(true);
mBouncer.show(true /* reset */);
verify(mHandler, never()).postDelayed(any(), anyLong());
}
@Test
public void testRegisterUpdateMonitorCallback() {
verify(mKeyguardUpdateMonitor).registerCallback(any());
}
@Test
public void testInTransit_whenTranslation() {
mBouncer.show(true);
mBouncer.setExpansion(EXPANSION_HIDDEN);
assertThat(mBouncer.inTransit()).isFalse();
mBouncer.setExpansion(0.5f);
assertThat(mBouncer.inTransit()).isTrue();
mBouncer.setExpansion(EXPANSION_VISIBLE);
assertThat(mBouncer.inTransit()).isFalse();
}
@Test
public void testUpdateResources_delegatesToRootView() {
mBouncer.ensureView();
mBouncer.updateResources();
// This is mocked, so won't pick up on the call to updateResources via
// mKeyguardViewController.init(), only updateResources above.
verify(mKeyguardHostViewController).updateResources();
}
@Test
public void testUpdateKeyguardPosition_delegatesToRootView() {
mBouncer.ensureView();
mBouncer.updateKeyguardPosition(1.0f);
verify(mKeyguardHostViewController).updateKeyguardPosition(1.0f);
}
@Test
public void testExpansion_notifiesCallback() {
mBouncer.ensureView();
mBouncer.setExpansion(0.5f);
final PrimaryBouncerExpansionCallback callback =
mock(PrimaryBouncerExpansionCallback.class);
mBouncer.addBouncerExpansionCallback(callback);
mBouncer.setExpansion(EXPANSION_HIDDEN);
verify(callback).onFullyHidden();
verify(callback).onExpansionChanged(EXPANSION_HIDDEN);
Mockito.clearInvocations(callback);
mBouncer.setExpansion(EXPANSION_VISIBLE);
verify(callback).onFullyShown();
verify(callback).onExpansionChanged(EXPANSION_VISIBLE);
Mockito.clearInvocations(callback);
float bouncerHideAmount = 0.9f;
// Ensure the callback only triggers once despite multiple calls to setExpansion
// with the same value.
mBouncer.setExpansion(bouncerHideAmount);
mBouncer.setExpansion(bouncerHideAmount);
verify(callback, times(1)).onStartingToHide();
verify(callback, times(1)).onExpansionChanged(bouncerHideAmount);
Mockito.clearInvocations(callback);
mBouncer.removeBouncerExpansionCallback(callback);
bouncerHideAmount = 0.5f;
mBouncer.setExpansion(bouncerHideAmount);
verify(callback, never()).onExpansionChanged(bouncerHideAmount);
}
@Test
public void testOnResumeCalledForFullscreenBouncerOnSecondShow() {
// GIVEN a security mode which requires fullscreen bouncer
when(mKeyguardSecurityModel.getSecurityMode(anyInt()))
.thenReturn(KeyguardSecurityModel.SecurityMode.SimPin);
mBouncer.show(true);
// WHEN a second call to show occurs, the bouncer will already by visible
reset(mKeyguardHostViewController);
mBouncer.show(true);
// THEN ensure the ViewController is told to resume
verify(mKeyguardHostViewController).onResume();
}
}

View File

@@ -16,7 +16,6 @@
package com.android.systemui.statusbar.phone; package com.android.systemui.statusbar.phone;
import static com.android.systemui.flags.Flags.MODERN_BOUNCER;
import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_HIDDEN; import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_HIDDEN;
import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_VISIBLE; import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_VISIBLE;
@@ -109,7 +108,6 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
@Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock private View mNotificationContainer; @Mock private View mNotificationContainer;
@Mock private KeyguardBypassController mBypassController; @Mock private KeyguardBypassController mBypassController;
@Mock private KeyguardBouncer.Factory mKeyguardBouncerFactory;
@Mock private KeyguardMessageAreaController.Factory mKeyguardMessageAreaFactory; @Mock private KeyguardMessageAreaController.Factory mKeyguardMessageAreaFactory;
@Mock private KeyguardMessageAreaController mKeyguardMessageAreaController; @Mock private KeyguardMessageAreaController mKeyguardMessageAreaController;
@Mock private KeyguardMessageArea mKeyguardMessageArea; @Mock private KeyguardMessageArea mKeyguardMessageArea;
@@ -153,8 +151,6 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
.isEnabled(Flags.WM_ENABLE_PREDICTIVE_BACK_BOUNCER_ANIM)) .isEnabled(Flags.WM_ENABLE_PREDICTIVE_BACK_BOUNCER_ANIM))
.thenReturn(true); .thenReturn(true);
when(mFeatureFlags.isEnabled(MODERN_BOUNCER)).thenReturn(true);
mStatusBarKeyguardViewManager = mStatusBarKeyguardViewManager =
new StatusBarKeyguardViewManager( new StatusBarKeyguardViewManager(
getContext(), getContext(),
@@ -169,7 +165,6 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mock(NotificationShadeWindowController.class), mock(NotificationShadeWindowController.class),
mKeyguardStateController, mKeyguardStateController,
mock(NotificationMediaManager.class), mock(NotificationMediaManager.class),
mKeyguardBouncerFactory,
mKeyguardMessageAreaFactory, mKeyguardMessageAreaFactory,
Optional.of(mSysUiUnfoldComponent), Optional.of(mSysUiUnfoldComponent),
() -> mShadeController, () -> mShadeController,
@@ -660,7 +655,6 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
mock(NotificationShadeWindowController.class), mock(NotificationShadeWindowController.class),
mKeyguardStateController, mKeyguardStateController,
mock(NotificationMediaManager.class), mock(NotificationMediaManager.class),
mKeyguardBouncerFactory,
mKeyguardMessageAreaFactory, mKeyguardMessageAreaFactory,
Optional.of(mSysUiUnfoldComponent), Optional.of(mSysUiUnfoldComponent),
() -> mShadeController, () -> mShadeController,

View File

@@ -1,581 +0,0 @@
/*
* Copyright (C) 2018 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.systemui.statusbar.phone;
import static com.android.systemui.flags.Flags.MODERN_BOUNCER;
import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_HIDDEN;
import static com.android.systemui.keyguard.shared.constants.KeyguardBouncerConstants.EXPANSION_VISIBLE;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewRootImpl;
import android.window.OnBackInvokedCallback;
import android.window.OnBackInvokedDispatcher;
import android.window.WindowOnBackInvokedDispatcher;
import androidx.test.filters.SmallTest;
import com.android.internal.util.LatencyTracker;
import com.android.internal.widget.LockPatternUtils;
import com.android.keyguard.KeyguardMessageArea;
import com.android.keyguard.KeyguardMessageAreaController;
import com.android.keyguard.KeyguardSecurityModel;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.ViewMediatorCallback;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.dock.DockManager;
import com.android.systemui.dreams.DreamOverlayStateController;
import com.android.systemui.flags.FeatureFlags;
import com.android.systemui.keyguard.data.BouncerView;
import com.android.systemui.keyguard.data.BouncerViewDelegate;
import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback;
import com.android.systemui.keyguard.domain.interactor.PrimaryBouncerInteractor;
import com.android.systemui.navigationbar.NavigationModeController;
import com.android.systemui.plugins.ActivityStarter.OnDismissAction;
import com.android.systemui.shade.NotificationPanelViewController;
import com.android.systemui.shade.ShadeController;
import com.android.systemui.shade.ShadeExpansionChangeEvent;
import com.android.systemui.shade.ShadeExpansionStateManager;
import com.android.systemui.statusbar.NotificationMediaManager;
import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.SysuiStatusBarStateController;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.unfold.SysUIUnfoldComponent;
import com.google.common.truth.Truth;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import java.util.Optional;
/**
* StatusBarKeyguardViewManager Test with deprecated KeyguardBouncer.java.
* TODO: Delete when deleting {@link KeyguardBouncer}
*/
@SmallTest
@RunWith(AndroidTestingRunner.class)
@TestableLooper.RunWithLooper
public class StatusBarKeyguardViewManagerTest_Old extends SysuiTestCase {
private static final ShadeExpansionChangeEvent EXPANSION_EVENT =
expansionEvent(/* fraction= */ 0.5f, /* expanded= */ false, /* tracking= */ true);
@Mock private ViewMediatorCallback mViewMediatorCallback;
@Mock private LockPatternUtils mLockPatternUtils;
@Mock private CentralSurfaces mCentralSurfaces;
@Mock private ViewGroup mContainer;
@Mock private NotificationPanelViewController mNotificationPanelView;
@Mock private BiometricUnlockController mBiometricUnlockController;
@Mock private SysuiStatusBarStateController mStatusBarStateController;
@Mock private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
@Mock private View mNotificationContainer;
@Mock private KeyguardBypassController mBypassController;
@Mock private KeyguardBouncer.Factory mKeyguardBouncerFactory;
@Mock private KeyguardMessageAreaController.Factory mKeyguardMessageAreaFactory;
@Mock private KeyguardMessageAreaController mKeyguardMessageAreaController;
@Mock private KeyguardBouncer mPrimaryBouncer;
@Mock private KeyguardMessageArea mKeyguardMessageArea;
@Mock private ShadeController mShadeController;
@Mock private SysUIUnfoldComponent mSysUiUnfoldComponent;
@Mock private DreamOverlayStateController mDreamOverlayStateController;
@Mock private LatencyTracker mLatencyTracker;
@Mock private FeatureFlags mFeatureFlags;
@Mock private KeyguardSecurityModel mKeyguardSecurityModel;
@Mock private PrimaryBouncerCallbackInteractor mPrimaryBouncerCallbackInteractor;
@Mock private PrimaryBouncerInteractor mPrimaryBouncerInteractor;
@Mock private AlternateBouncerInteractor mAlternateBouncerInteractor;
@Mock private BouncerView mBouncerView;
@Mock private BouncerViewDelegate mBouncerViewDelegate;
private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
private PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback
mBouncerExpansionCallback;
private FakeKeyguardStateController mKeyguardStateController =
spy(new FakeKeyguardStateController());
@Mock private ViewRootImpl mViewRootImpl;
@Mock private WindowOnBackInvokedDispatcher mOnBackInvokedDispatcher;
@Captor
private ArgumentCaptor<OnBackInvokedCallback> mOnBackInvokedCallback;
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
when(mKeyguardBouncerFactory.create(
any(ViewGroup.class),
any(PrimaryBouncerExpansionCallback.class)))
.thenReturn(mPrimaryBouncer);
when(mCentralSurfaces.getBouncerContainer()).thenReturn(mContainer);
when(mContainer.findViewById(anyInt())).thenReturn(mKeyguardMessageArea);
when(mKeyguardMessageAreaFactory.create(any(KeyguardMessageArea.class)))
.thenReturn(mKeyguardMessageAreaController);
when(mBouncerView.getDelegate()).thenReturn(mBouncerViewDelegate);
mStatusBarKeyguardViewManager =
new StatusBarKeyguardViewManager(
getContext(),
mViewMediatorCallback,
mLockPatternUtils,
mStatusBarStateController,
mock(ConfigurationController.class),
mKeyguardUpdateMonitor,
mDreamOverlayStateController,
mock(NavigationModeController.class),
mock(DockManager.class),
mock(NotificationShadeWindowController.class),
mKeyguardStateController,
mock(NotificationMediaManager.class),
mKeyguardBouncerFactory,
mKeyguardMessageAreaFactory,
Optional.of(mSysUiUnfoldComponent),
() -> mShadeController,
mLatencyTracker,
mKeyguardSecurityModel,
mFeatureFlags,
mPrimaryBouncerCallbackInteractor,
mPrimaryBouncerInteractor,
mBouncerView,
mAlternateBouncerInteractor) {
@Override
public ViewRootImpl getViewRootImpl() {
return mViewRootImpl;
}
};
when(mViewRootImpl.getOnBackInvokedDispatcher())
.thenReturn(mOnBackInvokedDispatcher);
mStatusBarKeyguardViewManager.registerCentralSurfaces(
mCentralSurfaces,
mNotificationPanelView,
new ShadeExpansionStateManager(),
mBiometricUnlockController,
mNotificationContainer,
mBypassController);
mStatusBarKeyguardViewManager.show(null);
ArgumentCaptor<PrimaryBouncerExpansionCallback> callbackArgumentCaptor =
ArgumentCaptor.forClass(PrimaryBouncerExpansionCallback.class);
verify(mKeyguardBouncerFactory).create(any(ViewGroup.class),
callbackArgumentCaptor.capture());
mBouncerExpansionCallback = callbackArgumentCaptor.getValue();
}
@Test
public void dismissWithAction_AfterKeyguardGoneSetToFalse() {
OnDismissAction action = () -> false;
Runnable cancelAction = () -> {};
mStatusBarKeyguardViewManager.dismissWithAction(
action, cancelAction, false /* afterKeyguardGone */);
verify(mPrimaryBouncer).showWithDismissAction(eq(action), eq(cancelAction));
}
@Test
public void showBouncer_onlyWhenShowing() {
mStatusBarKeyguardViewManager.hide(0 /* startTime */, 0 /* fadeoutDuration */);
mStatusBarKeyguardViewManager.showPrimaryBouncer(true /* scrimmed */);
verify(mPrimaryBouncer, never()).show(anyBoolean(), anyBoolean());
verify(mPrimaryBouncer, never()).show(anyBoolean());
}
@Test
public void showBouncer_notWhenBouncerAlreadyShowing() {
mStatusBarKeyguardViewManager.hide(0 /* startTime */, 0 /* fadeoutDuration */);
when(mPrimaryBouncer.isSecure()).thenReturn(true);
mStatusBarKeyguardViewManager.showPrimaryBouncer(true /* scrimmed */);
verify(mPrimaryBouncer, never()).show(anyBoolean(), anyBoolean());
verify(mPrimaryBouncer, never()).show(anyBoolean());
}
@Test
public void showBouncer_showsTheBouncer() {
mStatusBarKeyguardViewManager.showPrimaryBouncer(true /* scrimmed */);
verify(mPrimaryBouncer).show(anyBoolean(), eq(true));
}
@Test
public void onPanelExpansionChanged_neverShowsDuringHintAnimation() {
when(mNotificationPanelView.isUnlockHintRunning()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mPrimaryBouncer, never()).setExpansion(anyFloat());
}
@Test
public void onPanelExpansionChanged_propagatesToBouncerOnlyIfShowing() {
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mPrimaryBouncer, never()).setExpansion(eq(0.5f));
when(mPrimaryBouncer.isShowing()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
expansionEvent(/* fraction= */ 0.6f, /* expanded= */ false, /* tracking= */ true));
verify(mPrimaryBouncer).setExpansion(eq(0.6f));
}
@Test
public void onPanelExpansionChanged_duplicateEventsAreIgnored() {
when(mPrimaryBouncer.isShowing()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mPrimaryBouncer).setExpansion(eq(0.5f));
reset(mPrimaryBouncer);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mPrimaryBouncer, never()).setExpansion(eq(0.5f));
}
@Test
public void onPanelExpansionChanged_hideBouncer_afterKeyguardHidden() {
mStatusBarKeyguardViewManager.hide(0, 0);
when(mPrimaryBouncer.inTransit()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mPrimaryBouncer).setExpansion(eq(EXPANSION_HIDDEN));
}
@Test
public void onPanelExpansionChanged_showsBouncerWhenSwiping() {
mKeyguardStateController.setCanDismissLockScreen(false);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mPrimaryBouncer).show(eq(false), eq(false));
// But not when it's already visible
reset(mPrimaryBouncer);
when(mPrimaryBouncer.isShowing()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mPrimaryBouncer, never()).show(eq(false), eq(false));
// Or animating away
reset(mPrimaryBouncer);
when(mPrimaryBouncer.isAnimatingAway()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(EXPANSION_EVENT);
verify(mPrimaryBouncer, never()).show(eq(false), eq(false));
}
@Test
public void onPanelExpansionChanged_neverTranslatesBouncerWhenWakeAndUnlock() {
when(mBiometricUnlockController.getMode())
.thenReturn(BiometricUnlockController.MODE_WAKE_AND_UNLOCK);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
expansionEvent(
/* fraction= */ EXPANSION_VISIBLE,
/* expanded= */ true,
/* tracking= */ false));
verify(mPrimaryBouncer, never()).setExpansion(anyFloat());
}
@Test
public void onPanelExpansionChanged_neverTranslatesBouncerWhenDismissBouncer() {
// Since KeyguardBouncer.EXPANSION_VISIBLE = 0 panel expansion, if the unlock is dismissing
// the bouncer, there may be an onPanelExpansionChanged(0) call to collapse the panel
// which would mistakenly cause the bouncer to show briefly before its visibility
// is set to hide. Therefore, we don't want to propagate panelExpansionChanged to the
// bouncer if the bouncer is dismissing as a result of a biometric unlock.
when(mBiometricUnlockController.getMode())
.thenReturn(BiometricUnlockController.MODE_DISMISS_BOUNCER);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
expansionEvent(
/* fraction= */ EXPANSION_VISIBLE,
/* expanded= */ true,
/* tracking= */ false));
verify(mPrimaryBouncer, never()).setExpansion(anyFloat());
}
@Test
public void onPanelExpansionChanged_neverTranslatesBouncerWhenOccluded() {
when(mKeyguardStateController.isOccluded()).thenReturn(true);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
expansionEvent(
/* fraction= */ EXPANSION_VISIBLE,
/* expanded= */ true,
/* tracking= */ false));
verify(mPrimaryBouncer, never()).setExpansion(anyFloat());
}
@Test
public void onPanelExpansionChanged_neverTranslatesBouncerWhenShowBouncer() {
// Since KeyguardBouncer.EXPANSION_VISIBLE = 0 panel expansion, if the unlock is dismissing
// the bouncer, there may be an onPanelExpansionChanged(0) call to collapse the panel
// which would mistakenly cause the bouncer to show briefly before its visibility
// is set to hide. Therefore, we don't want to propagate panelExpansionChanged to the
// bouncer if the bouncer is dismissing as a result of a biometric unlock.
when(mBiometricUnlockController.getMode())
.thenReturn(BiometricUnlockController.MODE_SHOW_BOUNCER);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
expansionEvent(
/* fraction= */ EXPANSION_VISIBLE,
/* expanded= */ true,
/* tracking= */ false));
verify(mPrimaryBouncer, never()).setExpansion(anyFloat());
}
@Test
public void onPanelExpansionChanged_neverTranslatesBouncerWhenShadeLocked() {
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE_LOCKED);
mStatusBarKeyguardViewManager.onPanelExpansionChanged(
expansionEvent(
/* fraction= */ EXPANSION_VISIBLE,
/* expanded= */ true,
/* tracking= */ false));
verify(mPrimaryBouncer, never()).setExpansion(anyFloat());
}
@Test
public void setOccluded_animatesPanelExpansion_onlyIfBouncerHidden() {
mStatusBarKeyguardViewManager.setOccluded(false /* occluded */, true /* animated */);
verify(mCentralSurfaces).animateKeyguardUnoccluding();
when(mPrimaryBouncer.isShowing()).thenReturn(true);
clearInvocations(mCentralSurfaces);
mStatusBarKeyguardViewManager.setOccluded(false /* occluded */, true /* animated */);
verify(mCentralSurfaces, never()).animateKeyguardUnoccluding();
}
@Test
public void setOccluded_onKeyguardOccludedChangedCalled() {
clearInvocations(mKeyguardStateController);
clearInvocations(mKeyguardUpdateMonitor);
mStatusBarKeyguardViewManager.setOccluded(false /* occluded */, false /* animated */);
verify(mKeyguardStateController).notifyKeyguardState(true, false);
clearInvocations(mKeyguardUpdateMonitor);
clearInvocations(mKeyguardStateController);
mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */);
verify(mKeyguardStateController).notifyKeyguardState(true, true);
clearInvocations(mKeyguardUpdateMonitor);
clearInvocations(mKeyguardStateController);
mStatusBarKeyguardViewManager.setOccluded(false /* occluded */, false /* animated */);
verify(mKeyguardStateController).notifyKeyguardState(true, false);
}
@Test
public void setOccluded_isInLaunchTransition_onKeyguardOccludedChangedCalled() {
mStatusBarKeyguardViewManager.show(null);
mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */);
verify(mKeyguardStateController).notifyKeyguardState(true, true);
}
@Test
public void setOccluded_isLaunchingActivityOverLockscreen_onKeyguardOccludedChangedCalled() {
when(mCentralSurfaces.isLaunchingActivityOverLockscreen()).thenReturn(true);
mStatusBarKeyguardViewManager.show(null);
mStatusBarKeyguardViewManager.setOccluded(true /* occluded */, false /* animated */);
verify(mKeyguardStateController).notifyKeyguardState(true, true);
}
@Test
public void testHiding_cancelsGoneRunnable() {
OnDismissAction action = mock(OnDismissAction.class);
Runnable cancelAction = mock(Runnable.class);
mStatusBarKeyguardViewManager.dismissWithAction(
action, cancelAction, true /* afterKeyguardGone */);
when(mPrimaryBouncer.isShowing()).thenReturn(false);
mStatusBarKeyguardViewManager.hideBouncer(true);
mStatusBarKeyguardViewManager.hide(0, 30);
verify(action, never()).onDismiss();
verify(cancelAction).run();
}
@Test
public void testHidingBouncer_cancelsGoneRunnable() {
OnDismissAction action = mock(OnDismissAction.class);
Runnable cancelAction = mock(Runnable.class);
mStatusBarKeyguardViewManager.dismissWithAction(
action, cancelAction, true /* afterKeyguardGone */);
when(mPrimaryBouncer.isShowing()).thenReturn(false);
mStatusBarKeyguardViewManager.hideBouncer(true);
verify(action, never()).onDismiss();
verify(cancelAction).run();
}
@Test
public void testHiding_doesntCancelWhenShowing() {
OnDismissAction action = mock(OnDismissAction.class);
Runnable cancelAction = mock(Runnable.class);
mStatusBarKeyguardViewManager.dismissWithAction(
action, cancelAction, true /* afterKeyguardGone */);
mStatusBarKeyguardViewManager.hide(0, 30);
verify(action).onDismiss();
verify(cancelAction, never()).run();
}
@Test
public void testBouncerIsOrWillBeShowing_whenBouncerIsInTransit() {
when(mPrimaryBouncer.isShowing()).thenReturn(false);
when(mPrimaryBouncer.inTransit()).thenReturn(true);
assertTrue(
"Is or will be showing should be true when bouncer is in transit",
mStatusBarKeyguardViewManager.primaryBouncerIsOrWillBeShowing());
}
@Test
public void testUpdateResources_delegatesToBouncer() {
mStatusBarKeyguardViewManager.updateResources();
verify(mPrimaryBouncer).updateResources();
}
@Test
public void updateKeyguardPosition_delegatesToBouncer() {
mStatusBarKeyguardViewManager.updateKeyguardPosition(1.0f);
verify(mPrimaryBouncer).updateKeyguardPosition(1.0f);
}
@Test
public void testIsBouncerInTransit() {
when(mPrimaryBouncer.inTransit()).thenReturn(true);
Truth.assertThat(mStatusBarKeyguardViewManager.isPrimaryBouncerInTransit()).isTrue();
when(mPrimaryBouncer.inTransit()).thenReturn(false);
Truth.assertThat(mStatusBarKeyguardViewManager.isPrimaryBouncerInTransit()).isFalse();
mPrimaryBouncer = null;
Truth.assertThat(mStatusBarKeyguardViewManager.isPrimaryBouncerInTransit()).isFalse();
}
private static ShadeExpansionChangeEvent expansionEvent(
float fraction, boolean expanded, boolean tracking) {
return new ShadeExpansionChangeEvent(
fraction, expanded, tracking, /* dragDownPxAmount= */ 0f);
}
@Test
public void testPredictiveBackCallback_registration() {
/* verify that a predictive back callback is registered when the bouncer becomes visible */
mBouncerExpansionCallback.onVisibilityChanged(true);
verify(mOnBackInvokedDispatcher).registerOnBackInvokedCallback(
eq(OnBackInvokedDispatcher.PRIORITY_OVERLAY),
mOnBackInvokedCallback.capture());
/* verify that the same callback is unregistered when the bouncer becomes invisible */
mBouncerExpansionCallback.onVisibilityChanged(false);
verify(mOnBackInvokedDispatcher).unregisterOnBackInvokedCallback(
eq(mOnBackInvokedCallback.getValue()));
}
@Test
public void testPredictiveBackCallback_invocationHidesBouncer() {
mBouncerExpansionCallback.onVisibilityChanged(true);
/* capture the predictive back callback during registration */
verify(mOnBackInvokedDispatcher).registerOnBackInvokedCallback(
eq(OnBackInvokedDispatcher.PRIORITY_OVERLAY),
mOnBackInvokedCallback.capture());
when(mPrimaryBouncer.isShowing()).thenReturn(true);
when(mCentralSurfaces.shouldKeyguardHideImmediately()).thenReturn(true);
/* invoke the back callback directly */
mOnBackInvokedCallback.getValue().onBackInvoked();
/* verify that the bouncer will be hidden as a result of the invocation */
verify(mCentralSurfaces).setBouncerShowing(eq(false));
}
@Test
public void testReportBouncerOnDreamWhenVisible() {
mBouncerExpansionCallback.onVisibilityChanged(true);
verify(mCentralSurfaces).setBouncerShowingOverDream(false);
Mockito.clearInvocations(mCentralSurfaces);
when(mDreamOverlayStateController.isOverlayActive()).thenReturn(true);
mBouncerExpansionCallback.onVisibilityChanged(true);
verify(mCentralSurfaces).setBouncerShowingOverDream(true);
}
@Test
public void testReportBouncerOnDreamWhenNotVisible() {
mBouncerExpansionCallback.onVisibilityChanged(false);
verify(mCentralSurfaces).setBouncerShowingOverDream(false);
Mockito.clearInvocations(mCentralSurfaces);
when(mDreamOverlayStateController.isOverlayActive()).thenReturn(true);
mBouncerExpansionCallback.onVisibilityChanged(false);
verify(mCentralSurfaces).setBouncerShowingOverDream(false);
}
@Test
public void flag_off_DoesNotCallBouncerInteractor() {
when(mFeatureFlags.isEnabled(MODERN_BOUNCER)).thenReturn(false);
mStatusBarKeyguardViewManager.hideBouncer(false);
verify(mPrimaryBouncerInteractor, never()).hide();
}
@Test
public void hideAlternateBouncer_beforeCentralSurfacesRegistered() {
mStatusBarKeyguardViewManager =
new StatusBarKeyguardViewManager(
getContext(),
mViewMediatorCallback,
mLockPatternUtils,
mStatusBarStateController,
mock(ConfigurationController.class),
mKeyguardUpdateMonitor,
mDreamOverlayStateController,
mock(NavigationModeController.class),
mock(DockManager.class),
mock(NotificationShadeWindowController.class),
mKeyguardStateController,
mock(NotificationMediaManager.class),
mKeyguardBouncerFactory,
mKeyguardMessageAreaFactory,
Optional.of(mSysUiUnfoldComponent),
() -> mShadeController,
mLatencyTracker,
mKeyguardSecurityModel,
mFeatureFlags,
mPrimaryBouncerCallbackInteractor,
mPrimaryBouncerInteractor,
mBouncerView,
mAlternateBouncerInteractor) {
@Override
public ViewRootImpl getViewRootImpl() {
return mViewRootImpl;
}
};
// the following call before registering centralSurfaces should NOT throw a NPE:
mStatusBarKeyguardViewManager.hideAlternateBouncer(true);
}
}