diff options
| author | 2024-06-28 20:59:59 +0000 | |
|---|---|---|
| committer | 2024-06-28 20:59:59 +0000 | |
| commit | 69a415e8d57ba73ae96911940b611f1529f2b128 (patch) | |
| tree | 2a9fc2a6d7c5c9e28b0126662bd46b4352ba1f46 | |
| parent | 26531acea5181d9416e39f6349d6ba5edcce3871 (diff) | |
| parent | 0f1c0d8092291e9aee52a965679ebbd55d6d715a (diff) | |
Merge "Remove the "show all widgets" setting for communal hub." into main
8 files changed, 10 insertions, 200 deletions
diff --git a/packages/SettingsLib/aconfig/settingslib.aconfig b/packages/SettingsLib/aconfig/settingslib.aconfig index 4ac3e671a378..8666584e0972 100644 --- a/packages/SettingsLib/aconfig/settingslib.aconfig +++ b/packages/SettingsLib/aconfig/settingslib.aconfig @@ -64,13 +64,6 @@ flag { } flag { - name: "allow_all_widgets_on_lockscreen_by_default" - namespace: "systemui" - description: "Allow all widgets on the lock screen by default." - bug: "328261690" -} - -flag { name: "enable_determining_advanced_details_header_with_metadata" namespace: "pixel_cross_device_control" description: "Use metadata instead of device type to determine whether a bluetooth device should use advanced details header." diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSettingsRepositoryImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSettingsRepositoryImplTest.kt index fb2b33d70c47..da40f640d5fa 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSettingsRepositoryImplTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/data/repository/CommunalSettingsRepositoryImplTest.kt @@ -20,7 +20,6 @@ import android.app.admin.DevicePolicyManager import android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_NONE import android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_WIDGETS_ALL import android.app.admin.devicePolicyManager -import android.appwidget.AppWidgetProviderInfo import android.content.Intent import android.content.pm.UserInfo import android.os.UserManager.USER_TYPE_PROFILE_MANAGED @@ -29,7 +28,6 @@ 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.settingslib.flags.Flags.FLAG_ALLOW_ALL_WIDGETS_ON_LOCKSCREEN_BY_DEFAULT import com.android.systemui.Flags.FLAG_COMMUNAL_HUB import com.android.systemui.SysuiTestCase import com.android.systemui.broadcast.broadcastDispatcher @@ -183,42 +181,6 @@ class CommunalSettingsRepositoryImplTest : SysuiTestCase() { ) } - @EnableFlags(FLAG_COMMUNAL_HUB) - @Test - fun hubShowsWidgetCategoriesSetByUser() = - testScope.runTest { - kosmos.fakeSettings.putIntForUser( - CommunalSettingsRepositoryImpl.GLANCEABLE_HUB_CONTENT_SETTING, - AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN, - PRIMARY_USER.id - ) - val setting by collectLastValue(underTest.getWidgetCategories(PRIMARY_USER)) - assertThat(setting?.categories) - .isEqualTo(AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN) - } - - @EnableFlags(FLAG_COMMUNAL_HUB) - @DisableFlags(FLAG_ALLOW_ALL_WIDGETS_ON_LOCKSCREEN_BY_DEFAULT) - @Test - fun hubShowsKeyguardWidgetsByDefault() = - testScope.runTest { - val setting by collectLastValue(underTest.getWidgetCategories(PRIMARY_USER)) - assertThat(setting?.categories) - .isEqualTo(AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD) - } - - @EnableFlags(FLAG_COMMUNAL_HUB, FLAG_ALLOW_ALL_WIDGETS_ON_LOCKSCREEN_BY_DEFAULT) - @Test - fun hubShowsAllWidgetsByDefaultWhenFlagEnabled() = - testScope.runTest { - val setting by collectLastValue(underTest.getWidgetCategories(PRIMARY_USER)) - assertThat(setting?.categories) - .isEqualTo( - AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD + - AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN - ) - } - @Test fun backgroundType_defaultValue() = testScope.runTest { diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt index d951cca89f64..7b26db50814e 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/domain/interactor/CommunalInteractorTest.kt @@ -36,7 +36,6 @@ import com.android.compose.animation.scene.ObservableTransitionState import com.android.systemui.Flags.FLAG_COMMUNAL_HUB import com.android.systemui.SysuiTestCase import com.android.systemui.broadcast.broadcastDispatcher -import com.android.systemui.communal.data.repository.CommunalSettingsRepositoryImpl import com.android.systemui.communal.data.repository.FakeCommunalMediaRepository import com.android.systemui.communal.data.repository.FakeCommunalPrefsRepository import com.android.systemui.communal.data.repository.FakeCommunalSceneRepository @@ -81,7 +80,6 @@ import com.android.systemui.util.mockito.capture import com.android.systemui.util.mockito.mock import com.android.systemui.util.mockito.nullable import com.android.systemui.util.mockito.whenever -import com.android.systemui.util.settings.fakeSettings import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.MutableStateFlow @@ -915,14 +913,6 @@ class CommunalInteractorTest : SysuiTestCase() { ) runCurrent() - // Keyguard widgets are allowed. - kosmos.fakeSettings.putIntForUser( - CommunalSettingsRepositoryImpl.GLANCEABLE_HUB_CONTENT_SETTING, - AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD, - mainUser.id - ) - runCurrent() - // When work profile is paused. whenever(userManager.isQuietModeEnabled(eq(UserHandle.of(USER_INFO_WORK.id)))) .thenReturn(true) @@ -956,93 +946,6 @@ class CommunalInteractorTest : SysuiTestCase() { } @Test - fun widgetContent_containsDisabledWidgets_whenCategoryNotAllowed() = - testScope.runTest { - // Communal available, and tutorial completed. - keyguardRepository.setKeyguardShowing(true) - keyguardRepository.setKeyguardOccluded(false) - tutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_COMPLETED) - - val userInfos = listOf(MAIN_USER_INFO, USER_INFO_WORK) - userRepository.setUserInfos(userInfos) - userTracker.set( - userInfos = userInfos, - selectedUserIndex = 0, - ) - userRepository.setSelectedUserInfo(MAIN_USER_INFO) - runCurrent() - - // Widgets available. - val widget1 = - createWidgetWithCategory(1, AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN) - val widget2 = - createWidgetWithCategory(2, AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD) - val widget3 = - createWidgetWithCategory(3, AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX) - val widgets = listOf(widget1, widget2, widget3) - widgetRepository.setCommunalWidgets(widgets) - - val widgetContent by collectLastValue(underTest.widgetContent) - kosmos.fakeSettings.putIntForUser( - CommunalSettingsRepositoryImpl.GLANCEABLE_HUB_CONTENT_SETTING, - AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD, - mainUser.id - ) - - // Only the keyguard widget is enabled. - assertThat(widgetContent).hasSize(3) - assertThat(widgetContent!!.get(0)) - .isInstanceOf(CommunalContentModel.WidgetContent.DisabledWidget::class.java) - assertThat(widgetContent!!.get(1)) - .isInstanceOf(CommunalContentModel.WidgetContent.Widget::class.java) - assertThat(widgetContent!!.get(2)) - .isInstanceOf(CommunalContentModel.WidgetContent.DisabledWidget::class.java) - } - - @Test - fun widgetContent_allEnabled_whenCategoryAllowed() = - testScope.runTest { - // Communal available, and tutorial completed. - keyguardRepository.setKeyguardShowing(true) - keyguardRepository.setKeyguardOccluded(false) - tutorialRepository.setTutorialSettingState(HUB_MODE_TUTORIAL_COMPLETED) - - val userInfos = listOf(MAIN_USER_INFO, USER_INFO_WORK) - userRepository.setUserInfos(userInfos) - userTracker.set( - userInfos = userInfos, - selectedUserIndex = 0, - ) - userRepository.setSelectedUserInfo(MAIN_USER_INFO) - runCurrent() - - // Widgets available. - val widget1 = - createWidgetWithCategory(1, AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN) - val widget2 = - createWidgetWithCategory(2, AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD) - val widget3 = - createWidgetWithCategory(3, AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD) - val widgets = listOf(widget1, widget2, widget3) - widgetRepository.setCommunalWidgets(widgets) - - val widgetContent by collectLastValue(underTest.widgetContent) - kosmos.fakeSettings.putIntForUser( - CommunalSettingsRepositoryImpl.GLANCEABLE_HUB_CONTENT_SETTING, - AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD or - AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN, - mainUser.id - ) - - // All widgets are enabled. - assertThat(widgetContent).hasSize(3) - widgetContent!!.forEach { model -> - assertThat(model) - .isInstanceOf(CommunalContentModel.WidgetContent.Widget::class.java) - } - } - - @Test fun filterWidgets_whenDisallowedByDevicePolicyForWorkProfile() = testScope.runTest { // Keyguard showing, and tutorial completed. diff --git a/packages/SystemUI/src/com/android/systemui/communal/data/model/CommunalWidgetCategories.kt b/packages/SystemUI/src/com/android/systemui/communal/data/model/CommunalWidgetCategories.kt index 5cd15f278f00..75f0badfc7cb 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/data/model/CommunalWidgetCategories.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/data/model/CommunalWidgetCategories.kt @@ -17,7 +17,6 @@ package com.android.systemui.communal.data.model import android.appwidget.AppWidgetProviderInfo -import com.android.settingslib.flags.Flags.allowAllWidgetsOnLockscreenByDefault /** * The widget categories to display on communal hub (where categories is a bitfield with values that @@ -31,9 +30,7 @@ value class CommunalWidgetCategories(val categories: Int = defaultCategories) { val defaultCategories: Int get() { return AppWidgetProviderInfo.WIDGET_CATEGORY_KEYGUARD or - if (allowAllWidgetsOnLockscreenByDefault()) - AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN - else 0 + AppWidgetProviderInfo.WIDGET_CATEGORY_HOME_SCREEN } } } 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 1c47e507c972..2940a95fdc33 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 @@ -24,7 +24,6 @@ import android.provider.Settings import com.android.systemui.Flags.communalHub import com.android.systemui.broadcast.BroadcastDispatcher import com.android.systemui.communal.data.model.CommunalEnabledState -import com.android.systemui.communal.data.model.CommunalWidgetCategories import com.android.systemui.communal.data.model.DisabledReason import com.android.systemui.communal.data.model.DisabledReason.DISABLED_REASON_DEVICE_POLICY import com.android.systemui.communal.data.model.DisabledReason.DISABLED_REASON_FLAG @@ -52,12 +51,6 @@ interface CommunalSettingsRepository { /** A [CommunalEnabledState] for the specified user. */ fun getEnabledState(user: UserInfo): Flow<CommunalEnabledState> - /** - * A flow that reports the widget categories to show on the hub as selected by the user in - * Settings. - */ - fun getWidgetCategories(user: UserInfo): Flow<CommunalWidgetCategories> - /** Keyguard widgets enabled state by Device Policy Manager for the specified user. */ fun getAllowedByDevicePolicy(user: UserInfo): Flow<Boolean> @@ -104,22 +97,6 @@ constructor( .flowOn(bgDispatcher) } - override fun getWidgetCategories(user: UserInfo): Flow<CommunalWidgetCategories> = - secureSettings - .observerFlow(userId = user.id, names = arrayOf(GLANCEABLE_HUB_CONTENT_SETTING)) - // Force an update - .onStart { emit(Unit) } - .map { - CommunalWidgetCategories( - secureSettings.getIntForUser( - GLANCEABLE_HUB_CONTENT_SETTING, - CommunalWidgetCategories.defaultCategories, - user.id - ) - ) - } - .flowOn(bgDispatcher) - override fun getAllowedByDevicePolicy(user: UserInfo): Flow<Boolean> = broadcastDispatcher .broadcastFlow( @@ -159,7 +136,6 @@ constructor( } companion object { - const val GLANCEABLE_HUB_CONTENT_SETTING = "glanceable_hub_content_setting" const val GLANCEABLE_HUB_BACKGROUND_SETTING = "glanceable_hub_background" private const val ENABLED_SETTING_DEFAULT = 1 } diff --git a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt index 9f3ade9cd425..f5255ac4d545 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalInteractor.kt @@ -392,26 +392,17 @@ constructor( allowedForWorkProfile -> filterWidgetsAllowedByDevicePolicy(widgets, allowedForWorkProfile) }, - communalSettingsInteractor.communalWidgetCategories, updateOnWorkProfileBroadcastReceived, - ) { widgets, allowedCategories, _ -> + ) { widgets, _ -> widgets.map { widget -> when (widget) { is CommunalWidgetContentModel.Available -> { - if (widget.providerInfo.widgetCategory and allowedCategories != 0) { - // At least one category this widget specified is allowed, so show it - WidgetContent.Widget( - appWidgetId = widget.appWidgetId, - providerInfo = widget.providerInfo, - appWidgetHost = appWidgetHost, - inQuietMode = isQuietModeEnabled(widget.providerInfo.profile) - ) - } else { - WidgetContent.DisabledWidget( - appWidgetId = widget.appWidgetId, - providerInfo = widget.providerInfo, - ) - } + WidgetContent.Widget( + appWidgetId = widget.appWidgetId, + providerInfo = widget.providerInfo, + appWidgetHost = appWidgetHost, + inQuietMode = isQuietModeEnabled(widget.providerInfo.profile) + ) } is CommunalWidgetContentModel.Pending -> { WidgetContent.PendingWidget( diff --git a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractor.kt b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractor.kt index f043d58543fc..47b75c458d20 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/domain/interactor/CommunalSettingsInteractor.kt @@ -19,7 +19,6 @@ package com.android.systemui.communal.domain.interactor import android.content.pm.UserInfo import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow import com.android.systemui.communal.data.model.CommunalEnabledState -import com.android.systemui.communal.data.model.CommunalWidgetCategories import com.android.systemui.communal.data.repository.CommunalSettingsRepository import com.android.systemui.communal.shared.model.CommunalBackgroundType import com.android.systemui.dagger.SysUISingleton @@ -70,18 +69,6 @@ constructor( // Start this eagerly since the value is accessed synchronously in many places. .stateIn(scope = bgScope, started = SharingStarted.Eagerly, initialValue = false) - /** What widget categories to show on the hub. */ - val communalWidgetCategories: StateFlow<Int> = - userInteractor.selectedUserInfo - .flatMapLatest { user -> repository.getWidgetCategories(user) } - .map { categories -> categories.categories } - .stateIn( - scope = bgScope, - // Start this eagerly since the value can be accessed synchronously. - started = SharingStarted.Eagerly, - initialValue = CommunalWidgetCategories.defaultCategories - ) - /** The type of background to use for the hub. Used to experiment with different backgrounds */ val communalBackground: Flow<CommunalBackgroundType> = userInteractor.selectedUserInfo diff --git a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt index 9185384e79a3..fab243575670 100644 --- a/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/communal/ui/viewmodel/CommunalEditModeViewModel.kt @@ -25,6 +25,7 @@ import android.util.Log import androidx.activity.result.ActivityResultLauncher import com.android.internal.logging.UiEventLogger import com.android.systemui.Flags.enableWidgetPickerSizeFilter +import com.android.systemui.communal.data.model.CommunalWidgetCategories import com.android.systemui.communal.domain.interactor.CommunalInteractor import com.android.systemui.communal.domain.interactor.CommunalPrefsInteractor import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor @@ -183,7 +184,7 @@ constructor( } putExtra( AppWidgetManager.EXTRA_CATEGORY_FILTER, - communalSettingsInteractor.communalWidgetCategories.value + CommunalWidgetCategories.defaultCategories ) putExtra(EXTRA_UI_SURFACE_KEY, EXTRA_UI_SURFACE_VALUE) putParcelableArrayListExtra(EXTRA_ADDED_APP_WIDGETS_KEY, excludeList) |