From 33174bcab3b9eaee63dedb714f871ea428fb6e32 Mon Sep 17 00:00:00 2001 From: Dave Mankoff Date: Thu, 10 Oct 2019 14:57:02 -0400 Subject: [PATCH] Remove some calls to putComponent. This gets some of the low hanging fruit out of the way for deprecation of the SystemUI.mComponents member. Bug: 138786270 Test: atest SystemUITests Change-Id: I9388d671a39e8a20973c39489398064c434c31ec --- .../android/systemui/CarSystemUIFactory.java | 6 ------ .../com/android/systemui/CarSystemUIModule.java | 6 ++++++ .../volume/CarVolumeDialogComponent.java | 10 ++++++++-- .../com/android/systemui/ScreenDecorations.java | 1 - .../com/android/systemui/SystemUIBinder.java | 14 ++++++++++++++ .../com/android/systemui/SystemUIFactory.java | 6 ------ .../systemui/keyguard/KeyguardViewMediator.java | 1 - .../src/com/android/systemui/pip/PipUI.java | 6 +++++- .../systemui/recents/OverviewProxyService.java | 7 ++++--- .../systemui/volume/VolumeDialogComponent.java | 17 +++++++++-------- .../com/android/systemui/volume/VolumeUI.java | 11 +++++++---- 11 files changed, 53 insertions(+), 32 deletions(-) diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java index c7654e81e0b17..be2d5425cac1c 100644 --- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java +++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIFactory.java @@ -23,8 +23,6 @@ import com.android.keyguard.ViewMediatorCallback; import com.android.systemui.statusbar.car.CarFacetButtonController; import com.android.systemui.statusbar.car.CarStatusBarKeyguardViewManager; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; -import com.android.systemui.volume.CarVolumeDialogComponent; -import com.android.systemui.volume.VolumeDialogComponent; import javax.inject.Singleton; @@ -57,10 +55,6 @@ public class CarSystemUIFactory extends SystemUIFactory { return new CarStatusBarKeyguardViewManager(context, viewMediatorCallback, lockPatternUtils); } - public VolumeDialogComponent createVolumeDialogComponent(SystemUI systemUi, Context context) { - return new CarVolumeDialogComponent(systemUi, context); - } - @Singleton @Component(modules = ContextHolder.class) public interface CarDependencyComponent { diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java index 5ec1baee5b14f..b1067f8c3df50 100644 --- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java +++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java @@ -36,6 +36,8 @@ import com.android.systemui.statusbar.notification.collection.NotificationData; import com.android.systemui.statusbar.phone.KeyguardEnvironmentImpl; import com.android.systemui.statusbar.phone.ShadeController; import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.volume.CarVolumeDialogComponent; +import com.android.systemui.volume.VolumeDialogComponent; import javax.inject.Named; import javax.inject.Singleton; @@ -102,4 +104,8 @@ abstract class CarSystemUIModule { @IntoMap @ClassKey(StatusBar.class) public abstract SystemUI providesStatusBar(CarStatusBar statusBar); + + @Binds + abstract VolumeDialogComponent bindVolumeDialogComponent( + CarVolumeDialogComponent carVolumeDialogComponent); } diff --git a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogComponent.java b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogComponent.java index 71cc19b63ac14..4d6af95b3f9c7 100644 --- a/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogComponent.java +++ b/packages/CarSystemUI/src/com/android/systemui/volume/CarVolumeDialogComponent.java @@ -19,15 +19,21 @@ package com.android.systemui.volume; import android.content.Context; import com.android.systemui.SystemUI; +import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.plugins.VolumeDialog; +import javax.inject.Inject; +import javax.inject.Singleton; + /** * Allows for adding car specific dialog when the volume dialog is created. */ +@Singleton public class CarVolumeDialogComponent extends VolumeDialogComponent { - public CarVolumeDialogComponent(SystemUI sysui, Context context) { - super(sysui, context); + @Inject + public CarVolumeDialogComponent(Context context, KeyguardViewMediator keyguardViewMediator) { + super(context, keyguardViewMediator); } protected VolumeDialog createDefault() { diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java index 5b2fe61cfe07c..3a7a7f72f2993 100644 --- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java +++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java @@ -141,7 +141,6 @@ public class ScreenDecorations extends SystemUI implements Tunable { mHandler = startHandlerThread(); mHandler.post(this::startOnScreenDecorationsThread); setupStatusBarPaddingIfNeeded(); - putComponent(ScreenDecorations.class, this); } @VisibleForTesting diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIBinder.java b/packages/SystemUI/src/com/android/systemui/SystemUIBinder.java index 696e23a223c2a..a5a55983fe51a 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIBinder.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIBinder.java @@ -17,10 +17,12 @@ package com.android.systemui; import com.android.systemui.keyguard.KeyguardViewMediator; +import com.android.systemui.pip.PipUI; import com.android.systemui.power.PowerUI; import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsModule; import com.android.systemui.util.leak.GarbageMonitor; +import com.android.systemui.volume.VolumeUI; import dagger.Binds; import dagger.Module; @@ -45,6 +47,12 @@ public abstract class SystemUIBinder { @ClassKey(KeyguardViewMediator.class) public abstract SystemUI bindKeyguardViewMediator(KeyguardViewMediator sysui); + /** Inject into PipUI. */ + @Binds + @IntoMap + @ClassKey(PipUI.class) + public abstract SystemUI bindPipUI(PipUI sysui); + /** Inject into PowerUI. */ @Binds @IntoMap @@ -57,4 +65,10 @@ public abstract class SystemUIBinder { @ClassKey(Recents.class) public abstract SystemUI bindRecents(Recents sysui); + /** Inject into VolumeUI. */ + @Binds + @IntoMap + @ClassKey(VolumeUI.class) + public abstract SystemUI bindVolumeUI(VolumeUI sysui); + } diff --git a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java index ae2543c2aeda8..da4f3046badcb 100644 --- a/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +++ b/packages/SystemUI/src/com/android/systemui/SystemUIFactory.java @@ -48,7 +48,6 @@ import com.android.systemui.statusbar.phone.ScrimState; import com.android.systemui.statusbar.phone.StatusBar; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.statusbar.policy.KeyguardStateController; -import com.android.systemui.volume.VolumeDialogComponent; import java.util.function.Consumer; @@ -169,11 +168,6 @@ public class SystemUIFactory { return new KeyguardIndicationController(context, indicationArea, lockIcon); } - public VolumeDialogComponent createVolumeDialogComponent(SystemUI systemUi, Context context) { - // TODO: dagger injection. - return new VolumeDialogComponent(systemUi, context); - } - @Module public static class ContextHolder { private Context mContext; diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 200f17418ee8c..e0270decff08f 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -794,7 +794,6 @@ public class KeyguardViewMediator extends SystemUI { synchronized (this) { setupLocked(); } - putComponent(KeyguardViewMediator.class, this); } /** diff --git a/packages/SystemUI/src/com/android/systemui/pip/PipUI.java b/packages/SystemUI/src/com/android/systemui/pip/PipUI.java index 4d5e35014117b..f1e801b3a474b 100644 --- a/packages/SystemUI/src/com/android/systemui/pip/PipUI.java +++ b/packages/SystemUI/src/com/android/systemui/pip/PipUI.java @@ -31,15 +31,20 @@ import com.android.systemui.statusbar.CommandQueue; import java.io.FileDescriptor; import java.io.PrintWriter; +import javax.inject.Inject; +import javax.inject.Singleton; + /** * Controls the picture-in-picture window. */ +@Singleton public class PipUI extends SystemUI implements CommandQueue.Callbacks { private BasePipManager mPipManager; private boolean mSupportsPip; + @Inject public PipUI(Context context) { super(context); } @@ -64,7 +69,6 @@ public class PipUI extends SystemUI implements CommandQueue.Callbacks { mPipManager.initialize(mContext); getComponent(CommandQueue.class).addCallback(this); - putComponent(PipUI.class, this); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java index e0ae8ed66f41b..3fc139882693e 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java +++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java @@ -101,6 +101,7 @@ public class OverviewProxyService implements CallbackController