Make BiometricUnlockController injectable.
Bug: 142952576
Test: atest SystemUITests
Change-Id: Ib2e274325aa3bfb4627879ab36ef4efe187530eb
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemServicesModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemServicesModule.java
index 891bf615..fffba8c 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/SystemServicesModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemServicesModule.java
@@ -34,6 +34,7 @@
import android.view.WindowManager;
import android.view.WindowManagerGlobal;
+import com.android.internal.util.LatencyTracker;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.systemui.dagger.qualifiers.BgHandler;
import com.android.systemui.dagger.qualifiers.MainResources;
@@ -75,6 +76,12 @@
return WindowManagerGlobal.getWindowManagerService();
}
+ @Singleton
+ @Provides
+ static LatencyTracker provideLatencyTracker(Context context) {
+ return LatencyTracker.getInstance(context);
+ }
+
@SuppressLint("MissingPermission")
@Singleton
@Provides
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
index 30f1397..41ac69c 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java
@@ -36,7 +36,9 @@
* A dagger module for injecting components of System UI that are not overridden by the System UI
* implementation.
*/
-@Module(includes = {AssistModule.class, ComponentBinder.class, PeopleHubModule.class})
+@Module(includes = {AssistModule.class,
+ ComponentBinder.class,
+ PeopleHubModule.class})
public abstract class SystemUIModule {
@Singleton
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java b/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java
index a36ff0d..33f68cf 100644
--- a/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java
+++ b/packages/SystemUI/src/com/android/systemui/doze/DozeFactory.java
@@ -57,6 +57,7 @@
private final ProximitySensor mProximitySensor;
private final DelayedWakeLock.Builder mDelayedWakeLockBuilder;
private final Handler mHandler;
+ private final BiometricUnlockController mBiometricUnlockController;
@Inject
public DozeFactory(FalsingManager falsingManager, DozeLog dozeLog,
@@ -65,7 +66,8 @@
WakefulnessLifecycle wakefulnessLifecycle, KeyguardUpdateMonitor keyguardUpdateMonitor,
DockManager dockManager, @Nullable IWallpaperManager wallpaperManager,
ProximitySensor proximitySensor,
- DelayedWakeLock.Builder delayedWakeLockBuilder, Handler handler) {
+ DelayedWakeLock.Builder delayedWakeLockBuilder, Handler handler,
+ BiometricUnlockController biometricUnlockController) {
mFalsingManager = falsingManager;
mDozeLog = dozeLog;
mDozeParameters = dozeParameters;
@@ -79,6 +81,7 @@
mProximitySensor = proximitySensor;
mDelayedWakeLockBuilder = delayedWakeLockBuilder;
mHandler = handler;
+ mBiometricUnlockController = biometricUnlockController;
}
/** Creates a DozeMachine with its parts for {@code dozeService}. */
@@ -107,9 +110,7 @@
createDozeScreenBrightness(dozeService, wrappedService, mAsyncSensorManager, host,
mDozeParameters, mHandler),
new DozeWallpaperState(
- mWallpaperManager,
- getBiometricUnlockController(dozeService),
- mDozeParameters),
+ mWallpaperManager, mBiometricUnlockController, mDozeParameters),
new DozeDockHandler(dozeService, machine, host, config, mHandler, mDockManager),
new DozeAuthRemover(dozeService)
});
@@ -149,10 +150,4 @@
final SystemUIApplication app = (SystemUIApplication) appCandidate;
return app.getComponent(DozeHost.class);
}
-
- public static BiometricUnlockController getBiometricUnlockController(DozeService service) {
- Application appCandidate = service.getApplication();
- final SystemUIApplication app = (SystemUIApplication) appCandidate;
- return app.getComponent(BiometricUnlockController.class);
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
index 548afd5..b9516cf 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java
@@ -18,6 +18,7 @@
import android.annotation.IntDef;
import android.content.Context;
+import android.content.res.Resources;
import android.hardware.biometrics.BiometricSourceType;
import android.metrics.LogMaker;
import android.os.Handler;
@@ -34,6 +35,7 @@
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.Dependency;
+import com.android.systemui.dagger.qualifiers.MainResources;
import com.android.systemui.keyguard.KeyguardViewMediator;
import com.android.systemui.keyguard.ScreenLifecycle;
import com.android.systemui.keyguard.WakefulnessLifecycle;
@@ -44,6 +46,8 @@
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import javax.inject.Inject;
+
/**
* Controller which coordinates all the biometric unlocking actions with the UI.
*/
@@ -145,31 +149,16 @@
private boolean mHasScreenTurnedOnSinceAuthenticating;
private boolean mFadedAwayAfterWakeAndUnlock;
- private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
+ private final MetricsLogger mMetricsLogger;
- public BiometricUnlockController(
- Context context,
- DozeScrimController dozeScrimController,
- KeyguardViewMediator keyguardViewMediator,
- ScrimController scrimController,
- StatusBar statusBar,
- KeyguardStateController keyguardStateController, Handler handler,
- KeyguardUpdateMonitor keyguardUpdateMonitor,
- KeyguardBypassController keyguardBypassController,
- DozeParameters dozeParameters) {
- this(context, dozeScrimController, keyguardViewMediator, scrimController, statusBar,
- keyguardStateController, handler, keyguardUpdateMonitor,
- context.getResources()
- .getInteger(com.android.internal.R.integer.config_wakeUpDelayDoze),
- keyguardBypassController, dozeParameters);
- }
-
- @VisibleForTesting
- protected BiometricUnlockController(Context context, DozeScrimController dozeScrimController,
+ @Inject
+ public BiometricUnlockController(Context context, DozeScrimController dozeScrimController,
KeyguardViewMediator keyguardViewMediator, ScrimController scrimController,
StatusBar statusBar, KeyguardStateController keyguardStateController, Handler handler,
- KeyguardUpdateMonitor keyguardUpdateMonitor, int wakeUpDelay,
- KeyguardBypassController keyguardBypassController, DozeParameters dozeParameters) {
+ KeyguardUpdateMonitor keyguardUpdateMonitor,
+ @MainResources Resources resources,
+ KeyguardBypassController keyguardBypassController, DozeParameters dozeParameters,
+ MetricsLogger metricsLogger) {
mContext = context;
mPowerManager = context.getSystemService(PowerManager.class);
mUpdateMonitor = keyguardUpdateMonitor;
@@ -185,9 +174,10 @@
mStatusBar = statusBar;
mKeyguardStateController = keyguardStateController;
mHandler = handler;
- mWakeUpDelay = wakeUpDelay;
+ mWakeUpDelay = resources.getInteger(com.android.internal.R.integer.config_wakeUpDelayDoze);
mKeyguardBypassController = keyguardBypassController;
mKeyguardBypassController.setUnlockController(this);
+ mMetricsLogger = metricsLogger;
}
public void setStatusBarKeyguardViewManager(
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 97e09dc..4e0af64 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -356,7 +356,7 @@
private VolumeComponent mVolumeComponent;
private BrightnessMirrorController mBrightnessMirrorController;
private boolean mBrightnessMirrorVisible;
- protected BiometricUnlockController mBiometricUnlockController;
+ private BiometricUnlockController mBiometricUnlockController;
private final LightBarController mLightBarController;
private final Lazy<LockscreenWallpaper> mLockscreenWallpaperLazy;
protected LockscreenWallpaper mLockscreenWallpaper;
@@ -398,6 +398,7 @@
private final StatusBarWindowViewController.Builder mStatusBarWindowViewControllerBuilder;
private final NotifLog mNotifLog;
private final DozeParameters mDozeParameters;
+ private final Lazy<BiometricUnlockController> mBiometricUnlockControllerLazy;
// expanded notifications
protected NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window
@@ -691,7 +692,8 @@
NotifLog notifLog,
DozeParameters dozeParameters,
ScrimController scrimController,
- Lazy<LockscreenWallpaper> lockscreenWallpaperLazy) {
+ Lazy<LockscreenWallpaper> lockscreenWallpaperLazy,
+ Lazy<BiometricUnlockController> biometricUnlockControllerLazy) {
super(context);
mFeatureFlags = featureFlags;
mLightBarController = lightBarController;
@@ -751,6 +753,7 @@
mDozeParameters = dozeParameters;
mScrimController = scrimController;
mLockscreenWallpaperLazy = lockscreenWallpaperLazy;
+ mBiometricUnlockControllerLazy = biometricUnlockControllerLazy;
mBubbleExpandListener =
(isExpanding, key) -> {
@@ -1370,11 +1373,7 @@
protected void startKeyguard() {
Trace.beginSection("StatusBar#startKeyguard");
- mBiometricUnlockController = new BiometricUnlockController(mContext,
- mDozeScrimController, mKeyguardViewMediator,
- mScrimController, this, mKeyguardStateController, new Handler(),
- mKeyguardUpdateMonitor, mKeyguardBypassController, mDozeParameters);
- putComponent(BiometricUnlockController.class, mBiometricUnlockController);
+ mBiometricUnlockController = mBiometricUnlockControllerLazy.get();
mStatusBarKeyguardViewManager = mKeyguardViewMediator.registerStatusBar(this,
getBouncerContainer(), mNotificationPanel, mBiometricUnlockController,
mStatusBarWindow.findViewById(R.id.lock_icon_container), mStackScroller,