From eace41f652f7c5a7d1fef2ae2ed649e802a5cd35 Mon Sep 17 00:00:00 2001 From: Dave Mankoff Date: Fri, 15 Apr 2022 00:36:15 +0000 Subject: [PATCH] Move EnhancedEstimates to PowerModule Rename SystemUIDefaultModule to AOSPSystemUIModule. Bug: 229228871 Test: manual Change-Id: I8da604b281e28dd3982b1f8ec84f5a8415dad47e --- ...dule.java => ReferenceSystemUIModule.java} | 22 +++++++++++++------ .../systemui/dagger/SysUIComponent.java | 2 +- .../systemui/dagger/SystemUIModule.java | 10 +++++++-- .../systemui/power/dagger/PowerModule.java | 6 +++++ .../android/systemui/tv/TvSystemUIModule.java | 4 ---- 5 files changed, 30 insertions(+), 14 deletions(-) rename packages/SystemUI/src/com/android/systemui/dagger/{SystemUIDefaultModule.java => ReferenceSystemUIModule.java} (92%) diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java b/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSystemUIModule.java similarity index 92% rename from packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java rename to packages/SystemUI/src/com/android/systemui/dagger/ReferenceSystemUIModule.java index 5d154c3b4f6b5..4e48a5261f6bb 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/ReferenceSystemUIModule.java @@ -38,7 +38,6 @@ import com.android.systemui.media.dagger.MediaModule; import com.android.systemui.plugins.qs.QSFactory; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.power.EnhancedEstimates; -import com.android.systemui.power.EnhancedEstimatesImpl; import com.android.systemui.power.dagger.PowerModule; import com.android.systemui.qs.dagger.QSModule; import com.android.systemui.qs.tileimpl.QSFactoryImpl; @@ -80,8 +79,19 @@ import dagger.Module; import dagger.Provides; /** - * A dagger module for injecting default implementations of components of System UI that may be - * overridden by the System UI implementation. + * A dagger module for injecting default implementations of components of System UI. + * + * Variants of SystemUI should make a copy of this, include it in their component, and customize it + * as needed. + * + * This module might alternatively be named `AospSystemUIModule`, `PhoneSystemUIModule`, + * or `BasicSystemUIModule`. + * + * Nothing in the module should be strictly required. Each piece should either be swappable with + * a different implementation or entirely removable. + * + * This is different from {@link SystemUIModule} which should be used for pieces of required + * SystemUI code that variants of SystemUI _must_ include to function correctly. */ @Module(includes = { MediaModule.class, @@ -90,7 +100,7 @@ import dagger.Provides; StartCentralSurfacesModule.class, VolumeModule.class }) -public abstract class SystemUIDefaultModule { +public abstract class ReferenceSystemUIModule { @SysUISingleton @Provides @@ -100,9 +110,6 @@ public abstract class SystemUIDefaultModule { return null; } - @Binds - abstract EnhancedEstimates bindEnhancedEstimates(EnhancedEstimatesImpl enhancedEstimates); - @Binds abstract NotificationLockscreenUserManager bindNotificationLockscreenUserManager( NotificationLockscreenUserManagerImpl notificationLockscreenUserManager); @@ -148,6 +155,7 @@ public abstract class SystemUIDefaultModule { return spC; } + /** */ @Binds @SysUISingleton public abstract QSFactory bindQSFactory(QSFactoryImpl qsFactoryImpl); diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java b/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java index 701972ab7264c..5d34a6987b663 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java @@ -73,7 +73,7 @@ import dagger.Subcomponent; SystemUIBinder.class, SystemUIModule.class, SystemUICoreStartableModule.class, - SystemUIDefaultModule.class}) + ReferenceSystemUIModule.class}) public interface SysUIComponent { /** diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index bbeb66c5af522..535eff8018785 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -100,8 +100,14 @@ import dagger.Module; import dagger.Provides; /** - * A dagger module for injecting components of System UI that are not overridden by the System UI - * implementation. + * A dagger module for injecting components of System UI that are required by System UI. + * + * If your feature can be excluded, subclassed, or re-implemented by a variant of SystemUI, put + * your Dagger Module in {@link ReferenceSystemUIModule} and/or any variant modules that + * rely on the feature. + * + * Adding an entry in this file means that _all_ variants of SystemUI will receive that code. They + * may not appreciate that. */ @Module(includes = { AppOpsModule.class, diff --git a/packages/SystemUI/src/com/android/systemui/power/dagger/PowerModule.java b/packages/SystemUI/src/com/android/systemui/power/dagger/PowerModule.java index 8b8941a9112d3..3709a86f2fa57 100644 --- a/packages/SystemUI/src/com/android/systemui/power/dagger/PowerModule.java +++ b/packages/SystemUI/src/com/android/systemui/power/dagger/PowerModule.java @@ -16,6 +16,8 @@ package com.android.systemui.power.dagger; +import com.android.systemui.power.EnhancedEstimates; +import com.android.systemui.power.EnhancedEstimatesImpl; import com.android.systemui.power.PowerNotificationWarnings; import com.android.systemui.power.PowerUI; @@ -26,6 +28,10 @@ import dagger.Module; /** Dagger Module for code in the power package. */ @Module public interface PowerModule { + /** */ + @Binds + EnhancedEstimates bindEnhancedEstimates(EnhancedEstimatesImpl enhancedEstimates); + /** */ @Binds PowerUI.WarningsUI provideWarningsUi(PowerNotificationWarnings controllerImpl); diff --git a/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java b/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java index b7f90a4795188..4685c148e7e59 100644 --- a/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/tv/TvSystemUIModule.java @@ -38,7 +38,6 @@ import com.android.systemui.doze.DozeHost; import com.android.systemui.plugins.qs.QSFactory; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.power.EnhancedEstimates; -import com.android.systemui.power.EnhancedEstimatesImpl; import com.android.systemui.power.dagger.PowerModule; import com.android.systemui.qs.dagger.QSModule; import com.android.systemui.qs.tileimpl.QSFactoryImpl; @@ -101,9 +100,6 @@ public abstract class TvSystemUIModule { return null; } - @Binds - abstract EnhancedEstimates bindEnhancedEstimates(EnhancedEstimatesImpl enhancedEstimates); - @Binds abstract NotificationLockscreenUserManager bindNotificationLockscreenUserManager( NotificationLockscreenUserManagerImpl notificationLockscreenUserManager);