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

Commit 131356a8 authored by Nicolò Mazzucato's avatar Nicolò Mazzucato
Browse files

Fix context and resources used for keyguard presentation

This avoids creating a new context if the default context in the dagger graph is already the correct one for the display in the scope.

Before this cl, a new context was created also for the default display, and it had the wrong android.R.attr.isLightTheme value.

Ideally we should use the DisplaySpecific context in ClockEventController as well, but we first need to fix isLightTheme wrong value in the new display specific context.

Test: Manually check clocks colors + KeyguardClockSwitchScreenshotTest
Bug: 299256162
Change-Id: I942c8e35a644df27a6f442d7eddf8a2a767765be
parent f9a6b1a7
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import androidx.lifecycle.repeatOnLifecycle
import com.android.systemui.customization.R
import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.DisplaySpecific
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags.DOZING_MIGRATION_1
@@ -79,7 +80,7 @@ constructor(
    private val batteryController: BatteryController,
    private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
    private val configurationController: ConfigurationController,
    @Main private val resources: Resources,
    @DisplaySpecific private val resources: Resources,
    private val context: Context,
    @Main private val mainExecutor: DelayableExecutor,
    @Background private val bgExecutor: Executor,
+6 −4
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import android.content.Context
import android.content.res.Resources
import android.view.Display
import com.android.systemui.dagger.qualifiers.DisplaySpecific
import com.android.systemui.util.kotlin.getOrNull
import dagger.BindsOptionalOf
import dagger.Module
import dagger.Provides
@@ -23,11 +24,12 @@ abstract class KeyguardDisplayModule {
    companion object {
        @Provides
        @DisplaySpecific
        fun getDisplayContext(context: Context, display: Optional<Display>): Context {
            return if (display.isPresent) {
                context.createDisplayContext(display.get())
            } else {
        fun getDisplayContext(context: Context, optionalDisplay: Optional<Display>): Context {
            val display = optionalDisplay.getOrNull() ?: return context
            return if (context.displayId == display.displayId) {
                context
            } else {
                context.createDisplayContext(display)
            }
        }