Merge "Remove released flag SMARTSPACE_DATE_WEATHER_DECOUPLED and its use sites." into main

This commit is contained in:
Xiaowen Lei 2023-11-13 18:24:29 +00:00 committed by Android (Google) Code Review
commit be10ee5a41
5 changed files with 33 additions and 135 deletions

View File

@ -316,11 +316,6 @@ object Flags {
val SMARTSPACE_SHARED_ELEMENT_TRANSITION_ENABLED =
releasedFlag("smartspace_shared_element_transition_enabled")
// TODO(b/258517050): Clean up after the feature is launched.
@JvmField
val SMARTSPACE_DATE_WEATHER_DECOUPLED =
sysPropBooleanFlag("persist.sysui.ss.dw_decoupled", default = true)
// TODO(b/270223352): Tracking Bug
@JvmField
val HIDE_SMARTSPACE_ON_DREAM_OVERLAY = releasedFlag("hide_smartspace_on_dream_overlay")

View File

@ -17,11 +17,10 @@
package com.android.systemui.smartspace.config
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.plugins.BcSmartspaceConfigPlugin
class BcSmartspaceConfigProvider(private val featureFlags: FeatureFlags) :
BcSmartspaceConfigPlugin {
override val isDefaultDateWeatherDisabled: Boolean
get() = featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)
get() = true
}

View File

@ -269,8 +269,7 @@ constructor(
fun isDateWeatherDecoupled(): Boolean {
execution.assertIsMainThread()
return featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED) &&
datePlugin != null && weatherPlugin != null
return datePlugin != null && weatherPlugin != null
}
fun isWeatherEnabled(): Boolean {
@ -501,8 +500,8 @@ constructor(
}
private fun filterSmartspaceTarget(t: SmartspaceTarget): Boolean {
if (isDateWeatherDecoupled()) {
return t.featureType != SmartspaceTarget.FEATURE_WEATHER
if (isDateWeatherDecoupled() && t.featureType == SmartspaceTarget.FEATURE_WEATHER) {
return false
}
if (!showNotifications) {
return t.featureType == SmartspaceTarget.FEATURE_WEATHER

View File

@ -20,10 +20,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.smartspace.config.BcSmartspaceConfigProvider
import com.android.systemui.util.mockito.whenever
import junit.framework.Assert.assertFalse
import junit.framework.Assert.assertTrue
import org.junit.Before
import org.junit.Test
@ -45,16 +42,7 @@ class BcSmartspaceConfigProviderTest : SysuiTestCase() {
}
@Test
fun isDefaultDateWeatherDisabled_flagIsTrue_returnsTrue() {
whenever(featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)).thenReturn(true)
fun isDefaultDateWeatherDisabled_returnsTrue() {
assertTrue(configProvider.isDefaultDateWeatherDisabled)
}
@Test
fun isDefaultDateWeatherDisabled_flagIsFalse_returnsFalse() {
whenever(featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)).thenReturn(false)
assertFalse(configProvider.isDefaultDateWeatherDisabled)
}
}

View File

@ -38,7 +38,6 @@ import com.android.keyguard.KeyguardUpdateMonitor
import com.android.systemui.SysuiTestCase
import com.android.systemui.dump.DumpManager
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.BcSmartspaceConfigPlugin
import com.android.systemui.plugins.BcSmartspaceDataPlugin
@ -205,10 +204,6 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
fun setUp() {
MockitoAnnotations.initMocks(this)
// Todo(b/261760571): flip the flag value here when feature is launched, and update relevant
// tests.
`when`(featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)).thenReturn(false)
`when`(secureSettings.getUriFor(PRIVATE_LOCKSCREEN_SETTING))
.thenReturn(fakePrivateLockscreenSettingUri)
`when`(secureSettings.getUriFor(NOTIF_ON_LOCKSCREEN_SETTING))
@ -260,17 +255,6 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
deviceProvisionedListener = deviceProvisionedCaptor.value
}
@Test(expected = RuntimeException::class)
fun testBuildAndConnectWeatherView_throwsIfDecouplingDisabled() {
// GIVEN the feature flag is disabled
`when`(featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)).thenReturn(false)
// WHEN we try to build the view
controller.buildAndConnectWeatherView(fakeParent)
// THEN an exception is thrown
}
@Test
fun testBuildAndConnectView_connectsOnlyAfterDeviceIsProvisioned() {
// GIVEN an unprovisioned device and an attempt to connect
@ -332,6 +316,8 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
clearInvocations(plugin)
// WHEN the session is closed
controller.stateChangeListener.onViewDetachedFromWindow(dateSmartspaceView as View)
controller.stateChangeListener.onViewDetachedFromWindow(weatherSmartspaceView as View)
controller.stateChangeListener.onViewDetachedFromWindow(smartspaceView as View)
controller.disconnect()
@ -375,20 +361,6 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
// WHEN the theme changes
configChangeListener.onThemeChanged()
// We update the new text color to match the wallpaper color
verify(smartspaceView).setPrimaryTextColor(anyInt())
}
@Test
fun testThemeChange_ifDecouplingEnabled_updatesTextColor() {
`when`(featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)).thenReturn(true)
// GIVEN a connected smartspace session
connectSession()
// WHEN the theme changes
configChangeListener.onThemeChanged()
// We update the new text color to match the wallpaper color
verify(dateSmartspaceView).setPrimaryTextColor(anyInt())
verify(weatherSmartspaceView).setPrimaryTextColor(anyInt())
@ -403,20 +375,6 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
// WHEN the doze amount changes
statusBarStateListener.onDozeAmountChanged(0.1f, 0.7f)
// We pass that along to the view
verify(smartspaceView).setDozeAmount(0.7f)
}
@Test
fun testDozeAmountChange_ifDecouplingEnabled_updatesViews() {
`when`(featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)).thenReturn(true)
// GIVEN a connected smartspace session
connectSession()
// WHEN the doze amount changes
statusBarStateListener.onDozeAmountChanged(0.1f, 0.7f)
// We pass that along to the view
verify(dateSmartspaceView).setDozeAmount(0.7f)
verify(weatherSmartspaceView).setDozeAmount(0.7f)
@ -472,7 +430,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
}
@Test
fun testAllTargetsAreFilteredExceptWeatherWhenNotificationsAreDisabled() {
fun testAllTargetsAreFilteredInclWeatherWhenNotificationsAreDisabled() {
// GIVEN the active user doesn't allow any notifications on lockscreen
setShowNotifications(userHandlePrimary, false)
connectSession()
@ -488,7 +446,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
sessionListener.onTargetsAvailable(targets)
// THEN all non-sensitive content is still shown
verify(plugin).onTargetsAvailable(eq(listOf(targets[3])))
verify(plugin).onTargetsAvailable(emptyList())
}
@Test
@ -519,8 +477,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
}
@Test
fun testSessionListener_ifDecouplingEnabled_weatherTargetIsFilteredOut() {
`when`(featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)).thenReturn(true)
fun testSessionListener_weatherTargetIsFilteredOut() {
connectSession()
// WHEN we receive a list of targets
@ -670,8 +627,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
}
@Test
fun testSessionListener_ifDecouplingEnabled_weatherDataUpdates() {
`when`(featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)).thenReturn(true)
fun testSessionListener_weatherDataUpdates() {
connectSession()
clock.setCurrentTimeMillis(SMARTSPACE_TIME_JUST_RIGHT)
@ -698,33 +654,6 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
})
}
@Test
fun testSessionListener_ifDecouplingDisabled_weatherDataUpdates() {
`when`(featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)).thenReturn(false)
connectSession()
clock.setCurrentTimeMillis(SMARTSPACE_TIME_JUST_RIGHT)
// WHEN we receive a list of targets
val targets = listOf(
makeWeatherTargetWithExtras(
id = 1,
userHandle = userHandlePrimary,
description = "Sunny",
state = WeatherData.WeatherStateIcon.SUNNY.id,
temperature = "32",
useCelsius = false),
makeTarget(2, userHandlePrimary, isSensitive = true)
)
sessionListener.onTargetsAvailable(targets)
verify(keyguardUpdateMonitor).sendWeatherData(argThat { w ->
w.description == "Sunny" &&
w.state == WeatherData.WeatherStateIcon.SUNNY &&
w.temperature == 32 && !w.useCelsius
})
}
@Test
fun testSettingsAreReloaded() {
// GIVEN a connected session where the privacy settings later flip to false
@ -781,6 +710,8 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
connectSession()
// WHEN we are told to cleanup
controller.stateChangeListener.onViewDetachedFromWindow(dateSmartspaceView as View)
controller.stateChangeListener.onViewDetachedFromWindow(weatherSmartspaceView as View)
controller.stateChangeListener.onViewDetachedFromWindow(smartspaceView as View)
controller.disconnect()
@ -815,16 +746,6 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
verify(smartspaceView2).registerConfigProvider(configPlugin)
}
@Test
fun testWeatherViewUsesSameSession() {
`when`(featureFlags.isEnabled(Flags.SMARTSPACE_DATE_WEATHER_DECOUPLED)).thenReturn(true)
// GIVEN a connected session
connectSession()
// No checks is needed here, since connectSession() already checks internally that
// createSmartspaceSession is invoked only once.
}
@Test
fun testViewGetInitializedWithBypassEnabledState() {
// GIVEN keyguard bypass is enabled.
@ -853,31 +774,29 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
}
private fun connectSession() {
if (controller.isDateWeatherDecoupled()) {
val dateView = controller.buildAndConnectDateView(fakeParent)
dateSmartspaceView = dateView as SmartspaceView
fakeParent.addView(dateView)
controller.stateChangeListener.onViewAttachedToWindow(dateView)
val dateView = controller.buildAndConnectDateView(fakeParent)
dateSmartspaceView = dateView as SmartspaceView
fakeParent.addView(dateView)
controller.stateChangeListener.onViewAttachedToWindow(dateView)
verify(dateSmartspaceView).setUiSurface(
BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
verify(dateSmartspaceView).registerDataProvider(datePlugin)
verify(dateSmartspaceView).setUiSurface(
BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
verify(dateSmartspaceView).registerDataProvider(datePlugin)
verify(dateSmartspaceView).setPrimaryTextColor(anyInt())
verify(dateSmartspaceView).setDozeAmount(0.5f)
verify(dateSmartspaceView).setPrimaryTextColor(anyInt())
verify(dateSmartspaceView).setDozeAmount(0.5f)
val weatherView = controller.buildAndConnectWeatherView(fakeParent)
weatherSmartspaceView = weatherView as SmartspaceView
fakeParent.addView(weatherView)
controller.stateChangeListener.onViewAttachedToWindow(weatherView)
val weatherView = controller.buildAndConnectWeatherView(fakeParent)
weatherSmartspaceView = weatherView as SmartspaceView
fakeParent.addView(weatherView)
controller.stateChangeListener.onViewAttachedToWindow(weatherView)
verify(weatherSmartspaceView).setUiSurface(
BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
verify(weatherSmartspaceView).registerDataProvider(weatherPlugin)
verify(weatherSmartspaceView).setUiSurface(
BcSmartspaceDataPlugin.UI_SURFACE_LOCK_SCREEN_AOD)
verify(weatherSmartspaceView).registerDataProvider(weatherPlugin)
verify(weatherSmartspaceView).setPrimaryTextColor(anyInt())
verify(weatherSmartspaceView).setDozeAmount(0.5f)
}
verify(weatherSmartspaceView).setPrimaryTextColor(anyInt())
verify(weatherSmartspaceView).setDozeAmount(0.5f)
val view = controller.buildAndConnectView(fakeParent)
smartspaceView = view as SmartspaceView
@ -918,10 +837,8 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
verify(smartspaceView).setPrimaryTextColor(anyInt())
verify(smartspaceView).setDozeAmount(0.5f)
if (controller.isDateWeatherDecoupled()) {
clearInvocations(dateSmartspaceView)
clearInvocations(weatherSmartspaceView)
}
clearInvocations(dateSmartspaceView)
clearInvocations(weatherSmartspaceView)
clearInvocations(smartspaceView)
}