diff options
| author | 2024-12-09 16:23:39 +0000 | |
|---|---|---|
| committer | 2024-12-10 10:53:42 +0000 | |
| commit | 79079b80076d40e545e61991e12958072f70e60d (patch) | |
| tree | 7dfa0466b1d1090ff6967b15e47625b5ba112fb6 | |
| parent | 869a4eda92dba12f0ea043439342972563978689 (diff) | |
Provide @Main decorated context for the default display
This creates a binding for the default context using the @Main annotation.
As we're now using several different types of context in sysui (e.g. a shade window specific one), classes that are aware they need the context only for the default display should be annotating it directly with @Main.
This also ensures consistency as we're using @Main for several other classes.
No injections of undecorated context will be forbidden with a linter eventually (and is already forbidden in shade related packages as of today with ShadeDisplayAwareContextChecker)
Bug: 362719719
Bug: 374267505
Test: presubmits
Flag: com.android.systemui.shade_window_goes_around
Change-Id: I3b0c1bc1659a2285c5ca55dd10ed8d2d2d0b7abe
4 files changed, 19 insertions, 6 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/common/ui/ConfigurationModule.kt b/packages/SystemUI/src/com/android/systemui/common/ui/ConfigurationModule.kt index d0b2408e45c0..ad504d502847 100644 --- a/packages/SystemUI/src/com/android/systemui/common/ui/ConfigurationModule.kt +++ b/packages/SystemUI/src/com/android/systemui/common/ui/ConfigurationModule.kt @@ -21,7 +21,6 @@ import com.android.systemui.common.ui.data.repository.ConfigurationRepository import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractorImpl import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.statusbar.policy.ConfigurationController import dagger.Binds @@ -54,7 +53,7 @@ interface ConfigurationModule { fun provideGlobalConfigurationState( configStateFactory: ConfigurationStateImpl.Factory, configurationController: ConfigurationController, - @Application context: Context, + @Main context: Context, ): ConfigurationState { return configStateFactory.create(context, configurationController) } diff --git a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java index 78a8a42e2743..9ae106c3ab39 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java @@ -708,6 +708,14 @@ public class FrameworkServicesModule { return context.getSystemService(WindowManager.class); } + /** A window manager working for the default display only. */ + @Provides + @Singleton + @Main + static WindowManager provideMainWindowManager(WindowManager windowManager) { + return windowManager; + } + @Provides @Singleton static ViewCaptureAwareWindowManager provideViewCaptureAwareWindowManager( diff --git a/packages/SystemUI/src/com/android/systemui/dagger/GlobalModule.java b/packages/SystemUI/src/com/android/systemui/dagger/GlobalModule.java index 3072f74dff2b..ddc88a839a63 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/GlobalModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/GlobalModule.java @@ -21,6 +21,7 @@ import android.util.DisplayMetrics; import android.view.Display; import com.android.systemui.dagger.qualifiers.Application; +import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.PluginsModule; import com.android.systemui.unfold.UnfoldTransitionModule; import com.android.systemui.util.concurrency.GlobalConcurrencyModule; @@ -62,6 +63,13 @@ public class GlobalModule { return context.getApplicationContext(); } + /** Provides the default content with the main annotation. */ + @Provides + @Main + public Context provideMainContext(Context context) { + return context; + } + /** * @deprecated Deprecdated because {@link Display#getMetrics} is deprecated. */ diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModel.kt index c04cbf8aa32d..a25d08d21517 100644 --- a/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModel.kt @@ -24,7 +24,6 @@ import com.android.app.tracing.coroutines.launchTraced as launch import com.android.settingslib.Utils import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.keyboard.docking.domain.interactor.KeyboardDockingIndicationInteractor @@ -38,9 +37,8 @@ import kotlinx.coroutines.flow.asStateFlow class KeyboardDockingIndicationViewModel @Inject constructor( - // TODO b/374267505 - Annotate this. - @SuppressLint("ShadeDisplayAwareContextChecker") private val windowManager: WindowManager, - @Application private val context: Context, + @SuppressLint("ShadeDisplayAwareContextChecker") @Main private val windowManager: WindowManager, + @SuppressLint("ShadeDisplayAwareContextChecker") @Main private val context: Context, keyboardDockingIndicationInteractor: KeyboardDockingIndicationInteractor, @SuppressLint("ShadeDisplayAwareContextChecker") @Main configurationInteractor: ConfigurationInteractor, @Background private val backgroundScope: CoroutineScope, |