summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/src/com/android/systemui/util/settings/repository/SettingsForUserRepository.kt15
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)
+ }
+ }
}