From ae8ec453d480bd22c4f489aa24a516cdfca85aed Mon Sep 17 00:00:00 2001 From: Dave Mankoff Date: Tue, 29 Oct 2019 15:50:02 -0400 Subject: [PATCH] Instances of SystemUI must now define their own ComponentBinder This will allow us to mark parts of the core system as Optional, like the StatusBar. Bug: 140514132 Test: atest SystemUITests Change-Id: I37f6fa414e9dc2a672dd0bc8cc69ce4049762973 --- .../android/systemui/CarComponentBinder.java | 32 +++++++++ .../android/systemui/CarSystemUIBinder.java | 71 ++++++++++++++++++- .../android/systemui/CarSystemUIModule.java | 7 -- .../systemui/CarSystemUIRootComponent.java | 1 + ...Binder.java => DefaultActivityBinder.java} | 2 +- ...inder.java => DefaultComponentBinder.java} | 11 ++- ...eBinder.java => DefaultServiceBinder.java} | 2 +- .../systemui/dagger/SystemUIBinder.java | 7 ++ .../dagger/SystemUIDefaultModule.java | 8 --- .../systemui/dagger/SystemUIModule.java | 7 +- .../dagger/SystemUIRootComponent.java | 1 + 11 files changed, 122 insertions(+), 27 deletions(-) create mode 100644 packages/CarSystemUI/src/com/android/systemui/CarComponentBinder.java rename packages/SystemUI/src/com/android/systemui/dagger/{ActivityBinder.java => DefaultActivityBinder.java} (96%) rename packages/SystemUI/src/com/android/systemui/dagger/{ComponentBinder.java => DefaultComponentBinder.java} (72%) rename packages/SystemUI/src/com/android/systemui/dagger/{ServiceBinder.java => DefaultServiceBinder.java} (96%) diff --git a/packages/CarSystemUI/src/com/android/systemui/CarComponentBinder.java b/packages/CarSystemUI/src/com/android/systemui/CarComponentBinder.java new file mode 100644 index 0000000000000..c40eda9fb3031 --- /dev/null +++ b/packages/CarSystemUI/src/com/android/systemui/CarComponentBinder.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui; + +import com.android.systemui.dagger.DefaultActivityBinder; +import com.android.systemui.dagger.DefaultServiceBinder; + +import dagger.Module; + +/** + * Supply Activities, Services, and SystemUI Objects for CarSystemUI. + */ +@Module(includes = { + DefaultActivityBinder.class, + DefaultServiceBinder.class, + CarSystemUIBinder.class}) +public class CarComponentBinder { +} diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java index 8e0a3eb53e6f4..4f7b5d530c96f 100644 --- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java +++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIBinder.java @@ -16,7 +16,16 @@ package com.android.systemui; +import com.android.systemui.keyguard.KeyguardViewMediator; import com.android.systemui.navigationbar.car.CarNavigationBar; +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.statusbar.car.CarStatusBar; +import com.android.systemui.statusbar.phone.StatusBar; +import com.android.systemui.util.leak.GarbageMonitor; +import com.android.systemui.volume.VolumeUI; import dagger.Binds; import dagger.Module; @@ -24,11 +33,71 @@ import dagger.multibindings.ClassKey; import dagger.multibindings.IntoMap; /** Binder for car specific {@link SystemUI} modules. */ -@Module +@Module(includes = {RecentsModule.class}) public abstract class CarSystemUIBinder { /** */ @Binds @IntoMap @ClassKey(CarNavigationBar.class) public abstract SystemUI bindCarNavigationBar(CarNavigationBar sysui); + + /** Inject into GarbageMonitor.Service. */ + @Binds + @IntoMap + @ClassKey(GarbageMonitor.Service.class) + public abstract SystemUI bindGarbageMonitorService(GarbageMonitor.Service service); + + /** Inject into KeyguardViewMediator. */ + @Binds + @IntoMap + @ClassKey(KeyguardViewMediator.class) + public abstract SystemUI bindKeyguardViewMediator(KeyguardViewMediator sysui); + + /** Inject into LatencyTests. */ + @Binds + @IntoMap + @ClassKey(LatencyTester.class) + public abstract SystemUI bindLatencyTester(LatencyTester sysui); + + /** Inject into PipUI. */ + @Binds + @IntoMap + @ClassKey(PipUI.class) + public abstract SystemUI bindPipUI(PipUI sysui); + + /** Inject into PowerUI. */ + @Binds + @IntoMap + @ClassKey(PowerUI.class) + public abstract SystemUI bindPowerUI(PowerUI sysui); + + /** Inject into Recents. */ + @Binds + @IntoMap + @ClassKey(Recents.class) + public abstract SystemUI bindRecents(Recents sysui); + + /** Inject into ScreenDecorations. */ + @Binds + @IntoMap + @ClassKey(ScreenDecorations.class) + public abstract SystemUI bindScreenDecorations(ScreenDecorations sysui); + + /** Inject into StatusBar. */ + @Binds + @IntoMap + @ClassKey(StatusBar.class) + public abstract SystemUI bindsStatusBar(CarStatusBar sysui); + + /** Inject into StatusBarGoogle. */ + @Binds + @IntoMap + @ClassKey(CarStatusBar.class) + public abstract SystemUI bindsCarStatusBar(CarStatusBar sysui); + + /** Inject into VolumeUI. */ + @Binds + @IntoMap + @ClassKey(VolumeUI.class) + public abstract SystemUI bindVolumeUI(VolumeUI sysui); } diff --git a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java index 93e553f59dcfd..d3a6cde66e849 100644 --- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java +++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIModule.java @@ -46,8 +46,6 @@ import javax.inject.Singleton; import dagger.Binds; import dagger.Module; import dagger.Provides; -import dagger.multibindings.ClassKey; -import dagger.multibindings.IntoMap; @Module abstract class CarSystemUIModule { @@ -104,11 +102,6 @@ abstract class CarSystemUIModule { @Binds public abstract StatusBar bindStatusBar(CarStatusBar statusBar); - @Binds - @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/CarSystemUIRootComponent.java b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIRootComponent.java index c2847c88785ba..51b263ebdb4ee 100644 --- a/packages/CarSystemUI/src/com/android/systemui/CarSystemUIRootComponent.java +++ b/packages/CarSystemUI/src/com/android/systemui/CarSystemUIRootComponent.java @@ -29,6 +29,7 @@ import dagger.Component; @Singleton @Component( modules = { + CarComponentBinder.class, DependencyProvider.class, DependencyBinder.class, SystemUIFactory.ContextHolder.class, diff --git a/packages/SystemUI/src/com/android/systemui/dagger/ActivityBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/DefaultActivityBinder.java similarity index 96% rename from packages/SystemUI/src/com/android/systemui/dagger/ActivityBinder.java rename to packages/SystemUI/src/com/android/systemui/dagger/DefaultActivityBinder.java index 4be610fcd9ee3..61ded138134cf 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/ActivityBinder.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/DefaultActivityBinder.java @@ -30,7 +30,7 @@ import dagger.multibindings.IntoMap; * Services and Activities that are injectable should go here. */ @Module -public abstract class ActivityBinder { +public abstract class DefaultActivityBinder { /** Inject into TunerActivity. */ @Binds @IntoMap diff --git a/packages/SystemUI/src/com/android/systemui/dagger/ComponentBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/DefaultComponentBinder.java similarity index 72% rename from packages/SystemUI/src/com/android/systemui/dagger/ComponentBinder.java rename to packages/SystemUI/src/com/android/systemui/dagger/DefaultComponentBinder.java index 4e4c06e9d4475..d8989ee624fae 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/ComponentBinder.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/DefaultComponentBinder.java @@ -16,16 +16,13 @@ package com.android.systemui.dagger; -import dagger.Binds; import dagger.Module; /** * Dagger Module that collects related sub-modules together. + * + * See {@link ContextComponentResolver} */ -@Module(includes = {ActivityBinder.class, ServiceBinder.class, SystemUIBinder.class}) -public abstract class ComponentBinder { - /** */ - @Binds - public abstract ContextComponentHelper bindComponentHelper( - ContextComponentResolver componentHelper); +@Module(includes = {DefaultActivityBinder.class, DefaultServiceBinder.class, SystemUIBinder.class}) +public abstract class DefaultComponentBinder { } diff --git a/packages/SystemUI/src/com/android/systemui/dagger/ServiceBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/DefaultServiceBinder.java similarity index 96% rename from packages/SystemUI/src/com/android/systemui/dagger/ServiceBinder.java rename to packages/SystemUI/src/com/android/systemui/dagger/DefaultServiceBinder.java index 1f2c0a18f928f..14bb80c79e271 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/ServiceBinder.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/DefaultServiceBinder.java @@ -31,7 +31,7 @@ import dagger.multibindings.IntoMap; * Services that are injectable should go here. */ @Module -public abstract class ServiceBinder { +public abstract class DefaultServiceBinder { /** */ @Binds @IntoMap diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java index 738f53920b98d..27c526b22283e 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIBinder.java @@ -24,6 +24,7 @@ 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.statusbar.phone.StatusBar; import com.android.systemui.util.leak.GarbageMonitor; import com.android.systemui.volume.VolumeUI; @@ -80,6 +81,12 @@ public abstract class SystemUIBinder { @ClassKey(ScreenDecorations.class) public abstract SystemUI bindScreenDecorations(ScreenDecorations sysui); + /** Inject into StatusBar. */ + @Binds + @IntoMap + @ClassKey(StatusBar.class) + public abstract SystemUI bindsStatusBar(StatusBar sysui); + /** Inject into VolumeUI. */ @Binds @IntoMap diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java index c95b50b195b37..7b8d3bc4a1218 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIDefaultModule.java @@ -21,7 +21,6 @@ import static com.android.systemui.Dependency.LEAK_REPORT_EMAIL_NAME; import androidx.annotation.Nullable; -import com.android.systemui.SystemUI; import com.android.systemui.dock.DockManager; import com.android.systemui.dock.DockManagerImpl; import com.android.systemui.power.EnhancedEstimates; @@ -39,8 +38,6 @@ import javax.inject.Singleton; import dagger.Binds; import dagger.Module; import dagger.Provides; -import dagger.multibindings.ClassKey; -import dagger.multibindings.IntoMap; /** * A dagger module for injecting default implementations of components of System UI that may be @@ -74,11 +71,6 @@ abstract class SystemUIDefaultModule { @Binds abstract ShadeController provideShadeController(StatusBar statusBar); - @Binds - @IntoMap - @ClassKey(StatusBar.class) - public abstract SystemUI providesStatusBar(StatusBar statusBar); - @Singleton @Provides @Named(ALLOW_NOTIFICATION_LONG_PRESS_NAME) diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index 4e60f194e5524..ca8e53deffdcd 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -30,6 +30,7 @@ import com.android.systemui.util.sensors.AsyncSensorManager; import javax.inject.Singleton; +import dagger.Binds; import dagger.Module; import dagger.Provides; @@ -38,9 +39,12 @@ import dagger.Provides; * implementation. */ @Module(includes = {AssistModule.class, - ComponentBinder.class, PeopleHubModule.class}) public abstract class SystemUIModule { + /** */ + @Binds + public abstract ContextComponentHelper bindComponentHelper( + ContextComponentResolver componentHelper); @Singleton @Provides @@ -56,7 +60,6 @@ public abstract class SystemUIModule { keyguardUpdateMonitor); } - @Singleton @Provides static SysUiState provideSysUiState() { diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIRootComponent.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIRootComponent.java index 113c9c845d95a..83d956c22fb82 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIRootComponent.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIRootComponent.java @@ -37,6 +37,7 @@ import dagger.Component; */ @Singleton @Component(modules = { + DefaultComponentBinder.class, DependencyProvider.class, DependencyBinder.class, SystemServicesModule.class,