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

Commit 6bef4eb9 authored by 0's avatar 0
Browse files

Wrap ShadeViewController in a Provider in BaseCommunalViewModel

Prevents the NSSL from being inflated twice during startup with SCENE_CONTAINER flags enabled, causing a crashloop.

Test: manual
Bug: 309170620
Flag: NONE
Change-Id: Ia37c3fa9ede5aaa81646b9bdd5b2933e33a602ee
parent aec048d6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import com.android.systemui.smartspace.data.repository.FakeSmartspaceRepository
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import javax.inject.Provider
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runTest
import org.junit.Before
@@ -83,7 +84,7 @@ class CommunalEditModeViewModelTest : SysuiTestCase() {
        underTest =
            CommunalEditModeViewModel(
                withDeps.communalInteractor,
                shadeViewController,
                Provider { shadeViewController },
                powerManager,
                mediaHost,
            )
+2 −1
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import com.android.systemui.smartspace.data.repository.FakeSmartspaceRepository
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.mockito.whenever
import com.google.common.truth.Truth.assertThat
import javax.inject.Provider
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runTest
import org.junit.Before
@@ -84,7 +85,7 @@ class CommunalViewModelTest : SysuiTestCase() {
            CommunalViewModel(
                withDeps.communalInteractor,
                withDeps.tutorialInteractor,
                shadeViewController,
                Provider { shadeViewController },
                powerManager,
                mediaHost,
            )
+3 −2
Original line number Diff line number Diff line
@@ -24,13 +24,14 @@ import com.android.systemui.communal.domain.model.CommunalContentModel
import com.android.systemui.communal.shared.model.CommunalSceneKey
import com.android.systemui.media.controls.ui.MediaHost
import com.android.systemui.shade.ShadeViewController
import javax.inject.Provider
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow

/** The base view model for the communal hub. */
abstract class BaseCommunalViewModel(
    private val communalInteractor: CommunalInteractor,
    private val shadeViewController: ShadeViewController,
    private val shadeViewController: Provider<ShadeViewController>,
    private val powerManager: PowerManager,
    val mediaHost: MediaHost,
) {
@@ -48,7 +49,7 @@ abstract class BaseCommunalViewModel(
    fun onOuterTouch(motionEvent: MotionEvent) {
        // Forward the touch to the shade so that basic gestures like swipe up/down for
        // shade/bouncer work.
        shadeViewController.handleExternalTouch(motionEvent)
        shadeViewController.get().handleExternalTouch(motionEvent)
    }

    // TODO(b/308813166): remove once CommunalContainer is moved lower in z-order and doesn't block
+2 −1
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import com.android.systemui.media.dagger.MediaModule
import com.android.systemui.shade.ShadeViewController
import javax.inject.Inject
import javax.inject.Named
import javax.inject.Provider
import kotlinx.coroutines.flow.Flow

/** The view model for communal hub in edit mode. */
@@ -33,7 +34,7 @@ class CommunalEditModeViewModel
@Inject
constructor(
    private val communalInteractor: CommunalInteractor,
    shadeViewController: ShadeViewController,
    shadeViewController: Provider<ShadeViewController>,
    powerManager: PowerManager,
    @Named(MediaModule.COMMUNAL_HUB) mediaHost: MediaHost,
) : BaseCommunalViewModel(communalInteractor, shadeViewController, powerManager, mediaHost) {
+2 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.systemui.media.dagger.MediaModule
import com.android.systemui.shade.ShadeViewController
import javax.inject.Inject
import javax.inject.Named
import javax.inject.Provider
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
@@ -39,7 +40,7 @@ class CommunalViewModel
constructor(
    private val communalInteractor: CommunalInteractor,
    tutorialInteractor: CommunalTutorialInteractor,
    shadeViewController: ShadeViewController,
    shadeViewController: Provider<ShadeViewController>,
    powerManager: PowerManager,
    @Named(MediaModule.COMMUNAL_HUB) mediaHost: MediaHost,
) : BaseCommunalViewModel(communalInteractor, shadeViewController, powerManager, mediaHost) {