diff options
| author | 2025-02-07 17:06:40 -0500 | |
|---|---|---|
| committer | 2025-02-07 19:57:41 -0500 | |
| commit | f24cae6e398d8698d66044e1447237fa1018256a (patch) | |
| tree | de12202810716c40f59690eb1f25d07f72e66574 | |
| parent | e80f1b9a275793715dd7279e2ab352ed56e72e94 (diff) | |
Include the restore path in upgrade to large tiles
This adds similar treatment for upgrading from single size tiles to two
size tiles when restoring from a backup.
It also fixes a bug in the previous CL. In the case of a fresh user,
upon restart they would be upgraded to all large tiles. This is not the
case anymore.
Test: atest com.android.systemui.qs
Test: atest LargeTilesUpgradePathsTest
Fixes: 392615513
Flag: com.android.systemui.qs_ui_refactor_compose_fragment
Change-Id: Id870f6d43b26b3800f9e72d5320962c348f4e8b2
13 files changed, 617 insertions, 65 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/QSPreferencesRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/QSPreferencesRepositoryTest.kt index 264eda5a07eb..668c606677ba 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/QSPreferencesRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/QSPreferencesRepositoryTest.kt @@ -25,6 +25,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.qs.pipeline.shared.TileSpec +import com.android.systemui.qs.pipeline.shared.TilesUpgradePath import com.android.systemui.settings.userFileManager import com.android.systemui.testKosmos import com.android.systemui.user.data.repository.fakeUserRepository @@ -76,11 +77,11 @@ class QSPreferencesRepositoryTest : SysuiTestCase() { @Test fun setLargeTilesSpecs_inSharedPreferences() { val setA = setOf("tileA", "tileB") - underTest.setLargeTilesSpecs(setA.toTileSpecs()) + underTest.writeLargeTileSpecs(setA.toTileSpecs()) assertThat(getLargeTilesSpecsFromSharedPreferences()).isEqualTo(setA) val setB = setOf("tileA", "tileB") - underTest.setLargeTilesSpecs(setB.toTileSpecs()) + underTest.writeLargeTileSpecs(setB.toTileSpecs()) assertThat(getLargeTilesSpecsFromSharedPreferences()).isEqualTo(setB) } @@ -92,12 +93,12 @@ class QSPreferencesRepositoryTest : SysuiTestCase() { fakeUserRepository.setSelectedUserInfo(PRIMARY_USER) val setA = setOf("tileA", "tileB") - underTest.setLargeTilesSpecs(setA.toTileSpecs()) + underTest.writeLargeTileSpecs(setA.toTileSpecs()) assertThat(getLargeTilesSpecsFromSharedPreferences()).isEqualTo(setA) fakeUserRepository.setSelectedUserInfo(ANOTHER_USER) val setB = setOf("tileA", "tileB") - underTest.setLargeTilesSpecs(setB.toTileSpecs()) + underTest.writeLargeTileSpecs(setB.toTileSpecs()) assertThat(getLargeTilesSpecsFromSharedPreferences()).isEqualTo(setB) fakeUserRepository.setSelectedUserInfo(PRIMARY_USER) @@ -106,7 +107,7 @@ class QSPreferencesRepositoryTest : SysuiTestCase() { } @Test - fun setInitialTilesFromSettings_noLargeTiles_tilesSet() = + fun setUpgradePathFromSettings_noLargeTiles_tilesSet() = with(kosmos) { testScope.runTest { val largeTiles by collectLastValue(underTest.largeTilesSpecs) @@ -117,14 +118,17 @@ class QSPreferencesRepositoryTest : SysuiTestCase() { assertThat(getSharedPreferences().contains(LARGE_TILES_SPECS_KEY)).isFalse() - underTest.setInitialLargeTilesSpecs(tiles, PRIMARY_USER_ID) + underTest.setInitialOrUpgradeLargeTiles( + TilesUpgradePath.ReadFromSettings(tiles), + PRIMARY_USER_ID, + ) assertThat(largeTiles).isEqualTo(tiles) } } @Test - fun setInitialTilesFromSettings_alreadyLargeTiles_tilesNotSet() = + fun setUpgradePathFromSettings_alreadyLargeTiles_tilesNotSet() = with(kosmos) { testScope.runTest { val largeTiles by collectLastValue(underTest.largeTilesSpecs) @@ -133,14 +137,17 @@ class QSPreferencesRepositoryTest : SysuiTestCase() { fakeUserRepository.setSelectedUserInfo(ANOTHER_USER) setLargeTilesSpecsInSharedPreferences(setOf("tileC")) - underTest.setInitialLargeTilesSpecs(setOf("tileA").toTileSpecs(), ANOTHER_USER_ID) + underTest.setInitialOrUpgradeLargeTiles( + TilesUpgradePath.ReadFromSettings(setOf("tileA").toTileSpecs()), + ANOTHER_USER_ID, + ) assertThat(largeTiles).isEqualTo(setOf("tileC").toTileSpecs()) } } @Test - fun setInitialTilesFromSettings_emptyLargeTiles_tilesNotSet() = + fun setUpgradePathFromSettings_emptyLargeTiles_tilesNotSet() = with(kosmos) { testScope.runTest { val largeTiles by collectLastValue(underTest.largeTilesSpecs) @@ -149,14 +156,17 @@ class QSPreferencesRepositoryTest : SysuiTestCase() { fakeUserRepository.setSelectedUserInfo(ANOTHER_USER) setLargeTilesSpecsInSharedPreferences(emptySet()) - underTest.setInitialLargeTilesSpecs(setOf("tileA").toTileSpecs(), ANOTHER_USER_ID) + underTest.setInitialOrUpgradeLargeTiles( + TilesUpgradePath.ReadFromSettings(setOf("tileA").toTileSpecs()), + ANOTHER_USER_ID, + ) assertThat(largeTiles).isEmpty() } } @Test - fun setInitialTilesFromSettings_nonCurrentUser_tilesSetForCorrectUser() = + fun setUpgradePathFromSettings_nonCurrentUser_tilesSetForCorrectUser() = with(kosmos) { testScope.runTest { val largeTiles by collectLastValue(underTest.largeTilesSpecs) @@ -164,7 +174,10 @@ class QSPreferencesRepositoryTest : SysuiTestCase() { fakeUserRepository.setUserInfos(USERS) fakeUserRepository.setSelectedUserInfo(PRIMARY_USER) - underTest.setInitialLargeTilesSpecs(setOf("tileA").toTileSpecs(), ANOTHER_USER_ID) + underTest.setInitialOrUpgradeLargeTiles( + TilesUpgradePath.ReadFromSettings(setOf("tileA").toTileSpecs()), + ANOTHER_USER_ID, + ) assertThat(largeTiles).isEqualTo(defaultLargeTilesRepository.defaultLargeTiles) @@ -174,7 +187,7 @@ class QSPreferencesRepositoryTest : SysuiTestCase() { } @Test - fun setInitialTiles_afterDefaultRead_noSetOnRepository_initialTilesCorrect() = + fun setUpgradePath_afterDefaultRead_noSetOnRepository_initialTilesCorrect() = with(kosmos) { testScope.runTest { val largeTiles by collectLastValue(underTest.largeTilesSpecs) @@ -186,14 +199,17 @@ class QSPreferencesRepositoryTest : SysuiTestCase() { assertThat(currentLargeTiles).isNotEmpty() val tiles = setOf("tileA", "tileB") - underTest.setInitialLargeTilesSpecs(tiles.toTileSpecs(), PRIMARY_USER_ID) + underTest.setInitialOrUpgradeLargeTiles( + TilesUpgradePath.ReadFromSettings(tiles.toTileSpecs()), + PRIMARY_USER_ID, + ) assertThat(largeTiles).isEqualTo(tiles.toTileSpecs()) } } @Test - fun setInitialTiles_afterDefaultRead_largeTilesSetOnRepository_initialTilesCorrect() = + fun setUpgradePath_afterDefaultRead_largeTilesSetOnRepository_initialTilesCorrect() = with(kosmos) { testScope.runTest { val largeTiles by collectLastValue(underTest.largeTilesSpecs) @@ -204,15 +220,80 @@ class QSPreferencesRepositoryTest : SysuiTestCase() { assertThat(currentLargeTiles).isNotEmpty() - underTest.setLargeTilesSpecs(setOf(TileSpec.create("tileC"))) + underTest.writeLargeTileSpecs(setOf(TileSpec.create("tileC"))) val tiles = setOf("tileA", "tileB") - underTest.setInitialLargeTilesSpecs(tiles.toTileSpecs(), PRIMARY_USER_ID) + underTest.setInitialOrUpgradeLargeTiles( + TilesUpgradePath.ReadFromSettings(tiles.toTileSpecs()), + PRIMARY_USER_ID, + ) assertThat(largeTiles).isEqualTo(setOf(TileSpec.create("tileC"))) } } + @Test + fun setTilesRestored_noLargeTiles_tilesSet() = + with(kosmos) { + testScope.runTest { + val largeTiles by collectLastValue(underTest.largeTilesSpecs) + + fakeUserRepository.setUserInfos(USERS) + fakeUserRepository.setSelectedUserInfo(PRIMARY_USER) + val tiles = setOf("tileA", "tileB").toTileSpecs() + + assertThat(getSharedPreferences().contains(LARGE_TILES_SPECS_KEY)).isFalse() + + underTest.setInitialOrUpgradeLargeTiles( + TilesUpgradePath.RestoreFromBackup(tiles), + PRIMARY_USER_ID, + ) + + assertThat(largeTiles).isEqualTo(tiles) + } + } + + @Test + fun setDefaultTilesInitial_defaultSetLarge() = + with(kosmos) { + testScope.runTest { + val largeTiles by collectLastValue(underTest.largeTilesSpecs) + + fakeUserRepository.setUserInfos(USERS) + fakeUserRepository.setSelectedUserInfo(PRIMARY_USER) + + underTest.setInitialOrUpgradeLargeTiles( + TilesUpgradePath.DefaultSet, + PRIMARY_USER_ID, + ) + + assertThat(largeTiles).isEqualTo(defaultLargeTilesRepository.defaultLargeTiles) + } + } + + @Test + fun setTilesRestored_afterDefaultSet_tilesSet() = + with(kosmos) { + testScope.runTest { + underTest.setInitialOrUpgradeLargeTiles( + TilesUpgradePath.DefaultSet, + PRIMARY_USER_ID, + ) + val largeTiles by collectLastValue(underTest.largeTilesSpecs) + + fakeUserRepository.setUserInfos(USERS) + fakeUserRepository.setSelectedUserInfo(PRIMARY_USER) + val tiles = setOf("tileA", "tileB").toTileSpecs() + + underTest.setInitialOrUpgradeLargeTiles( + TilesUpgradePath.RestoreFromBackup(tiles), + PRIMARY_USER_ID, + ) + + assertThat(largeTiles).isEqualTo(tiles) + } + } + private fun getSharedPreferences(): SharedPreferences = with(kosmos) { return userFileManager.getSharedPreferences( diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/LargeTilesUpgradePathsTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/LargeTilesUpgradePathsTest.kt new file mode 100644 index 000000000000..f3c1f0c9dba8 --- /dev/null +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/LargeTilesUpgradePathsTest.kt @@ -0,0 +1,328 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.qs.panels.domain + +import android.content.Context +import android.content.Intent +import android.content.SharedPreferences +import android.content.res.mainResources +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.SmallTest +import com.android.systemui.SysuiTestCase +import com.android.systemui.backup.BackupHelper.Companion.ACTION_RESTORE_FINISHED +import com.android.systemui.broadcast.broadcastDispatcher +import com.android.systemui.common.shared.model.PackageChangeModel.Empty.packageName +import com.android.systemui.kosmos.Kosmos +import com.android.systemui.kosmos.collectLastValue +import com.android.systemui.kosmos.runTest +import com.android.systemui.qs.panels.data.repository.QSPreferencesRepository +import com.android.systemui.qs.panels.data.repository.defaultLargeTilesRepository +import com.android.systemui.qs.panels.domain.interactor.qsPreferencesInteractor +import com.android.systemui.qs.pipeline.data.repository.DefaultTilesQSHostRepository +import com.android.systemui.qs.pipeline.data.repository.defaultTilesRepository +import com.android.systemui.qs.pipeline.shared.TileSpec +import com.android.systemui.qs.pipeline.shared.TilesUpgradePath +import com.android.systemui.settings.userFileManager +import com.android.systemui.testKosmos +import com.android.systemui.user.data.repository.userRepository +import com.google.common.truth.Truth.assertThat +import kotlin.test.Test +import org.junit.runner.RunWith + +@SmallTest +@RunWith(AndroidJUnit4::class) +class LargeTilesUpgradePathsTest : SysuiTestCase() { + + private val kosmos = + testKosmos().apply { defaultTilesRepository = DefaultTilesQSHostRepository(mainResources) } + + private val defaultTiles = kosmos.defaultTilesRepository.defaultTiles.toSet() + + private val underTest = kosmos.qsPreferencesInteractor + + private val Kosmos.userId + get() = userRepository.getSelectedUserInfo().id + + private val Kosmos.intent + get() = + Intent(ACTION_RESTORE_FINISHED).apply { + `package` = packageName + putExtra(Intent.EXTRA_USER_ID, kosmos.userId) + flags = Intent.FLAG_RECEIVER_REGISTERED_ONLY + } + + /** + * This test corresponds to the case of a fresh start. + * + * The resulting large tiles are the default set of large tiles. + */ + @Test + fun defaultTiles_noDataInSharedPreferences_defaultLargeTiles() = + kosmos.runTest { + val largeTiles by collectLastValue(underTest.largeTilesSpecs) + + underTest.setInitialOrUpgradeLargeTilesSpecs(TilesUpgradePath.DefaultSet, userId) + + assertThat(largeTiles).isEqualTo(defaultLargeTilesRepository.defaultLargeTiles) + } + + /** + * This test corresponds to a user that upgraded in place from a build that didn't support large + * tiles to one that does. The current tiles of the user are read from settings. + * + * The resulting large tiles are those that were read from Settings. + */ + @Test + fun upgradeInPlace_noDataInSharedPreferences_allLargeTiles() = + kosmos.runTest { + val largeTiles by collectLastValue(underTest.largeTilesSpecs) + val tiles = setOf("a", "b", "c").toTileSpecs() + + underTest.setInitialOrUpgradeLargeTilesSpecs( + TilesUpgradePath.ReadFromSettings(tiles), + userId, + ) + + assertThat(largeTiles).isEqualTo(tiles) + } + + /** + * This test corresponds to a fresh start, and then the user restarts the device, without ever + * having modified the set of large tiles. + * + * The resulting large tiles are the default large tiles that were set on the fresh start + */ + @Test + fun defaultSet_restartDevice_largeTilesDontChange() = + kosmos.runTest { + val largeTiles by collectLastValue(underTest.largeTilesSpecs) + + underTest.setInitialOrUpgradeLargeTilesSpecs(TilesUpgradePath.DefaultSet, userId) + + // User restarts the device, this will send a read from settings with the default + // set of tiles + + underTest.setInitialOrUpgradeLargeTilesSpecs( + TilesUpgradePath.ReadFromSettings(defaultTiles), + userId, + ) + + assertThat(largeTiles).isEqualTo(defaultLargeTilesRepository.defaultLargeTiles) + } + + /** + * This test corresponds to a fresh start, following the user changing the sizes of some tiles. + * After that, the user restarts the device. + * + * The resulting set of large tiles are those that the user determined before restarting the + * device. + */ + @Test + fun defaultSet_someSizeChanges_restart_correctSet() = + kosmos.runTest { + val largeTiles by collectLastValue(underTest.largeTilesSpecs) + underTest.setInitialOrUpgradeLargeTilesSpecs(TilesUpgradePath.DefaultSet, userId) + + underTest.setLargeTilesSpecs(largeTiles!! + setOf("a", "b").toTileSpecs()) + val largeTilesBeforeRestart = largeTiles!! + + // Restart + + underTest.setInitialOrUpgradeLargeTilesSpecs( + TilesUpgradePath.ReadFromSettings(defaultTiles), + userId, + ) + assertThat(largeTiles).isEqualTo(largeTilesBeforeRestart) + } + + /** + * This test corresponds to a user that upgraded, and after that performed some size changes. + * After that, the user restarts the device. + * + * The resulting set of large tiles are those that the user determined before restarting the + * device. + */ + @Test + fun readFromSettings_changeSizes_restart_newLargeSet() = + kosmos.runTest { + val largeTiles by collectLastValue(underTest.largeTilesSpecs) + val readTiles = setOf("a", "b", "c").toTileSpecs() + + underTest.setInitialOrUpgradeLargeTilesSpecs( + TilesUpgradePath.ReadFromSettings(readTiles), + userId, + ) + underTest.setLargeTilesSpecs(emptySet()) + + assertThat(largeTiles).isEmpty() + + // Restart + underTest.setInitialOrUpgradeLargeTilesSpecs( + TilesUpgradePath.ReadFromSettings(readTiles), + userId, + ) + assertThat(largeTiles).isEmpty() + } + + /** + * This test corresponds to a user that upgraded from a build that didn't support tile sizes to + * one that does, via restore from backup. Note that there's no file in SharedPreferences to + * restore. + * + * The resulting set of large tiles are those that were restored from the backup. + */ + @Test + fun restoreFromBackup_noDataInSharedPreferences_allLargeTiles() = + kosmos.runTest { + val largeTiles by collectLastValue(underTest.largeTilesSpecs) + val tiles = setOf("a", "b", "c").toTileSpecs() + + underTest.setInitialOrUpgradeLargeTilesSpecs( + TilesUpgradePath.RestoreFromBackup(tiles), + userId, + ) + + assertThat(largeTiles).isEqualTo(tiles) + } + + /** + * This test corresponds to a user that upgraded from a build that didn't support tile sizes to + * one that does, via restore from backup. However, the restore happens after SystemUI's + * initialization has set the tiles to default. Note that there's no file in SharedPreferences + * to restore. + * + * The resulting set of large tiles are those that were restored from the backup. + */ + @Test + fun restoreFromBackup_afterDefault_noDataInSharedPreferences_allLargeTiles() = + kosmos.runTest { + val largeTiles by collectLastValue(underTest.largeTilesSpecs) + underTest.setInitialOrUpgradeLargeTilesSpecs(TilesUpgradePath.DefaultSet, userId) + + val tiles = setOf("a", "b", "c").toTileSpecs() + + underTest.setInitialOrUpgradeLargeTilesSpecs( + TilesUpgradePath.RestoreFromBackup(tiles), + userId, + ) + + assertThat(largeTiles).isEqualTo(tiles) + } + + /** + * This test corresponds to a user that restored from a build that supported different sizes + * tiles. First the list of tiles is restored in Settings and then a file containing some large + * tiles overrides the current shared preferences file + * + * The resulting set of large tiles are those that were restored from the shared preferences + * backup (and not the full list). + */ + @Test + fun restoreFromBackup_thenRestoreOfSharedPrefs_sharedPrefsAreLarge() = + kosmos.runTest { + val largeTiles by collectLastValue(underTest.largeTilesSpecs) + val tiles = setOf("a", "b", "c").toTileSpecs() + underTest.setInitialOrUpgradeLargeTilesSpecs( + TilesUpgradePath.RestoreFromBackup(tiles), + userId, + ) + + val tilesFromBackupOfSharedPrefs = setOf("a") + setLargeTilesSpecsInSharedPreferences(tilesFromBackupOfSharedPrefs) + broadcastDispatcher.sendIntentToMatchingReceiversOnly(context, intent) + + assertThat(largeTiles).isEqualTo(tilesFromBackupOfSharedPrefs.toTileSpecs()) + } + + /** + * This test corresponds to a user that restored from a build that supported different sizes + * tiles. However, this restore of settings happened after SystemUI's restore of the SharedPrefs + * containing the user's previous selections to large/small tiles. + * + * The resulting set of large tiles are those that were restored from the shared preferences + * backup (and not the full list). + */ + @Test + fun restoreFromBackup_afterRestoreOfSharedPrefs_sharedPrefsAreLarge() = + kosmos.runTest { + val largeTiles by collectLastValue(underTest.largeTilesSpecs) + val tiles = setOf("a", "b", "c").toTileSpecs() + val tilesFromBackupOfSharedPrefs = setOf("a") + + setLargeTilesSpecsInSharedPreferences(tilesFromBackupOfSharedPrefs) + broadcastDispatcher.sendIntentToMatchingReceiversOnly(context, intent) + + underTest.setInitialOrUpgradeLargeTilesSpecs( + TilesUpgradePath.RestoreFromBackup(tiles), + userId, + ) + + assertThat(largeTiles).isEqualTo(tilesFromBackupOfSharedPrefs.toTileSpecs()) + } + + /** + * This test corresponds to a user that upgraded from a build that didn't support tile sizes to + * one that does, via restore from backup. After that, the user modifies the size of some tiles + * and then restarts the device. + * + * The resulting set of large tiles are those after the user modifications. + */ + @Test + fun restoreFromBackup_changeSizes_restart_newLargeSet() = + kosmos.runTest { + val largeTiles by collectLastValue(underTest.largeTilesSpecs) + val readTiles = setOf("a", "b", "c").toTileSpecs() + + underTest.setInitialOrUpgradeLargeTilesSpecs( + TilesUpgradePath.RestoreFromBackup(readTiles), + userId, + ) + underTest.setLargeTilesSpecs(emptySet()) + + assertThat(largeTiles).isEmpty() + + // Restart + underTest.setInitialOrUpgradeLargeTilesSpecs( + TilesUpgradePath.ReadFromSettings(readTiles), + userId, + ) + assertThat(largeTiles).isEmpty() + } + + private companion object { + private const val LARGE_TILES_SPECS_KEY = "large_tiles_specs" + + private fun Kosmos.getSharedPreferences(): SharedPreferences = + userFileManager.getSharedPreferences( + QSPreferencesRepository.FILE_NAME, + Context.MODE_PRIVATE, + userRepository.getSelectedUserInfo().id, + ) + + private fun Kosmos.setLargeTilesSpecsInSharedPreferences(specs: Set<String>) { + getSharedPreferences().edit().putStringSet(LARGE_TILES_SPECS_KEY, specs).apply() + } + + private fun Kosmos.getLargeTilesSpecsFromSharedPreferences(): Set<String> { + return getSharedPreferences().getStringSet(LARGE_TILES_SPECS_KEY, emptySet())!! + } + + private fun Set<String>.toTileSpecs(): Set<TileSpec> { + return map { TileSpec.create(it) }.toSet() + } + } +} diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/IconTilesInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/IconTilesInteractorTest.kt index 79acfdaa415b..9838bcb86684 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/IconTilesInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/IconTilesInteractorTest.kt @@ -66,7 +66,7 @@ class IconTilesInteractorTest : SysuiTestCase() { runCurrent() // Resize it to large - qsPreferencesRepository.setLargeTilesSpecs(setOf(spec)) + qsPreferencesRepository.writeLargeTileSpecs(setOf(spec)) runCurrent() // Assert that the new tile was added to the large tiles set diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/data/repository/TileSpecSettingsRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/data/repository/TileSpecSettingsRepositoryTest.kt index 4b8cd3742bff..d9b3926fa215 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/data/repository/TileSpecSettingsRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/data/repository/TileSpecSettingsRepositoryTest.kt @@ -24,6 +24,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectValues import com.android.systemui.qs.pipeline.shared.TileSpec +import com.android.systemui.qs.pipeline.shared.TilesUpgradePath import com.android.systemui.qs.pipeline.shared.logging.QSPipelineLogger import com.android.systemui.res.R import com.android.systemui.retail.data.repository.FakeRetailModeRepository @@ -242,9 +243,12 @@ class TileSpecSettingsRepositoryTest : SysuiTestCase() { storeTilesForUser(startingTiles, userId) val tiles by collectLastValue(underTest.tilesSpecs(userId)) - val tilesRead by collectLastValue(underTest.tilesReadFromSetting.consumeAsFlow()) + val tilesRead by collectLastValue(underTest.tilesUpgradePath.consumeAsFlow()) - assertThat(tilesRead).isEqualTo(startingTiles.toTileSpecs().toSet() to userId) + assertThat(tilesRead) + .isEqualTo( + TilesUpgradePath.ReadFromSettings(startingTiles.toTileSpecs().toSet()) to userId + ) } @Test @@ -258,13 +262,13 @@ class TileSpecSettingsRepositoryTest : SysuiTestCase() { val tiles10 by collectLastValue(underTest.tilesSpecs(10)) val tiles11 by collectLastValue(underTest.tilesSpecs(11)) - val tilesRead by collectValues(underTest.tilesReadFromSetting.consumeAsFlow()) + val tilesRead by collectValues(underTest.tilesUpgradePath.consumeAsFlow()) assertThat(tilesRead).hasSize(2) assertThat(tilesRead) .containsExactly( - startingTiles10.toTileSpecs().toSet() to 10, - startingTiles11.toTileSpecs().toSet() to 11, + TilesUpgradePath.ReadFromSettings(startingTiles10.toTileSpecs().toSet()) to 10, + TilesUpgradePath.ReadFromSettings(startingTiles11.toTileSpecs().toSet()) to 11, ) } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepositoryTest.kt index 1945f750efaf..29bd18d3f3a0 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepositoryTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepositoryTest.kt @@ -7,8 +7,8 @@ import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.coroutines.collectLastValue import com.android.systemui.qs.pipeline.data.model.RestoreData -import com.android.systemui.qs.pipeline.data.repository.UserTileSpecRepositoryTest.Companion.toTilesSet import com.android.systemui.qs.pipeline.shared.TileSpec +import com.android.systemui.qs.pipeline.shared.TilesUpgradePath import com.android.systemui.qs.pipeline.shared.logging.QSPipelineLogger import com.android.systemui.util.settings.FakeSettings import com.google.common.truth.Truth.assertThat @@ -352,11 +352,11 @@ class UserTileSpecRepositoryTest : SysuiTestCase() { @Test fun noSettingsStored_noTilesReadFromSettings() = testScope.runTest { - val tilesRead by collectLastValue(underTest.tilesReadFromSettings.consumeAsFlow()) + val tilesRead by collectLastValue(underTest.tilesUpgradePath.consumeAsFlow()) val tiles by collectLastValue(underTest.tiles()) assertThat(tiles).isEqualTo(getDefaultTileSpecs()) - assertThat(tilesRead).isEqualTo(null) + assertThat(tilesRead).isEqualTo(TilesUpgradePath.DefaultSet) } @Test @@ -365,19 +365,20 @@ class UserTileSpecRepositoryTest : SysuiTestCase() { val storedTiles = "a,b" storeTiles(storedTiles) val tiles by collectLastValue(underTest.tiles()) - val tilesRead by collectLastValue(underTest.tilesReadFromSettings.consumeAsFlow()) + val tilesRead by collectLastValue(underTest.tilesUpgradePath.consumeAsFlow()) - assertThat(tilesRead).isEqualTo(storedTiles.toTilesSet()) + assertThat(tilesRead) + .isEqualTo(TilesUpgradePath.ReadFromSettings(storedTiles.toTilesSet())) } @Test fun noSettingsStored_tilesChanged_tilesReadFromSettingsNotChanged() = testScope.runTest { - val tilesRead by collectLastValue(underTest.tilesReadFromSettings.consumeAsFlow()) + val tilesRead by collectLastValue(underTest.tilesUpgradePath.consumeAsFlow()) val tiles by collectLastValue(underTest.tiles()) underTest.addTile(TileSpec.create("a")) - assertThat(tilesRead).isEqualTo(null) + assertThat(tilesRead).isEqualTo(TilesUpgradePath.DefaultSet) } @Test @@ -386,10 +387,34 @@ class UserTileSpecRepositoryTest : SysuiTestCase() { val storedTiles = "a,b" storeTiles(storedTiles) val tiles by collectLastValue(underTest.tiles()) - val tilesRead by collectLastValue(underTest.tilesReadFromSettings.consumeAsFlow()) + val tilesRead by collectLastValue(underTest.tilesUpgradePath.consumeAsFlow()) underTest.addTile(TileSpec.create("c")) - assertThat(tilesRead).isEqualTo(storedTiles.toTilesSet()) + assertThat(tilesRead) + .isEqualTo(TilesUpgradePath.ReadFromSettings(storedTiles.toTilesSet())) + } + + @Test + fun tilesRestoredFromBackup() = + testScope.runTest { + val specsBeforeRestore = "a,b,c,d,e" + val restoredSpecs = "a,c,d,f" + val autoAddedBeforeRestore = "b,d" + val restoredAutoAdded = "d,e" + + storeTiles(specsBeforeRestore) + val tiles by collectLastValue(underTest.tiles()) + val tilesRead by collectLastValue(underTest.tilesUpgradePath.consumeAsFlow()) + runCurrent() + + val restoreData = + RestoreData(restoredSpecs.toTileSpecs(), restoredAutoAdded.toTilesSet(), USER) + underTest.reconcileRestore(restoreData, autoAddedBeforeRestore.toTilesSet()) + runCurrent() + + val expected = "a,b,c,d,f" + assertThat(tilesRead) + .isEqualTo(TilesUpgradePath.RestoreFromBackup(expected.toTilesSet())) } private fun getDefaultTileSpecs(): List<TileSpec> { diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/QSPreferencesRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/QSPreferencesRepository.kt index 16dff7d11002..11b014c2147f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/QSPreferencesRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/QSPreferencesRepository.kt @@ -28,6 +28,7 @@ import com.android.systemui.log.LogBuffer import com.android.systemui.log.core.Logger import com.android.systemui.qs.panels.shared.model.PanelsLog import com.android.systemui.qs.pipeline.shared.TileSpec +import com.android.systemui.qs.pipeline.shared.TilesUpgradePath import com.android.systemui.settings.UserFileManager import com.android.systemui.user.data.repository.UserRepository import com.android.systemui.util.kotlin.SharedPreferencesExt.observe @@ -83,34 +84,78 @@ constructor( .flowOn(backgroundDispatcher) /** Sets for the current user the set of [TileSpec] to display as large tiles. */ - fun setLargeTilesSpecs(specs: Set<TileSpec>) { - setLargeTilesSpecsForUser(specs, userRepository.getSelectedUserInfo().id) + fun writeLargeTileSpecs(specs: Set<TileSpec>) { + with(getSharedPrefs(userRepository.getSelectedUserInfo().id)) { + writeLargeTileSpecs(specs) + setLargeTilesDefault(false) + } } - private fun setLargeTilesSpecsForUser(specs: Set<TileSpec>, userId: Int) { - with(getSharedPrefs(userId)) { - edit().putStringSet(LARGE_TILES_SPECS_KEY, specs.map { it.spec }.toSet()).apply() + suspend fun deleteLargeTileDataJob() { + userRepository.selectedUserInfo.collect { userInfo -> + getSharedPrefs(userInfo.id) + .edit() + .remove(LARGE_TILES_SPECS_KEY) + .remove(LARGE_TILES_DEFAULT_KEY) + .apply() } } + private fun SharedPreferences.writeLargeTileSpecs(specs: Set<TileSpec>) { + edit().putStringSet(LARGE_TILES_SPECS_KEY, specs.map { it.spec }.toSet()).apply() + } + /** - * Sets the initial tiles as large, if there is no set in SharedPrefs for the [userId]. This is - * to be used when upgrading to a build that supports large/small tiles. + * Sets the initial set of large tiles. One of the following cases will happen: + * * If we are setting the default set (no value stored in settings for the list of tiles), set + * the large tiles based on [defaultLargeTilesRepository]. We do this to signal future reboots + * that we have performed the upgrade path once. In this case, we will mark that we set them + * as the default in case a restore needs to modify them later. + * * If we got a list of tiles restored from a device and nothing has modified the list of + * tiles, set all the restored tiles to large. Note that if we also restored a set of large + * tiles before this was called, [LARGE_TILES_DEFAULT_KEY] will be false and we won't + * overwrite it. + * * If we got a list of tiles from settings, we consider that we upgraded in place and then we + * will set all those tiles to large IF there's no current set of large tiles. * * Even if largeTilesSpec is read Eagerly before we know if we are in an initial state, because * we are not writing the default values to the SharedPreferences, the file will not contain the * key and this call will succeed, as long as there hasn't been any calls to setLargeTilesSpecs * for that user before. */ - fun setInitialLargeTilesSpecs(specs: Set<TileSpec>, userId: Int) { + fun setInitialOrUpgradeLargeTiles(upgradePath: TilesUpgradePath, userId: Int) { with(getSharedPrefs(userId)) { - if (!contains(LARGE_TILES_SPECS_KEY)) { - logger.i("Setting upgraded large tiles for user $userId: $specs") - setLargeTilesSpecsForUser(specs, userId) + when (upgradePath) { + is TilesUpgradePath.DefaultSet -> { + writeLargeTileSpecs(defaultLargeTilesRepository.defaultLargeTiles) + logger.i("Large tiles set to default on init") + setLargeTilesDefault(true) + } + is TilesUpgradePath.RestoreFromBackup -> { + if ( + getBoolean(LARGE_TILES_DEFAULT_KEY, false) || + !contains(LARGE_TILES_SPECS_KEY) + ) { + writeLargeTileSpecs(upgradePath.value) + logger.i("Tiles restored from backup set to large: ${upgradePath.value}") + setLargeTilesDefault(false) + } + } + is TilesUpgradePath.ReadFromSettings -> { + if (!contains(LARGE_TILES_SPECS_KEY)) { + writeLargeTileSpecs(upgradePath.value) + logger.i("Tiles read from settings set to large: ${upgradePath.value}") + setLargeTilesDefault(false) + } + } } } } + private fun SharedPreferences.setLargeTilesDefault(value: Boolean) { + edit().putBoolean(LARGE_TILES_DEFAULT_KEY, value).apply() + } + private fun getSharedPrefs(userId: Int): SharedPreferences { return userFileManager.getSharedPreferences(FILE_NAME, Context.MODE_PRIVATE, userId) } @@ -118,6 +163,7 @@ constructor( companion object { private const val TAG = "QSPreferencesRepository" private const val LARGE_TILES_SPECS_KEY = "large_tiles_specs" + private const val LARGE_TILES_DEFAULT_KEY = "large_tiles_default" const val FILE_NAME = "quick_settings_prefs" } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/QSPreferencesInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/QSPreferencesInteractor.kt index 86838b438bc6..9b98797ef393 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/QSPreferencesInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/QSPreferencesInteractor.kt @@ -19,6 +19,7 @@ package com.android.systemui.qs.panels.domain.interactor import com.android.systemui.dagger.SysUISingleton import com.android.systemui.qs.panels.data.repository.QSPreferencesRepository import com.android.systemui.qs.pipeline.shared.TileSpec +import com.android.systemui.qs.pipeline.shared.TilesUpgradePath import javax.inject.Inject import kotlinx.coroutines.flow.Flow @@ -27,10 +28,20 @@ class QSPreferencesInteractor @Inject constructor(private val repo: QSPreference val largeTilesSpecs: Flow<Set<TileSpec>> = repo.largeTilesSpecs fun setLargeTilesSpecs(specs: Set<TileSpec>) { - repo.setLargeTilesSpecs(specs) + repo.writeLargeTileSpecs(specs) } - fun setInitialLargeTilesSpecs(specs: Set<TileSpec>, user: Int) { - repo.setInitialLargeTilesSpecs(specs, user) + /** + * This method should be called to indicate that a "new" set of tiles has been determined for a + * particular user coming from different upgrade sources. + * + * @see TilesUpgradePath for more information + */ + fun setInitialOrUpgradeLargeTilesSpecs(specs: TilesUpgradePath, user: Int) { + repo.setInitialOrUpgradeLargeTiles(specs, user) + } + + suspend fun deleteLargeTilesDataJob() { + repo.deleteLargeTileDataJob() } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/domain/startable/QSPanelsCoreStartable.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/domain/startable/QSPanelsCoreStartable.kt index a8ac5c34d8f9..e2797356fa96 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/panels/domain/startable/QSPanelsCoreStartable.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/panels/domain/startable/QSPanelsCoreStartable.kt @@ -19,11 +19,13 @@ package com.android.systemui.qs.panels.domain.startable import com.android.app.tracing.coroutines.launchTraced import com.android.systemui.CoreStartable import com.android.systemui.dagger.qualifiers.Background +import com.android.systemui.qs.flags.QsInCompose import com.android.systemui.qs.panels.domain.interactor.QSPreferencesInteractor import com.android.systemui.qs.pipeline.data.repository.TileSpecRepository import javax.inject.Inject import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.flow.receiveAsFlow +import kotlinx.coroutines.launch class QSPanelsCoreStartable @Inject @@ -33,10 +35,14 @@ constructor( @Background private val backgroundApplicationScope: CoroutineScope, ) : CoreStartable { override fun start() { - backgroundApplicationScope.launchTraced("QSPanelsCoreStartable.startingLargeTiles") { - tileSpecRepository.tilesReadFromSetting.receiveAsFlow().collect { (tiles, userId) -> - preferenceInteractor.setInitialLargeTilesSpecs(tiles, userId) + if (QsInCompose.isEnabled) { + backgroundApplicationScope.launchTraced("QSPanelsCoreStartable.startingLargeTiles") { + tileSpecRepository.tilesUpgradePath.receiveAsFlow().collect { (tiles, userId) -> + preferenceInteractor.setInitialOrUpgradeLargeTilesSpecs(tiles, userId) + } } + } else { + backgroundApplicationScope.launch { preferenceInteractor.deleteLargeTilesDataJob() } } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/TileSpecRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/TileSpecRepository.kt index 6b7dd386bb46..c50d5dad10c1 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/TileSpecRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/TileSpecRepository.kt @@ -24,6 +24,7 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.qs.pipeline.data.model.RestoreData import com.android.systemui.qs.pipeline.shared.TileSpec +import com.android.systemui.qs.pipeline.shared.TilesUpgradePath import com.android.systemui.qs.pipeline.shared.logging.QSPipelineLogger import com.android.systemui.res.R import com.android.systemui.retail.data.repository.RetailModeRepository @@ -78,7 +79,7 @@ interface TileSpecRepository { /** Reset the current set of tiles to the default list of tiles */ suspend fun resetToDefault(userId: Int) - val tilesReadFromSetting: ReceiveChannel<Pair<Set<TileSpec>, Int>> + val tilesUpgradePath: ReceiveChannel<Pair<TilesUpgradePath, Int>> companion object { /** Position to indicate the end of the list */ @@ -112,8 +113,8 @@ constructor( .filter { it !is TileSpec.Invalid } } - private val _tilesReadFromSetting = Channel<Pair<Set<TileSpec>, Int>>(capacity = 5) - override val tilesReadFromSetting = _tilesReadFromSetting + private val _tilesUpgradePath = Channel<Pair<TilesUpgradePath, Int>>(capacity = 5) + override val tilesUpgradePath = _tilesUpgradePath private val userTileRepositories = SparseArray<UserTileSpecRepository>() @@ -122,8 +123,8 @@ constructor( val userTileRepository = userTileSpecRepositoryFactory.create(userId) userTileRepositories.put(userId, userTileRepository) applicationScope.launchTraced("TileSpecRepository.aggregateTilesPerUser") { - for (tilesFromSettings in userTileRepository.tilesReadFromSettings) { - _tilesReadFromSetting.send(tilesFromSettings to userId) + for (tileUpgrade in userTileRepository.tilesUpgradePath) { + _tilesUpgradePath.send(tileUpgrade to userId) } } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepository.kt index 7b56cd92a081..5aa5edaa726e 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/qs/pipeline/data/repository/UserTileSpecRepository.kt @@ -9,6 +9,7 @@ import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Background import com.android.systemui.qs.pipeline.data.model.RestoreData import com.android.systemui.qs.pipeline.shared.TileSpec +import com.android.systemui.qs.pipeline.shared.TilesUpgradePath import com.android.systemui.qs.pipeline.shared.logging.QSPipelineLogger import com.android.systemui.util.settings.SecureSettings import dagger.assisted.Assisted @@ -49,8 +50,8 @@ constructor( @Background private val backgroundDispatcher: CoroutineDispatcher, ) { - private val _tilesReadFromSettings = Channel<Set<TileSpec>>(capacity = 2) - val tilesReadFromSettings: ReceiveChannel<Set<TileSpec>> = _tilesReadFromSettings + private val _tilesUpgradePath = Channel<TilesUpgradePath>(capacity = 3) + val tilesUpgradePath: ReceiveChannel<TilesUpgradePath> = _tilesUpgradePath private val defaultTiles: List<TileSpec> get() = defaultTilesRepository.defaultTiles @@ -67,14 +68,23 @@ constructor( .scan(loadTilesFromSettingsAndParse(userId)) { current, change -> change .apply(current) - .also { - if (current != it) { + .also { afterRestore -> + if (current != afterRestore) { if (change is RestoreTiles) { - logger.logTilesRestoredAndReconciled(current, it, userId) + logger.logTilesRestoredAndReconciled( + current, + afterRestore, + userId, + ) } else { - logger.logProcessTileChange(change, it, userId) + logger.logProcessTileChange(change, afterRestore, userId) } } + if (change is RestoreTiles) { + _tilesUpgradePath.send( + TilesUpgradePath.RestoreFromBackup(afterRestore.toSet()) + ) + } } // Distinct preserves the order of the elements removing later // duplicates, @@ -154,7 +164,9 @@ constructor( private suspend fun loadTilesFromSettingsAndParse(userId: Int): List<TileSpec> { val loadedTiles = loadTilesFromSettings(userId) if (loadedTiles.isNotEmpty()) { - _tilesReadFromSettings.send(loadedTiles.toSet()) + _tilesUpgradePath.send(TilesUpgradePath.ReadFromSettings(loadedTiles.toSet())) + } else { + _tilesUpgradePath.send(TilesUpgradePath.DefaultSet) } return parseTileSpecs(loadedTiles, userId) } diff --git a/packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/TilesUpgradePath.kt b/packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/TilesUpgradePath.kt new file mode 100644 index 000000000000..98f30c22d0f3 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/qs/pipeline/shared/TilesUpgradePath.kt @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.qs.pipeline.shared + +/** Upgrade paths indicating the source of the list of QS tiles. */ +sealed interface TilesUpgradePath { + + sealed interface UpgradeWithTiles : TilesUpgradePath { + val value: Set<TileSpec> + } + + /** This indicates a set of tiles that was read from Settings on user start */ + @JvmInline value class ReadFromSettings(override val value: Set<TileSpec>) : UpgradeWithTiles + + /** This indicates a set of tiles that was restored from backup */ + @JvmInline value class RestoreFromBackup(override val value: Set<TileSpec>) : UpgradeWithTiles + + /** + * This indicates that no tiles were read from Settings on user start so the default has been + * stored. + */ + data object DefaultSet : TilesUpgradePath +} diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/pipeline/data/repository/FakeTileSpecRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/pipeline/data/repository/FakeTileSpecRepository.kt index 5fc31f8b9e10..f2871149de11 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/pipeline/data/repository/FakeTileSpecRepository.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/pipeline/data/repository/FakeTileSpecRepository.kt @@ -19,6 +19,7 @@ package com.android.systemui.qs.pipeline.data.repository import com.android.systemui.qs.pipeline.data.model.RestoreData import com.android.systemui.qs.pipeline.data.repository.TileSpecRepository.Companion.POSITION_AT_END import com.android.systemui.qs.pipeline.shared.TileSpec +import com.android.systemui.qs.pipeline.shared.TilesUpgradePath import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -79,9 +80,9 @@ class FakeTileSpecRepository( with(getFlow(userId)) { value = defaultTilesRepository.defaultTiles } } - override val tilesReadFromSetting: Channel<Pair<Set<TileSpec>, Int>> = Channel(capacity = 10) + override val tilesUpgradePath: Channel<Pair<TilesUpgradePath, Int>> = Channel(capacity = 10) - suspend fun sendTilesReadFromSetting(tiles: Set<TileSpec>, userId: Int) { - tilesReadFromSetting.send(tiles to userId) + suspend fun sendTilesFromUpgradePath(upgradePath: TilesUpgradePath, userId: Int) { + tilesUpgradePath.send(upgradePath to userId) } } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/pipeline/data/repository/QSPipelineRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/pipeline/data/repository/QSPipelineRepositoryKosmos.kt index 5ff44e5d33c5..c5de02a7281b 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/pipeline/data/repository/QSPipelineRepositoryKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/pipeline/data/repository/QSPipelineRepositoryKosmos.kt @@ -26,7 +26,7 @@ val Kosmos.minimumTilesRepository: MinimumTilesRepository by Kosmos.Fixture { fakeMinimumTilesRepository } var Kosmos.fakeDefaultTilesRepository by Kosmos.Fixture { FakeDefaultTilesRepository() } -val Kosmos.defaultTilesRepository: DefaultTilesRepository by +var Kosmos.defaultTilesRepository: DefaultTilesRepository by Kosmos.Fixture { fakeDefaultTilesRepository } val Kosmos.fakeTileSpecRepository by |