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

Commit 08e4029e authored by Lucas Silva's avatar Lucas Silva Committed by Android (Google) Code Review
Browse files

Merge "Remove dream-specific flag check from posturing interactor" into main

parents 4c26ce03 e2d48453
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -16,9 +16,11 @@

package com.android.systemui.communal.domain.interactor

import android.platform.test.annotations.EnableFlags
import android.provider.Settings
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.data.repository.batteryRepository
import com.android.systemui.common.data.repository.fake
@@ -47,6 +49,7 @@ import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
@EnableFlags(FLAG_GLANCEABLE_HUB_V2)
class CommunalAutoOpenInteractorTest : SysuiTestCase() {
    private val kosmos = testKosmos().useUnconfinedTestDispatcher()

@@ -54,6 +57,7 @@ class CommunalAutoOpenInteractorTest : SysuiTestCase() {

    @Before
    fun setUp() {
        kosmos.setCommunalV2ConfigEnabled(true)
        runBlocking { kosmos.fakeUserRepository.asMainUser() }
        with(kosmos.fakeSettings) {
            putIntForUser(
+4 −0
Original line number Diff line number Diff line
@@ -21,9 +21,11 @@ import android.app.admin.devicePolicyManager
import android.content.Intent
import android.content.pm.UserInfo
import android.os.UserManager
import android.platform.test.annotations.EnableFlags
import android.provider.Settings
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags.FLAG_GLANCEABLE_HUB_V2
import com.android.systemui.SysuiTestCase
import com.android.systemui.broadcast.broadcastDispatcher
import com.android.systemui.communal.shared.model.WhenToStartHub
@@ -86,8 +88,10 @@ class CommunalSettingsInteractorTest : SysuiTestCase() {
        }

    @Test
    @EnableFlags(FLAG_GLANCEABLE_HUB_V2)
    fun whenToStartHub_matchesRepository() =
        kosmos.runTest {
            setCommunalV2ConfigEnabled(true)
            fakeSettings.putIntForUser(
                Settings.Secure.WHEN_TO_START_GLANCEABLE_HUB,
                Settings.Secure.GLANCEABLE_HUB_START_CHARGING,
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ class PosturingInteractorTest : SysuiTestCase() {

    private val kosmos = testKosmos().useUnconfinedTestDispatcher()

    private val underTest by lazy { kosmos.posturingInteractor }
    private val Kosmos.underTest by Kosmos.Fixture { kosmos.posturingInteractor }

    @Test
    fun testNoDebugOverride() =
+7 −2
Original line number Diff line number Diff line
@@ -206,8 +206,11 @@ constructor(
            }
            .flowOn(bgDispatcher)

    override fun getWhenToStartHubState(user: UserInfo): Flow<WhenToStartHub> =
        secureSettings
    override fun getWhenToStartHubState(user: UserInfo): Flow<WhenToStartHub> {
        if (!getV2FlagEnabled()) {
            return MutableStateFlow(WhenToStartHub.NEVER)
        }
        return secureSettings
            .observerFlow(
                userId = user.id,
                names = arrayOf(Settings.Secure.WHEN_TO_START_GLANCEABLE_HUB),
@@ -225,11 +228,13 @@ constructor(
                    Settings.Secure.GLANCEABLE_HUB_START_CHARGING -> WhenToStartHub.WHILE_CHARGING
                    Settings.Secure.GLANCEABLE_HUB_START_CHARGING_UPRIGHT ->
                        WhenToStartHub.WHILE_CHARGING_AND_POSTURED

                    Settings.Secure.GLANCEABLE_HUB_START_DOCKED -> WhenToStartHub.WHILE_DOCKED
                    else -> WhenToStartHub.NEVER
                }
            }
            .flowOn(bgDispatcher)
    }

    override fun getAllowedByDevicePolicy(user: UserInfo): Flow<Boolean> =
        broadcastDispatcher
+3 −9
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.annotation.SuppressLint
import android.hardware.Sensor
import android.hardware.TriggerEvent
import android.hardware.TriggerEventListener
import android.service.dreams.Flags.allowDreamWhenPostured
import com.android.systemui.communal.posturing.data.model.PositionState
import com.android.systemui.communal.posturing.data.repository.PosturingRepository
import com.android.systemui.communal.posturing.shared.model.PosturedState
@@ -170,15 +169,10 @@ constructor(
     * NOTE: Due to smoothing, this signal may be delayed to ensure we have a stable reading before
     * being considered postured.
     */
    val postured: Flow<Boolean> by lazy {
        if (allowDreamWhenPostured()) {
    val postured: Flow<Boolean> =
        combine(posturedSmoothed, debugPostured) { postured, debugValue ->
            debugValue.asBoolean() ?: postured.asBoolean() ?: false
        }
        } else {
            MutableStateFlow(false)
        }
    }

    /**
     * Helper for observing a trigger sensor, which automatically unregisters itself after it