Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9e686b9 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[Central Surfaces] Make LetterboxBackgroundProvider a singleton.

See bug for more information.

Bug: 277762009
Test: compiles
Test: `adb shell dumpsys activity service
com.android.systemui/.SystemUIService LetterboxBackgroundProvider` ->
dumps letterbox provider info
Test: atest LetterboxBackgroundProviderTest

Change-Id: Id589c335d19468d3320b8a33ea0ed5d2246e0f5b
parent 86e2b60c
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ import com.android.systemui.settings.dagger.MultiUserUtilsModule
import com.android.systemui.shortcut.ShortcutKeyDispatcher
import com.android.systemui.statusbar.notification.InstantAppNotifier
import com.android.systemui.statusbar.phone.KeyguardLiftController
import com.android.systemui.statusbar.phone.LetterboxModule
import com.android.systemui.stylus.StylusUsiPowerStartable
import com.android.systemui.temporarydisplay.chipbar.ChipbarCoordinator
import com.android.systemui.theme.ThemeOverlayController
@@ -66,7 +67,8 @@ import dagger.multibindings.IntoMap
 */
@Module(includes = [
    MultiUserUtilsModule::class,
    StartControlsStartableModule::class
    StartControlsStartableModule::class,
    LetterboxModule::class,
])
abstract class SystemUICoreStartableModule {
    /** Inject into AuthController.  */
+4 −13
Original line number Diff line number Diff line
@@ -22,28 +22,25 @@ import android.graphics.Color
import android.os.Handler
import android.os.RemoteException
import android.view.IWindowManager
import com.android.systemui.CoreStartable
import com.android.systemui.Dumpable
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dump.DumpManager
import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent
import com.android.systemui.statusbar.phone.dagger.CentralSurfacesComponent.CentralSurfacesScope
import java.io.PrintWriter
import java.util.concurrent.Executor
import javax.inject.Inject

/** Responsible for providing information about the background of letterboxed apps. */
@CentralSurfacesScope
@SysUISingleton
class LetterboxBackgroundProvider
@Inject
constructor(
    private val windowManager: IWindowManager,
    @Background private val backgroundExecutor: Executor,
    private val dumpManager: DumpManager,
    private val wallpaperManager: WallpaperManager,
    @Main private val mainHandler: Handler,
) : CentralSurfacesComponent.Startable, Dumpable {

) : CoreStartable, Dumpable {
    @ColorInt
    var letterboxBackgroundColor: Int = Color.BLACK
        private set
@@ -57,7 +54,6 @@ constructor(
        }

    override fun start() {
        dumpManager.registerDumpable(javaClass.simpleName, this)
        fetchBackgroundColorInfo()
        wallpaperManager.addOnColorsChangedListener(wallpaperColorsListener, mainHandler)
    }
@@ -74,11 +70,6 @@ constructor(
        }
    }

    override fun stop() {
        dumpManager.unregisterDumpable(javaClass.simpleName)
        wallpaperManager.removeOnColorsChangedListener(wallpaperColorsListener)
    }

    override fun dump(pw: PrintWriter, args: Array<out String>) {
        pw.println(
            """
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.statusbar.phone

import com.android.systemui.CoreStartable
import dagger.Binds
import dagger.Module
import dagger.multibindings.ClassKey
import dagger.multibindings.IntoMap

@Module
abstract class LetterboxModule {
    @Binds
    @IntoMap
    @ClassKey(LetterboxBackgroundProvider::class)
    abstract fun bindFeature(impl: LetterboxBackgroundProvider): CoreStartable
}
+2 −8
Original line number Diff line number Diff line
@@ -17,16 +17,15 @@
package com.android.systemui.statusbar.phone.dagger;

import com.android.systemui.statusbar.phone.LetterboxAppearanceCalculator;
import com.android.systemui.statusbar.phone.LetterboxBackgroundProvider;
import com.android.systemui.statusbar.phone.SystemBarAttributesListener;

import java.util.Set;

import dagger.Binds;
import dagger.Module;
import dagger.multibindings.IntoSet;
import dagger.multibindings.Multibinds;

import java.util.Set;

@Module
interface CentralSurfacesStartableModule {
    @Multibinds
@@ -41,9 +40,4 @@ interface CentralSurfacesStartableModule {
    @IntoSet
    CentralSurfacesComponent.Startable sysBarAttrsListener(
            SystemBarAttributesListener systemBarAttributesListener);

    @Binds
    @IntoSet
    CentralSurfacesComponent.Startable letterboxBgProvider(
            LetterboxBackgroundProvider letterboxBackgroundProvider);
}
+1 −4
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.testing.AndroidTestingRunner
import android.view.IWindowManager
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.dump.DumpManager
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.mockito.eq
import com.android.systemui.util.time.FakeSystemClock
@@ -52,7 +51,6 @@ class LetterboxBackgroundProviderTest : SysuiTestCase() {
    @get:Rule var expect: Expect = Expect.create()

    @Mock private lateinit var windowManager: IWindowManager
    @Mock private lateinit var dumpManager: DumpManager
    @Mock private lateinit var wallpaperManager: WallpaperManager

    private lateinit var provider: LetterboxBackgroundProvider
@@ -65,8 +63,7 @@ class LetterboxBackgroundProviderTest : SysuiTestCase() {

        setUpWallpaperManager()
        provider =
            LetterboxBackgroundProvider(
                windowManager, fakeExecutor, dumpManager, wallpaperManager, mainHandler)
            LetterboxBackgroundProvider(windowManager, fakeExecutor, wallpaperManager, mainHandler)
    }

    private fun setUpWallpaperManager() {