Loading packages/SystemUI/customization/src/com/android/systemui/shared/settings/data/repository/SecureSettingsRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ interface SecureSettingsRepository { /** Returns a [Flow] tracking the value of a setting as an [Int]. */ fun intSetting(name: String, defaultValue: Int = 0): Flow<Int> /** Returns a [Flow] tracking the value of a setting as a [Boolean]. */ fun boolSetting(name: String, defaultValue: Boolean = false): Flow<Boolean> /** Updates the value of the setting with the given name. */ suspend fun setInt(name: String, value: Int) Loading packages/SystemUI/customization/src/com/android/systemui/shared/settings/data/repository/SecureSettingsRepositoryImpl.kt +4 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,10 @@ class SecureSettingsRepositoryImpl( .flowOn(backgroundDispatcher) } override fun boolSetting(name: String, defaultValue: Boolean): Flow<Boolean> { return intSetting(name, if (defaultValue) 1 else 0).map { it != 0 } } override suspend fun setInt(name: String, value: Int) { withContext(backgroundDispatcher) { Settings.Secure.putInt(contentResolver, name, value) } } Loading packages/SystemUI/customization/src/com/android/systemui/shared/settings/data/repository/SystemSettingsRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ interface SystemSettingsRepository { /** Returns a [Flow] tracking the value of a setting as an [Int]. */ fun intSetting(name: String, defaultValue: Int = 0): Flow<Int> /** Returns a [Flow] tracking the value of a setting as a [Boolean]. */ fun boolSetting(name: String, defaultValue: Boolean = false): Flow<Boolean> /** Updates the value of the setting with the given name. */ suspend fun setInt(name: String, value: Int) Loading packages/SystemUI/customization/src/com/android/systemui/shared/settings/data/repository/SystemSettingsRepositoryImpl.kt +4 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,10 @@ class SystemSettingsRepositoryImpl( .flowOn(backgroundDispatcher) } override fun boolSetting(name: String, defaultValue: Boolean): Flow<Boolean> { return intSetting(name, if (defaultValue) 1 else 0).map { it != 0 } } override suspend fun setInt(name: String, value: Int) { withContext(backgroundDispatcher) { Settings.System.putInt(contentResolver, name, value) } } Loading packages/SystemUI/customization/tests/utils/src/com/android/systemui/shared/settings/data/repository/FakeSecureSettingsRepository.kt +4 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,10 @@ class FakeSecureSettingsRepository : SecureSettingsRepository { return settings.map { it.getOrDefault(name, defaultValue.toString()) }.map { it.toInt() } } override fun boolSetting(name: String, defaultValue: Boolean): Flow<Boolean> { return intSetting(name, if (defaultValue) 1 else 0).map { it != 0 } } override suspend fun setInt(name: String, value: Int) { settings.value = settings.value.toMutableMap().apply { this[name] = value.toString() } } Loading Loading
packages/SystemUI/customization/src/com/android/systemui/shared/settings/data/repository/SecureSettingsRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ interface SecureSettingsRepository { /** Returns a [Flow] tracking the value of a setting as an [Int]. */ fun intSetting(name: String, defaultValue: Int = 0): Flow<Int> /** Returns a [Flow] tracking the value of a setting as a [Boolean]. */ fun boolSetting(name: String, defaultValue: Boolean = false): Flow<Boolean> /** Updates the value of the setting with the given name. */ suspend fun setInt(name: String, value: Int) Loading
packages/SystemUI/customization/src/com/android/systemui/shared/settings/data/repository/SecureSettingsRepositoryImpl.kt +4 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,10 @@ class SecureSettingsRepositoryImpl( .flowOn(backgroundDispatcher) } override fun boolSetting(name: String, defaultValue: Boolean): Flow<Boolean> { return intSetting(name, if (defaultValue) 1 else 0).map { it != 0 } } override suspend fun setInt(name: String, value: Int) { withContext(backgroundDispatcher) { Settings.Secure.putInt(contentResolver, name, value) } } Loading
packages/SystemUI/customization/src/com/android/systemui/shared/settings/data/repository/SystemSettingsRepository.kt +3 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,9 @@ interface SystemSettingsRepository { /** Returns a [Flow] tracking the value of a setting as an [Int]. */ fun intSetting(name: String, defaultValue: Int = 0): Flow<Int> /** Returns a [Flow] tracking the value of a setting as a [Boolean]. */ fun boolSetting(name: String, defaultValue: Boolean = false): Flow<Boolean> /** Updates the value of the setting with the given name. */ suspend fun setInt(name: String, value: Int) Loading
packages/SystemUI/customization/src/com/android/systemui/shared/settings/data/repository/SystemSettingsRepositoryImpl.kt +4 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,10 @@ class SystemSettingsRepositoryImpl( .flowOn(backgroundDispatcher) } override fun boolSetting(name: String, defaultValue: Boolean): Flow<Boolean> { return intSetting(name, if (defaultValue) 1 else 0).map { it != 0 } } override suspend fun setInt(name: String, value: Int) { withContext(backgroundDispatcher) { Settings.System.putInt(contentResolver, name, value) } } Loading
packages/SystemUI/customization/tests/utils/src/com/android/systemui/shared/settings/data/repository/FakeSecureSettingsRepository.kt +4 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,10 @@ class FakeSecureSettingsRepository : SecureSettingsRepository { return settings.map { it.getOrDefault(name, defaultValue.toString()) }.map { it.toInt() } } override fun boolSetting(name: String, defaultValue: Boolean): Flow<Boolean> { return intSetting(name, if (defaultValue) 1 else 0).map { it != 0 } } override suspend fun setInt(name: String, value: Int) { settings.value = settings.value.toMutableMap().apply { this[name] = value.toString() } } Loading