[Central Surfaces] Make AuthRipple(view&controller) a singleton.

Bug: 277762009
Test: compiles
Test: auth ripple still works on various devices
Test: atest AuthRippleControllerTest CentralSurfacesImplTest
Change-Id: I24021161cfa49675a8856d9d4c0ea3ae464ef872
This commit is contained in:
Caitlin Shkuratov
2023-04-17 19:05:03 +00:00
parent 08c87d50c8
commit fa5de7020f
6 changed files with 35 additions and 20 deletions

View File

@@ -30,8 +30,10 @@ import com.android.keyguard.KeyguardUpdateMonitorCallback
import com.android.keyguard.logging.KeyguardLogger
import com.android.settingslib.Utils
import com.android.settingslib.udfps.UdfpsOverlayParams
import com.android.systemui.CoreStartable
import com.android.systemui.R
import com.android.systemui.animation.Interpolators
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.WakefulnessLifecycle
@@ -45,7 +47,6 @@ import com.android.systemui.statusbar.NotificationShadeWindowController
import com.android.systemui.statusbar.commandline.Command
import com.android.systemui.statusbar.commandline.CommandRegistry
import com.android.systemui.statusbar.phone.BiometricUnlockController
import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent.CentralSurfacesScope
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.util.ViewController
@@ -61,7 +62,7 @@ import javax.inject.Provider
*
* The ripple uses the accent color of the current theme.
*/
@CentralSurfacesScope
@SysUISingleton
class AuthRippleController @Inject constructor(
private val sysuiContext: Context,
private val authController: AuthController,
@@ -81,6 +82,7 @@ class AuthRippleController @Inject constructor(
rippleView: AuthRippleView?
) :
ViewController<AuthRippleView>(rippleView),
CoreStartable,
KeyguardStateController.Callback,
WakefulnessLifecycle.Observer {
@@ -94,6 +96,10 @@ class AuthRippleController @Inject constructor(
private var udfpsController: UdfpsController? = null
private var udfpsRadius: Float = -1f
override fun start() {
init()
}
@VisibleForTesting
public override fun onViewAttached() {
authController.addCallback(authControllerCallback)

View File

@@ -17,16 +17,28 @@
package com.android.systemui.shade
import android.view.LayoutInflater
import com.android.systemui.CoreStartable
import com.android.systemui.R
import com.android.systemui.biometrics.AuthRippleController
import com.android.systemui.biometrics.AuthRippleView
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.statusbar.LightRevealScrim
import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.multibindings.ClassKey
import dagger.multibindings.IntoMap
/** Module for classes related to the notification shade. */
@Module
abstract class ShadeModule {
@Binds
@IntoMap
@ClassKey(AuthRippleController::class)
abstract fun bindAuthRippleController(controller: AuthRippleController): CoreStartable
companion object {
@Provides
@SysUISingleton
@@ -68,5 +80,14 @@ abstract class ShadeModule {
): LightRevealScrim {
return notificationShadeWindowView.findViewById(R.id.light_reveal_scrim)
}
// TODO(b/277762009): Only allow this view's controller to inject the view. See above.
@Provides
@SysUISingleton
fun providesAuthRippleView(
notificationShadeWindowView: NotificationShadeWindowView,
): AuthRippleView? {
return notificationShadeWindowView.findViewById(R.id.auth_ripple)
}
}
}

View File

@@ -452,7 +452,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
protected PhoneStatusBarView mStatusBarView;
private PhoneStatusBarViewController mPhoneStatusBarViewController;
private PhoneStatusBarTransitions mStatusBarTransitions;
private AuthRippleController mAuthRippleController;
private final AuthRippleController mAuthRippleController;
@WindowVisibleState private int mStatusBarWindowState = WINDOW_STATE_SHOWING;
protected final NotificationShadeWindowController mNotificationShadeWindowController;
private final StatusBarInitializer mStatusBarInitializer;
@@ -768,6 +768,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
ScrimController scrimController,
Lazy<LockscreenWallpaper> lockscreenWallpaperLazy,
Lazy<BiometricUnlockController> biometricUnlockControllerLazy,
AuthRippleController authRippleController,
DozeServiceHost dozeServiceHost,
PowerManager powerManager,
ScreenPinningRequest screenPinningRequest,
@@ -867,6 +868,7 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
mScreenPinningRequest = screenPinningRequest;
mDozeScrimController = dozeScrimController;
mBiometricUnlockControllerLazy = biometricUnlockControllerLazy;
mAuthRippleController = authRippleController;
mNotificationShadeDepthControllerLazy = notificationShadeDepthControllerLazy;
mVolumeComponent = volumeComponent;
mCommandQueue = commandQueue;
@@ -1667,8 +1669,6 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces {
mPresenter = mCentralSurfacesComponent.getNotificationPresenter();
mNotificationActivityStarter = mCentralSurfacesComponent.getNotificationActivityStarter();
mNotificationShelfController = mCentralSurfacesComponent.getNotificationShelfController();
mAuthRippleController = mCentralSurfacesComponent.getAuthRippleController();
mAuthRippleController.init();
mHeadsUpManager.addListener(mCentralSurfacesComponent.getStatusBarHeadsUpChangeListener());

View File

@@ -121,11 +121,6 @@ public interface CentralSurfacesComponent {
*/
LockIconViewController getLockIconViewController();
/**
* Creates an AuthRippleViewController. Must be init after creation.
*/
AuthRippleController getAuthRippleController();
/**
* Creates a StatusBarHeadsUpChangeListener.
*/

View File

@@ -29,7 +29,6 @@ import com.android.keyguard.LockIconView;
import com.android.systemui.R;
import com.android.systemui.battery.BatteryMeterView;
import com.android.systemui.battery.BatteryMeterViewController;
import com.android.systemui.biometrics.AuthRippleView;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlags;
@@ -146,15 +145,6 @@ public abstract class StatusBarViewModule {
return notificationShadeWindowView.findViewById(R.id.lock_icon_view);
}
/** */
@Provides
@CentralSurfacesComponent.CentralSurfacesScope
@Nullable
public static AuthRippleView getAuthRippleView(
NotificationShadeWindowView notificationShadeWindowView) {
return notificationShadeWindowView.findViewById(R.id.auth_ripple);
}
/** */
@Provides
@Named(SHADE_HEADER)

View File

@@ -101,6 +101,7 @@ import com.android.systemui.SysuiTestCase;
import com.android.systemui.accessibility.floatingmenu.AccessibilityFloatingMenuController;
import com.android.systemui.animation.ActivityLaunchAnimator;
import com.android.systemui.assist.AssistManager;
import com.android.systemui.biometrics.AuthRippleController;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.charging.WiredChargingRippleController;
import com.android.systemui.classifier.FalsingCollectorFake;
@@ -237,6 +238,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
@Mock private DozeScrimController mDozeScrimController;
@Mock private Lazy<BiometricUnlockController> mBiometricUnlockControllerLazy;
@Mock private BiometricUnlockController mBiometricUnlockController;
@Mock private AuthRippleController mAuthRippleController;
@Mock private NotificationListener mNotificationListener;
@Mock private KeyguardViewMediator mKeyguardViewMediator;
@Mock private NotificationLockscreenUserManager mLockscreenUserManager;
@@ -500,6 +502,7 @@ public class CentralSurfacesImplTest extends SysuiTestCase {
mScrimController,
mLockscreenWallpaperLazy,
mBiometricUnlockControllerLazy,
mAuthRippleController,
mDozeServiceHost,
mPowerManager, mScreenPinningRequest,
mDozeScrimController,