diff options
| author | 2025-03-07 07:18:58 -0800 | |
|---|---|---|
| committer | 2025-03-07 07:18:58 -0800 | |
| commit | d9feda3a6f38dd88e42e34bf8fc2dc6e5db92ece (patch) | |
| tree | efca03f6ce9c6785d17e0d67c17075f1106938fe | |
| parent | 992e084da249ee64458c745acd2a9dd8847a7b8a (diff) | |
| parent | 0b7c46b168e981bd74757414a9cf03f04dca0664 (diff) | |
Merge "Add int methods to SettingsForUserRepository" into main
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/util/settings/repository/SettingsForUserRepository.kt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/util/settings/repository/SettingsForUserRepository.kt b/packages/SystemUI/src/com/android/systemui/util/settings/repository/SettingsForUserRepository.kt index 94b3fd244a92..6cdc94251d21 100644 --- a/packages/SystemUI/src/com/android/systemui/util/settings/repository/SettingsForUserRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/util/settings/repository/SettingsForUserRepository.kt @@ -47,6 +47,11 @@ abstract class SettingsForUserRepository( .distinctUntilChanged() .flowOn(backgroundDispatcher) + fun intSettingForUser(userId: Int, name: String, defaultValue: Int = 0): Flow<Int> = + settingObserver(name, userId) { userSettings.getIntForUser(name, defaultValue, userId) } + .distinctUntilChanged() + .flowOn(backgroundDispatcher) + fun <T> settingObserver(name: String, userId: Int, settingsReader: () -> T): Flow<T> { return userSettings .observerFlow(userId, name) @@ -63,4 +68,14 @@ abstract class SettingsForUserRepository( userSettings.getBoolForUser(name, defaultValue, userId) } } + + suspend fun setIntForUser(userId: Int, name: String, value: Int) { + withContext(backgroundContext) { userSettings.putIntForUser(name, value, userId) } + } + + suspend fun getIntForUser(userId: Int, name: String, defaultValue: Int = 0): Int { + return withContext(backgroundContext) { + userSettings.getIntForUser(name, defaultValue, userId) + } + } } |