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

Commit bbe0e03f authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

Use correct context, resources and configuration in bouncer + keyboard packages

Thanks to a linter that highlights non-annotated usages of resources, we realized several classes were not using the correct context.

Here:
- A few classes in the biometrics package were using ShadeDisplayAware context and resources, when they should have used the global one (for the default display), as they were tied to the finger print sensor (that at least for now, is only on the device)
- In a few other classes, @Application context and @Main resources have been used, as they are unrelated to the shade (and are not planning to move between displays)
- Many QS classes were not using the correct context. Now all those classes are either annotated with @ShadeDisplayAware, or @Main/@Application.

Generally, there shouldn't be not-annotated usages of context, resources, Layout inflator or Configuration{Repository|Interactor|State} after this cl.
There are 2 exceptions that are being clarified.

The expectation is that when the flag is off, there are no runtime changes (as the instances provided, even after these changes, will be exactly the same).

Bug: 362719719
Bug: 374267505
Test: presubmits + e2e tests
Flag: com.android.systemui.shade_window_goes_around
Change-Id: I6bc4fd5d3ccdd20e65232844488a748490bcc7fd
parent f2290c21
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.systemui.bouncer.data.repository

import android.content.res.Resources
import com.android.internal.R
import com.android.systemui.common.ui.GlobalConfig
import com.android.systemui.common.ui.data.repository.ConfigurationRepository
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
@@ -36,7 +37,7 @@ class EmergencyServicesRepository
constructor(
    @Application private val applicationScope: CoroutineScope,
    @Main private val resources: Resources,
    configurationRepository: ConfigurationRepository,
    @GlobalConfig configurationRepository: ConfigurationRepository,
) {
    /**
     * Whether to enable emergency services calls while the SIM card is locked. This is disabled in
+2 −1
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import com.android.systemui.keyguard.data.repository.TrustRepository
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.res.R
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.shared.system.SysUiStatsLog
import com.android.systemui.statusbar.policy.KeyguardStateController
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
@@ -71,7 +72,7 @@ constructor(
    private val primaryBouncerCallbackInteractor: PrimaryBouncerCallbackInteractor,
    private val falsingCollector: FalsingCollector,
    private val dismissCallbackRegistry: DismissCallbackRegistry,
    private val context: Context,
    @ShadeDisplayAware private val context: Context,
    private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
    private val trustRepository: TrustRepository,
    @Application private val applicationScope: CoroutineScope,
+2 −1
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ 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.res.R
import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionsRepository
import com.android.systemui.util.icuMessageFormat
import javax.inject.Inject
@@ -62,7 +63,7 @@ constructor(
    @Background private val backgroundDispatcher: CoroutineDispatcher,
    private val repository: SimBouncerRepository,
    private val telephonyManager: TelephonyManager,
    @Main private val resources: Resources,
    @ShadeDisplayAware private val resources: Resources,
    private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
    private val euiccManager: EuiccManager?,
    // TODO(b/307977401): Replace this with `MobileConnectionsInteractor` when available.
+4 −3
Original line number Diff line number Diff line
@@ -21,11 +21,12 @@ import android.view.Surface
import android.view.WindowManager
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.settingslib.Utils
import com.android.systemui.common.ui.GlobalConfig
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.keyboard.docking.domain.interactor.KeyboardDockingIndicationInteractor
import com.android.systemui.shade.ShadeDisplayAware
import com.android.systemui.surfaceeffects.glowboxeffect.GlowBoxConfig
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -37,9 +38,9 @@ class KeyboardDockingIndicationViewModel
@Inject
constructor(
    private val windowManager: WindowManager,
    private val context: Context,
    @Application private val context: Context,
    keyboardDockingIndicationInteractor: KeyboardDockingIndicationInteractor,
    @ShadeDisplayAware configurationInteractor: ConfigurationInteractor,
    @GlobalConfig configurationInteractor: ConfigurationInteractor,
    @Background private val backgroundScope: CoroutineScope,
) {