diff options
| author | 2023-04-11 21:54:41 +0000 | |
|---|---|---|
| committer | 2023-04-19 15:31:33 +0000 | |
| commit | eb46ed0e7a74cf4d3f6a93ebeca6d8a54d24031c (patch) | |
| tree | 65808c24cc5917008eff516a3139e54c2e8b2c0c | |
| parent | 99c4d1a0b3c1f56b766c9049405334ae37fece55 (diff) | |
[Central Surfaces] Make SystemBarAttributesListener a singleton.
Bug: 277762009
Test: compiles
Test: SystemBarAttributesListener still receives bounds changes
Test: `adb shell dumpsys activity service
com.android.systemui/.SystemUIService SystemBarAttributesListener` ->
shows dump
Test: atest SystemBarAttributesListenerTest
Change-Id: Ieb16dccf3b0a1a11633addf18499a5161cdbca92
2 files changed, 8 insertions, 21 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemBarAttributesListener.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemBarAttributesListener.kt index fbe374c32952..c0269b8d6fca 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemBarAttributesListener.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemBarAttributesListener.kt @@ -23,10 +23,10 @@ import android.view.WindowInsetsController.Appearance import android.view.WindowInsetsController.Behavior import com.android.internal.statusbar.LetterboxDetails import com.android.internal.view.AppearanceRegion +import com.android.systemui.Dumpable +import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dump.DumpManager import com.android.systemui.statusbar.SysuiStatusBarStateController -import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent -import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent.CentralSurfacesScope import java.io.PrintWriter import javax.inject.Inject @@ -37,7 +37,7 @@ import javax.inject.Inject * It is responsible for modifying any attributes if necessary, and then notifying the other * downstream listeners. */ -@CentralSurfacesScope +@SysUISingleton class SystemBarAttributesListener @Inject internal constructor( @@ -45,18 +45,14 @@ internal constructor( private val letterboxAppearanceCalculator: LetterboxAppearanceCalculator, private val statusBarStateController: SysuiStatusBarStateController, private val lightBarController: LightBarController, - private val dumpManager: DumpManager, -) : CentralSurfacesComponent.Startable, StatusBarBoundsProvider.BoundsChangeListener { + dumpManager: DumpManager, +) : Dumpable, StatusBarBoundsProvider.BoundsChangeListener { private var lastLetterboxAppearance: LetterboxAppearance? = null private var lastSystemBarAttributesParams: SystemBarAttributesParams? = null - override fun start() { - dumpManager.registerDumpable(javaClass.simpleName, this::dump) - } - - override fun stop() { - dumpManager.unregisterDumpable(javaClass.simpleName) + init { + dumpManager.registerCriticalDumpable(this) } override fun onStatusBarBoundsChanged() { @@ -128,7 +124,7 @@ internal constructor( private fun shouldUseLetterboxAppearance(letterboxDetails: Array<LetterboxDetails>) = letterboxDetails.isNotEmpty() - private fun dump(printWriter: PrintWriter, strings: Array<String>) { + override fun dump(printWriter: PrintWriter, strings: Array<String>) { printWriter.println("lastSystemBarAttributesParams: $lastSystemBarAttributesParams") printWriter.println("lastLetterboxAppearance: $lastLetterboxAppearance") } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesStartableModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesStartableModule.java index f72e74b77aea..7ded90f7cf25 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesStartableModule.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/dagger/CentralSurfacesStartableModule.java @@ -16,11 +16,7 @@ package com.android.systemui.statusbar.phone.dagger; -import com.android.systemui.statusbar.phone.SystemBarAttributesListener; - -import dagger.Binds; import dagger.Module; -import dagger.multibindings.IntoSet; import dagger.multibindings.Multibinds; import java.util.Set; @@ -29,9 +25,4 @@ import java.util.Set; interface CentralSurfacesStartableModule { @Multibinds Set<CentralSurfacesComponent.Startable> multibindStartables(); - - @Binds - @IntoSet - CentralSurfacesComponent.Startable sysBarAttrsListener( - SystemBarAttributesListener systemBarAttributesListener); } |