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

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

Explicitly use Main thread context for a few view models

this fixes a few crashes related to the usage of the bg dispatcher for activating view models. Crashes were happening mainly when expanding dual shade.

Bug: 421000550
Test: expand/collapse dual shade + existing unit tests for changed classes
Flag: com.android.systemui.remember_view_model_off_main_thread
Change-Id: I3bbf16d67ec530fb19fc556c6edd7bfd433cef51
parent c92c6491
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2391,7 +2391,7 @@ public class GlobalActionsDialogLite implements DialogInterface.OnDismissListene
        }
    };

    private ContentObserver mGlobalActionsTimeoutObserver = new ContentObserver(new Handler()) {
    private ContentObserver mGlobalActionsTimeoutObserver = new ContentObserver(mMainHandler) {
        @Override
        public void onChange(boolean selfChange) {
            onGlobalActionsTimeoutChanged();
+4 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import androidx.compose.runtime.getValue
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.compose.animation.scene.ContentKey
import com.android.compose.animation.scene.ObservableTransitionState
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dump.DumpManager
import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.flags.Flags
@@ -44,6 +45,7 @@ import com.android.systemui.util.kotlin.ActivatableFlowDumperImpl
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
import java.util.function.Consumer
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filter
@@ -64,6 +66,7 @@ constructor(
    remoteInputInteractor: RemoteInputInteractor,
    featureFlags: FeatureFlagsClassic,
    dumpManager: DumpManager,
    @Main private val mainContext: CoroutineContext,
) :
    ExclusiveActivatable(),
    ActivatableFlowDumper by ActivatableFlowDumperImpl(
@@ -110,7 +113,7 @@ constructor(
        coroutineScope {
            launch { hydrator.activate() }

            launch {
            launch(context = mainContext) {
                shadeInteractor.isAnyExpanded
                    .filter { it }
                    .collect { headsUpNotificationInteractor.unpinAll(true) }
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import com.android.systemui.dump.dumpManager
import com.android.systemui.flags.featureFlagsClassic
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.testScope
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.shade.domain.interactor.shadeModeInteractor
@@ -37,6 +38,7 @@ val Kosmos.notificationsPlaceholderViewModel by Fixture {
        remoteInputInteractor = remoteInputInteractor,
        featureFlags = featureFlagsClassic,
        dumpManager = dumpManager,
        mainContext = testScope.coroutineContext,
    )
}