Remove all calls to getComponent(CommandQueue.class).
Makes AuthController, GlobalActionsComponent, InstantAppNotifier,
SizeCompatModeActivityController, and TvStatusBar all injectable.
Prior to this CL, CommandQueue contained within it a SystemUI object
that it used to start itself up and add itself to components. With
this change, the SystemUI object is no longer necessary, as Dagger
will ensure that a CommandQueue is available to those who need it.
Bug: 143702229
Test: atest SystemUITests
Change-Id: I2763a6d918b41fe27a2370fdd820da476654e14f
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
index 446ed25..516de70 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
@@ -47,16 +47,21 @@
import java.util.List;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
/**
* Receives messages sent from {@link com.android.server.biometrics.BiometricService} and shows the
* appropriate biometric UI (e.g. BiometricDialogView).
*/
+@Singleton
public class AuthController extends SystemUI implements CommandQueue.Callbacks,
AuthDialogCallback {
private static final String TAG = "BiometricPrompt/AuthController";
private static final boolean DEBUG = true;
+ private final CommandQueue mCommandQueue;
private final Injector mInjector;
// TODO: These should just be saved from onSaveState
@@ -189,13 +194,15 @@
}
}
- public AuthController(Context context) {
- this(context, new Injector());
+ @Inject
+ public AuthController(Context context, CommandQueue commandQueue) {
+ this(context, commandQueue, new Injector());
}
@VisibleForTesting
- AuthController(Context context, Injector injector) {
+ AuthController(Context context, CommandQueue commandQueue, Injector injector) {
super(context);
+ mCommandQueue = commandQueue;
mInjector = injector;
}
@@ -205,7 +212,7 @@
if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)
|| pm.hasSystemFeature(PackageManager.FEATURE_FACE)
|| pm.hasSystemFeature(PackageManager.FEATURE_IRIS)) {
- getComponent(CommandQueue.class).addCallback(this);
+ mCommandQueue.addCallback(this);
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
mActivityTaskManager = mInjector.getActivityTaskManager();