diff options
| author | 2020-08-27 13:45:50 +0000 | |
|---|---|---|
| committer | 2020-08-27 13:45:50 +0000 | |
| commit | cb47f799f57d3cec3ae6ff6334dce86a91bc6b2d (patch) | |
| tree | 1ebbab9fc7c87bd3bdb44b62d7bcd5c238a9e02c | |
| parent | 0f292589f9adc9e7a8ce959da4aba9feab9a6ad2 (diff) | |
| parent | 4f0d8163501d8cbc066e96ab4fbee43350eb438d (diff) | |
Merge "Setup KeyguardBouncerComponent."
14 files changed, 172 insertions, 174 deletions
diff --git a/packages/CarSystemUI/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java b/packages/CarSystemUI/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java index 276ddfbc2b4f..dadbc22760b9 100644 --- a/packages/CarSystemUI/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java +++ b/packages/CarSystemUI/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java @@ -18,7 +18,6 @@ package com.android.systemui.car.keyguard; import android.car.Car; import android.car.user.CarUserManager; -import android.content.Context; import android.os.Bundle; import android.os.Handler; import android.util.Log; @@ -28,20 +27,17 @@ import android.view.ViewRootImpl; import androidx.annotation.VisibleForTesting; -import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardViewController; import com.android.keyguard.ViewMediatorCallback; +import com.android.keyguard.dagger.KeyguardBouncerComponent; import com.android.systemui.R; -import com.android.systemui.SystemUIFactory; import com.android.systemui.car.CarServiceProvider; import com.android.systemui.car.navigationbar.CarNavigationBarController; import com.android.systemui.car.window.OverlayViewController; import com.android.systemui.car.window.OverlayViewGlobalStateController; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.keyguard.DismissCallbackRegistry; -import com.android.systemui.plugins.FalsingManager; import com.android.systemui.statusbar.phone.BiometricUnlockController; import com.android.systemui.statusbar.phone.KeyguardBouncer; import com.android.systemui.statusbar.phone.KeyguardBypassController; @@ -63,18 +59,14 @@ public class CarKeyguardViewController extends OverlayViewController implements private static final String TAG = "CarKeyguardViewController"; private static final boolean DEBUG = true; - private final Context mContext; private final Handler mHandler; private final CarServiceProvider mCarServiceProvider; private final KeyguardStateController mKeyguardStateController; private final KeyguardUpdateMonitor mKeyguardUpdateMonitor; private final Lazy<BiometricUnlockController> mBiometricUnlockControllerLazy; - private final LockPatternUtils mLockPatternUtils; - private final FalsingManager mFalsingManager; - private final Lazy<KeyguardBypassController> mKeyguardBypassControllerLazy; - private final DismissCallbackRegistry mDismissCallbackRegistry; private final ViewMediatorCallback mViewMediatorCallback; private final CarNavigationBarController mCarNavigationBarController; + private final KeyguardBouncerComponent.Factory mKeyguardBouncerComponentFactory; // Needed to instantiate mBouncer. private final KeyguardBouncer.BouncerExpansionCallback mExpansionCallback = new KeyguardBouncer.BouncerExpansionCallback() { @@ -107,7 +99,6 @@ public class CarKeyguardViewController extends OverlayViewController implements @Inject public CarKeyguardViewController( - Context context, @Main Handler mainHandler, CarServiceProvider carServiceProvider, OverlayViewGlobalStateController overlayViewGlobalStateController, @@ -116,26 +107,18 @@ public class CarKeyguardViewController extends OverlayViewController implements Lazy<BiometricUnlockController> biometricUnlockControllerLazy, ViewMediatorCallback viewMediatorCallback, CarNavigationBarController carNavigationBarController, - /* The params below are only used to reuse KeyguardBouncer */ - LockPatternUtils lockPatternUtils, - DismissCallbackRegistry dismissCallbackRegistry, - FalsingManager falsingManager, - Lazy<KeyguardBypassController> keyguardBypassControllerLazy) { + KeyguardBouncerComponent.Factory keyguardBouncerComponentFactory) { super(R.id.keyguard_stub, overlayViewGlobalStateController); - mContext = context; mHandler = mainHandler; mCarServiceProvider = carServiceProvider; mKeyguardStateController = keyguardStateController; mKeyguardUpdateMonitor = keyguardUpdateMonitor; mBiometricUnlockControllerLazy = biometricUnlockControllerLazy; - mLockPatternUtils = lockPatternUtils; - mFalsingManager = falsingManager; - mKeyguardBypassControllerLazy = keyguardBypassControllerLazy; - mDismissCallbackRegistry = dismissCallbackRegistry; mViewMediatorCallback = viewMediatorCallback; mCarNavigationBarController = carNavigationBarController; + mKeyguardBouncerComponentFactory = keyguardBouncerComponentFactory; registerUserSwitchedListener(); } @@ -147,11 +130,9 @@ public class CarKeyguardViewController extends OverlayViewController implements @Override public void onFinishInflate() { - mBouncer = SystemUIFactory.getInstance().createKeyguardBouncer(mContext, - mViewMediatorCallback, mLockPatternUtils, - getLayout().findViewById(R.id.keyguard_container), mDismissCallbackRegistry, - mExpansionCallback, mKeyguardStateController, mFalsingManager, - mKeyguardBypassControllerLazy.get()); + mBouncer = mKeyguardBouncerComponentFactory + .build(getLayout().findViewById(R.id.keyguard_container), mExpansionCallback) + .createKeyguardBouncer(); mBiometricUnlockControllerLazy.get().setKeyguardViewController(this); } @@ -359,9 +340,8 @@ public class CarKeyguardViewController extends OverlayViewController implements public void registerStatusBar(StatusBar statusBar, ViewGroup container, NotificationPanelViewController notificationPanelViewController, BiometricUnlockController biometricUnlockController, - DismissCallbackRegistry dismissCallbackRegistry, ViewGroup lockIconContainer, - View notificationContainer, KeyguardBypassController bypassController, - FalsingManager falsingManager) { + ViewGroup lockIconContainer, + View notificationContainer, KeyguardBypassController bypassController) { // no-op } diff --git a/packages/CarSystemUI/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java b/packages/CarSystemUI/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java index 62dc23624520..63d4004fb640 100644 --- a/packages/CarSystemUI/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java +++ b/packages/CarSystemUI/tests/src/com/android/systemui/car/keyguard/CarKeyguardViewControllerTest.java @@ -26,7 +26,6 @@ import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import android.content.Context; import android.os.Handler; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; @@ -35,20 +34,17 @@ import android.view.ViewGroup; import androidx.test.filters.SmallTest; -import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.ViewMediatorCallback; +import com.android.keyguard.dagger.KeyguardBouncerComponent; import com.android.systemui.R; import com.android.systemui.SysuiTestCase; import com.android.systemui.car.CarServiceProvider; import com.android.systemui.car.CarSystemUiTest; import com.android.systemui.car.navigationbar.CarNavigationBarController; import com.android.systemui.car.window.OverlayViewGlobalStateController; -import com.android.systemui.keyguard.DismissCallbackRegistry; -import com.android.systemui.plugins.FalsingManager; import com.android.systemui.statusbar.phone.BiometricUnlockController; import com.android.systemui.statusbar.phone.KeyguardBouncer; -import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.policy.KeyguardStateController; import org.junit.Before; @@ -58,31 +54,36 @@ import org.mockito.InOrder; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import dagger.Lazy; - @CarSystemUiTest @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper @SmallTest public class CarKeyguardViewControllerTest extends SysuiTestCase { - private TestableCarKeyguardViewController mCarKeyguardViewController; + private CarKeyguardViewController mCarKeyguardViewController; @Mock private OverlayViewGlobalStateController mOverlayViewGlobalStateController; @Mock - private KeyguardBouncer mBouncer; + private CarKeyguardViewController.OnKeyguardCancelClickedListener mCancelClickedListener; @Mock - private CarNavigationBarController mCarNavigationBarController; + private KeyguardBouncerComponent.Factory mKeyguardBouncerComponentFactory; @Mock - private CarKeyguardViewController.OnKeyguardCancelClickedListener mCancelClickedListener; + private KeyguardBouncerComponent mKeyguardBouncerComponent; + @Mock + private KeyguardBouncer mBouncer; @Before public void setUp() { MockitoAnnotations.initMocks(this); - mCarKeyguardViewController = new TestableCarKeyguardViewController( - mContext, + when(mKeyguardBouncerComponentFactory.build( + any(ViewGroup.class), + any(KeyguardBouncer.BouncerExpansionCallback.class))) + .thenReturn(mKeyguardBouncerComponent); + when(mKeyguardBouncerComponent.createKeyguardBouncer()).thenReturn(mBouncer); + + mCarKeyguardViewController = new CarKeyguardViewController( Handler.getMain(), mock(CarServiceProvider.class), mOverlayViewGlobalStateController, @@ -91,10 +92,7 @@ public class CarKeyguardViewControllerTest extends SysuiTestCase { () -> mock(BiometricUnlockController.class), mock(ViewMediatorCallback.class), mock(CarNavigationBarController.class), - mock(LockPatternUtils.class), - mock(DismissCallbackRegistry.class), - mock(FalsingManager.class), - () -> mock(KeyguardBypassController.class) + mKeyguardBouncerComponentFactory ); mCarKeyguardViewController.inflate((ViewGroup) LayoutInflater.from(mContext).inflate( R.layout.sysui_overlay_window, /* root= */ null)); @@ -202,33 +200,4 @@ public class CarKeyguardViewControllerTest extends SysuiTestCase { verify(mBouncer).hide(/* destroyView= */ true); } - - private class TestableCarKeyguardViewController extends CarKeyguardViewController { - - TestableCarKeyguardViewController(Context context, - Handler mainHandler, - CarServiceProvider carServiceProvider, - OverlayViewGlobalStateController overlayViewGlobalStateController, - KeyguardStateController keyguardStateController, - KeyguardUpdateMonitor keyguardUpdateMonitor, - Lazy<BiometricUnlockController> biometricUnlockControllerLazy, - ViewMediatorCallback viewMediatorCallback, - CarNavigationBarController carNavigationBarController, - LockPatternUtils lockPatternUtils, - DismissCallbackRegistry dismissCallbackRegistry, - FalsingManager falsingManager, - Lazy<KeyguardBypassController> keyguardBypassControllerLazy) { - super(context, mainHandler, carServiceProvider, overlayViewGlobalStateController, - keyguardStateController, keyguardUpdateMonitor, biometricUnlockControllerLazy, - viewMediatorCallback, carNavigationBarController, lockPatternUtils, - dismissCallbackRegistry, falsingManager, keyguardBypassControllerLazy); - } - - @Override - public void onFinishInflate() { - super.onFinishInflate(); - setKeyguardBouncer(CarKeyguardViewControllerTest.this.mBouncer); - } - } - } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java index b0483339d14e..05172279c4ed 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -796,16 +796,6 @@ public class KeyguardSecurityContainer extends FrameLayout implements KeyguardSe securityMode != SecurityMode.None && newView.needsInput()); } - private KeyguardSecurityViewFlipper getFlipper() { - for (int i = 0; i < getChildCount(); i++) { - View child = getChildAt(i); - if (child instanceof KeyguardSecurityViewFlipper) { - return (KeyguardSecurityViewFlipper) child; - } - } - return null; - } - private KeyguardSecurityCallback mCallback = new KeyguardSecurityCallback() { public void userActivity() { if (mSecurityCallback != null) { diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java index 6a90d00c1e75..9766ee128f7c 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardViewController.java @@ -21,9 +21,7 @@ import android.view.View; import android.view.ViewGroup; import android.view.ViewRootImpl; -import com.android.systemui.keyguard.DismissCallbackRegistry; import com.android.systemui.keyguard.KeyguardViewMediator; -import com.android.systemui.plugins.FalsingManager; import com.android.systemui.statusbar.phone.BiometricUnlockController; import com.android.systemui.statusbar.phone.KeyguardBypassController; import com.android.systemui.statusbar.phone.NotificationPanelViewController; @@ -180,22 +178,18 @@ public interface KeyguardViewController { /** * Registers the StatusBar to which this Keyguard View is mounted. - * * @param statusBar * @param container * @param notificationPanelViewController * @param biometricUnlockController - * @param dismissCallbackRegistry * @param lockIconContainer * @param notificationContainer * @param bypassController - * @param falsingManager */ void registerStatusBar(StatusBar statusBar, ViewGroup container, NotificationPanelViewController notificationPanelViewController, BiometricUnlockController biometricUnlockController, - DismissCallbackRegistry dismissCallbackRegistry, ViewGroup lockIconContainer, View notificationContainer, - KeyguardBypassController bypassController, FalsingManager falsingManager); + KeyguardBypassController bypassController); } diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/ContainerView.java b/packages/SystemUI/src/com/android/keyguard/dagger/ContainerView.java new file mode 100644 index 000000000000..e65f19db5ac2 --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/dagger/ContainerView.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.keyguard.dagger; + +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; + +import javax.inject.Qualifier; + +@Qualifier +@Documented +@Retention(RUNTIME) +public @interface ContainerView { +} diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardBouncerComponent.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardBouncerComponent.java new file mode 100644 index 000000000000..84deaca096aa --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardBouncerComponent.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.keyguard.dagger; + +import android.view.ViewGroup; + +import com.android.systemui.statusbar.phone.KeyguardBouncer; + +import dagger.BindsInstance; +import dagger.Subcomponent; + +/** + * Dagger Subcomponent for the {@link KeyguardBouncer}. + */ +@Subcomponent +@KeyguardBouncerScope +public interface KeyguardBouncerComponent { + /** Simple factory for {@link KeyguardBouncerComponent}. */ + @Subcomponent.Factory + interface Factory { + KeyguardBouncerComponent build( + @BindsInstance @ContainerView ViewGroup container, + @BindsInstance KeyguardBouncer.BouncerExpansionCallback bouncerExpansionCallback); + } + + /** */ + KeyguardBouncer createKeyguardBouncer(); +} diff --git a/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardBouncerScope.java b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardBouncerScope.java new file mode 100644 index 000000000000..207ac2852f2f --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/dagger/KeyguardBouncerScope.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.keyguard.dagger; + +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; + +import javax.inject.Scope; + +/** + * Scope annotation for singleton items within the StatusBarComponent. + */ +@Documented +@Retention(RUNTIME) +@Scope +public @interface KeyguardBouncerScope {} diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java index 941fd6f320e2..f15949977754 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java @@ -19,24 +19,14 @@ package com.android.systemui; import android.content.Context; import android.content.res.Resources; import android.os.Handler; -import android.os.Looper; import android.util.Log; -import android.view.ViewGroup; import com.android.internal.annotations.VisibleForTesting; -import com.android.internal.widget.LockPatternUtils; -import com.android.keyguard.KeyguardUpdateMonitor; -import com.android.keyguard.ViewMediatorCallback; import com.android.systemui.dagger.DaggerGlobalRootComponent; import com.android.systemui.dagger.GlobalRootComponent; import com.android.systemui.dagger.SysUIComponent; import com.android.systemui.dagger.WMComponent; -import com.android.systemui.keyguard.DismissCallbackRegistry; -import com.android.systemui.plugins.FalsingManager; import com.android.systemui.screenshot.ScreenshotNotificationSmartActionsProvider; -import com.android.systemui.statusbar.phone.KeyguardBouncer; -import com.android.systemui.statusbar.phone.KeyguardBypassController; -import com.android.systemui.statusbar.policy.KeyguardStateController; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executor; @@ -140,17 +130,4 @@ public class SystemUIFactory { Handler uiHandler) { return new ScreenshotNotificationSmartActionsProvider(); } - - public KeyguardBouncer createKeyguardBouncer(Context context, ViewMediatorCallback callback, - LockPatternUtils lockPatternUtils, ViewGroup container, - DismissCallbackRegistry dismissCallbackRegistry, - KeyguardBouncer.BouncerExpansionCallback expansionCallback, - KeyguardStateController keyguardStateController, FalsingManager falsingManager, - KeyguardBypassController bypassController) { - return new KeyguardBouncer(context, callback, lockPatternUtils, container, - dismissCallbackRegistry, falsingManager, - expansionCallback, keyguardStateController, - Dependency.get(KeyguardUpdateMonitor.class), bypassController, - new Handler(Looper.getMainLooper())); - } } diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index 99a3a9119f89..8f4e738e5a5f 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -16,6 +16,7 @@ package com.android.systemui.dagger; +import com.android.keyguard.dagger.KeyguardBouncerComponent; import com.android.systemui.BootCompleteCache; import com.android.systemui.BootCompleteCacheImpl; import com.android.systemui.appops.dagger.AppOpsModule; @@ -82,6 +83,7 @@ import dagger.Provides; NotificationRowComponent.class, DozeComponent.class, ExpandableNotificationRowComponent.class, + KeyguardBouncerComponent.class, NotificationShelfComponent.class, FragmentService.FragmentCreator.class}) public abstract class SystemUIModule { diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 33407918f938..2705f07069bf 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -2184,8 +2184,8 @@ public class KeyguardViewMediator extends SystemUI implements Dumpable { BiometricUnlockController biometricUnlockController, ViewGroup lockIconContainer, View notificationContainer, KeyguardBypassController bypassController) { mKeyguardViewControllerLazy.get().registerStatusBar(statusBar, container, panelView, - biometricUnlockController, mDismissCallbackRegistry, lockIconContainer, - notificationContainer, bypassController, mFalsingManager); + biometricUnlockController, lockIconContainer, + notificationContainer, bypassController); return mKeyguardViewControllerLazy.get(); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java index b6a284c5e3c4..09034c0899f5 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java @@ -40,6 +40,8 @@ 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.ContainerView; +import com.android.keyguard.dagger.KeyguardBouncerScope; import com.android.systemui.DejankUtils; import com.android.systemui.Dependency; import com.android.systemui.R; @@ -50,9 +52,12 @@ import com.android.systemui.statusbar.policy.KeyguardStateController; import java.io.PrintWriter; +import javax.inject.Inject; + /** * A class which manages the bouncer on the lockscreen. */ +@KeyguardBouncerScope public class KeyguardBouncer { private static final String TAG = "KeyguardBouncer"; @@ -95,8 +100,9 @@ public class KeyguardBouncer { private boolean mIsAnimatingAway; private boolean mIsScrimmed; + @Inject public KeyguardBouncer(Context context, ViewMediatorCallback callback, - LockPatternUtils lockPatternUtils, ViewGroup container, + LockPatternUtils lockPatternUtils, @ContainerView ViewGroup container, DismissCallbackRegistry dismissCallbackRegistry, FalsingManager falsingManager, BouncerExpansionCallback expansionCallback, KeyguardStateController keyguardStateController, diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 58828797cfde..0089de27df94 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -1506,9 +1506,8 @@ public class StatusBar extends SystemUI implements DemoMode, mStatusBarKeyguardViewManager.registerStatusBar( /* statusBar= */ this, getBouncerContainer(), mNotificationPanelViewController, mBiometricUnlockController, - mDismissCallbackRegistry, mNotificationShadeWindowView.findViewById(R.id.lock_icon_container), - mStackScroller, mKeyguardBypassController, mFalsingManager); + mStackScroller, mKeyguardBypassController); mKeyguardIndicationController .setStatusBarKeyguardViewManager(mStatusBarKeyguardViewManager); mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 777bf3f73480..b56993b5f439 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -44,15 +44,13 @@ import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.keyguard.KeyguardViewController; import com.android.keyguard.ViewMediatorCallback; +import com.android.keyguard.dagger.KeyguardBouncerComponent; import com.android.settingslib.animation.AppearAnimationUtils; import com.android.systemui.DejankUtils; -import com.android.systemui.SystemUIFactory; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dock.DockManager; -import com.android.systemui.keyguard.DismissCallbackRegistry; import com.android.systemui.keyguard.FaceAuthScreenBrightnessController; import com.android.systemui.navigationbar.NavigationModeController; -import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.SysUiStatsLog; @@ -106,6 +104,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb private final NavigationModeController mNavigationModeController; private final NotificationShadeWindowController mNotificationShadeWindowController; private final Optional<FaceAuthScreenBrightnessController> mFaceAuthScreenBrightnessController; + private final KeyguardBouncerComponent.Factory mKeyguardBouncerComponentFactory; private final BouncerExpansionCallback mExpansionCallback = new BouncerExpansionCallback() { @Override public void onFullyShown() { @@ -216,7 +215,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb NotificationShadeWindowController notificationShadeWindowController, KeyguardStateController keyguardStateController, Optional<FaceAuthScreenBrightnessController> faceAuthScreenBrightnessController, - NotificationMediaManager notificationMediaManager) { + NotificationMediaManager notificationMediaManager, + KeyguardBouncerComponent.Factory keyguardBouncerComponentFactory) { mContext = context; mViewMediatorCallback = callback; mLockPatternUtils = lockPatternUtils; @@ -229,6 +229,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mStatusBarStateController = sysuiStatusBarStateController; mDockManager = dockManager; mFaceAuthScreenBrightnessController = faceAuthScreenBrightnessController; + mKeyguardBouncerComponentFactory = keyguardBouncerComponentFactory; } @Override @@ -236,9 +237,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb ViewGroup container, NotificationPanelViewController notificationPanelViewController, BiometricUnlockController biometricUnlockController, - DismissCallbackRegistry dismissCallbackRegistry, ViewGroup lockIconContainer, View notificationContainer, - KeyguardBypassController bypassController, FalsingManager falsingManager) { + KeyguardBypassController bypassController) { mStatusBar = statusBar; mContainer = container; mLockIconContainer = lockIconContainer; @@ -246,9 +246,9 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb mLastLockVisible = mLockIconContainer.getVisibility() == View.VISIBLE; } mBiometricUnlockController = biometricUnlockController; - mBouncer = SystemUIFactory.getInstance().createKeyguardBouncer(mContext, - mViewMediatorCallback, mLockPatternUtils, container, dismissCallbackRegistry, - mExpansionCallback, mKeyguardStateController, falsingManager, bypassController); + mBouncer = mKeyguardBouncerComponentFactory + .build(container, mExpansionCallback) + .createKeyguardBouncer(); mNotificationPanelViewController = notificationPanelViewController; notificationPanelViewController.addExpansionListener(this); mBypassController = bypassController; diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java index 2f4511329041..108327341f94 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.phone; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyFloat; import static org.mockito.ArgumentMatchers.eq; @@ -27,7 +28,6 @@ import static org.mockito.Mockito.reset; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import android.content.Context; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.view.View; @@ -39,14 +39,13 @@ import androidx.test.filters.SmallTest; import com.android.internal.widget.LockPatternUtils; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.ViewMediatorCallback; +import com.android.keyguard.dagger.KeyguardBouncerComponent; import com.android.systemui.SysuiTestCase; -import com.android.systemui.classifier.FalsingManagerFake; import com.android.systemui.dock.DockManager; import com.android.systemui.keyguard.DismissCallbackRegistry; import com.android.systemui.keyguard.FaceAuthScreenBrightnessController; import com.android.systemui.navigationbar.NavigationModeController; import com.android.systemui.plugins.ActivityStarter.OnDismissAction; -import com.android.systemui.plugins.FalsingManager; import com.android.systemui.statusbar.NotificationMediaManager; import com.android.systemui.statusbar.NotificationShadeWindowController; import com.android.systemui.statusbar.SysuiStatusBarStateController; @@ -71,8 +70,6 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { @Mock private LockPatternUtils mLockPatternUtils; @Mock - private KeyguardBouncer mBouncer; - @Mock private KeyguardStateController mKeyguardStateController; @Mock private StatusBar mStatusBar; @@ -94,6 +91,13 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { private KeyguardBypassController mBypassController; @Mock private FaceAuthScreenBrightnessController mFaceAuthScreenBrightnessController; + @Mock + private KeyguardBouncerComponent.Factory mKeyguardBouncerComponentFactory; + @Mock + private KeyguardBouncerComponent mKeyguardBouncerComponent; + @Mock + private KeyguardBouncer mBouncer; + private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; @Before @@ -102,7 +106,14 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { when(mLockIconContainer.getParent()).thenReturn(mock(ViewGroup.class)); when(mLockIconContainer.animate()).thenReturn(mock(ViewPropertyAnimator.class, RETURNS_DEEP_STUBS)); - mStatusBarKeyguardViewManager = new TestableStatusBarKeyguardViewManager( + + when(mKeyguardBouncerComponentFactory.build( + any(ViewGroup.class), + any(KeyguardBouncer.BouncerExpansionCallback.class))) + .thenReturn(mKeyguardBouncerComponent); + when(mKeyguardBouncerComponent.createKeyguardBouncer()).thenReturn(mBouncer); + + mStatusBarKeyguardViewManager = new StatusBarKeyguardViewManager( getContext(), mViewMediatorCallback, mLockPatternUtils, @@ -113,12 +124,12 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { mock(DockManager.class), mock(NotificationShadeWindowController.class), mKeyguardStateController, - mFaceAuthScreenBrightnessController, - mock(NotificationMediaManager.class)); + Optional.of(mFaceAuthScreenBrightnessController), + mock(NotificationMediaManager.class), + mKeyguardBouncerComponentFactory); mStatusBarKeyguardViewManager.registerStatusBar(mStatusBar, mContainer, - mNotificationPanelView, mBiometrucUnlockController, mDismissCallbackRegistry, - mLockIconContainer, mNotificationContainer, mBypassController, - new FalsingManagerFake()); + mNotificationPanelView, mBiometrucUnlockController, + mLockIconContainer, mNotificationContainer, mBypassController); mStatusBarKeyguardViewManager.show(null); } @@ -267,38 +278,4 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase { verify(action).onDismiss(); verify(cancelAction, never()).run(); } - - private class TestableStatusBarKeyguardViewManager extends StatusBarKeyguardViewManager { - - public TestableStatusBarKeyguardViewManager(Context context, - ViewMediatorCallback callback, - LockPatternUtils lockPatternUtils, - SysuiStatusBarStateController sysuiStatusBarStateController, - ConfigurationController configurationController, - KeyguardUpdateMonitor keyguardUpdateMonitor, - NavigationModeController navigationModeController, - DockManager dockManager, - NotificationShadeWindowController notificationShadeWindowController, - KeyguardStateController keyguardStateController, - FaceAuthScreenBrightnessController faceAuthScreenBrightnessController, - NotificationMediaManager notificationMediaManager) { - super(context, callback, lockPatternUtils, sysuiStatusBarStateController, - configurationController, keyguardUpdateMonitor, navigationModeController, - dockManager, notificationShadeWindowController, keyguardStateController, - Optional.of(faceAuthScreenBrightnessController), notificationMediaManager); - } - - @Override - public void registerStatusBar(StatusBar statusBar, ViewGroup container, - NotificationPanelViewController notificationPanelViewController, - BiometricUnlockController fingerprintUnlockController, - DismissCallbackRegistry dismissCallbackRegistry, - ViewGroup lockIconContainer, View notificationContainer, - KeyguardBypassController bypassController, FalsingManager falsingManager) { - super.registerStatusBar(statusBar, container, notificationPanelViewController, - fingerprintUnlockController, dismissCallbackRegistry, lockIconContainer, - notificationContainer, bypassController, falsingManager); - mBouncer = StatusBarKeyguardViewManagerTest.this.mBouncer; - } - } } |