summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalAutoOpenInteractorTest.kt4
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractorTest.kt4
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/communal/posturing/domain/interactor/PosturingInteractorTest.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSettingsRepository.kt9
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/posturing/domain/interactor/PosturingInteractor.kt12
5 files changed, 19 insertions, 12 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalAutoOpenInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalAutoOpenInteractorTest.kt
index 856a62e3f5a7..a6be3ce43b6a 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalAutoOpenInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalAutoOpenInteractorTest.kt
@@ -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(
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractorTest.kt
index d6f7145bd770..c671aed1f4a1 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractorTest.kt
@@ -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,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/posturing/domain/interactor/PosturingInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/posturing/domain/interactor/PosturingInteractorTest.kt
index b4708d97c4c3..80f0005cb73f 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/posturing/domain/interactor/PosturingInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/posturing/domain/interactor/PosturingInteractorTest.kt
@@ -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() =
diff --git a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSettingsRepository.kt b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSettingsRepository.kt
index 42a345b7deb4..8d599541b184 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSettingsRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/data/repository/CommunalSettingsRepository.kt
@@ -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
diff --git a/packages/SystemUI/src/com/android/systemui/communal/posturing/domain/interactor/PosturingInteractor.kt b/packages/SystemUI/src/com/android/systemui/communal/posturing/domain/interactor/PosturingInteractor.kt
index e487590d87d7..25c7f477c815 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/posturing/domain/interactor/PosturingInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/posturing/domain/interactor/PosturingInteractor.kt
@@ -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()) {
- combine(posturedSmoothed, debugPostured) { postured, debugValue ->
- debugValue.asBoolean() ?: postured.asBoolean() ?: false
- }
- } else {
- MutableStateFlow(false)
+ val postured: Flow<Boolean> =
+ combine(posturedSmoothed, debugPostured) { postured, debugValue ->
+ debugValue.asBoolean() ?: postured.asBoolean() ?: false
}
- }
/**
* Helper for observing a trigger sensor, which automatically unregisters itself after it