Loading packages/SystemUI/customization/src/com/android/systemui/shared/notifications/data/repository/NotificationSettingsRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ class NotificationSettingsRepository( suspend fun setShowNotificationsOnLockscreenEnabled(enabled: Boolean) { withContext(backgroundDispatcher) { secureSettingsRepository.set( secureSettingsRepository.setInt( name = Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, value = if (enabled) 1 else 0, ) Loading packages/SystemUI/customization/src/com/android/systemui/shared/settings/data/repository/SecureSettingsRepository.kt +15 −4 Original line number Diff line number Diff line Loading @@ -37,15 +37,17 @@ interface SecureSettingsRepository { ): Flow<Int> /** Updates the value of the setting with the given name. */ suspend fun set( suspend fun setInt( name: String, value: Int, ) suspend fun get( suspend fun getInt( name: String, defaultValue: Int = 0, ): Int suspend fun getString(name: String): String? } class SecureSettingsRepositoryImpl( Loading Loading @@ -80,7 +82,7 @@ class SecureSettingsRepositoryImpl( .flowOn(backgroundDispatcher) } override suspend fun set(name: String, value: Int) { override suspend fun setInt(name: String, value: Int) { withContext(backgroundDispatcher) { Settings.Secure.putInt( contentResolver, Loading @@ -90,7 +92,7 @@ class SecureSettingsRepositoryImpl( } } override suspend fun get(name: String, defaultValue: Int): Int { override suspend fun getInt(name: String, defaultValue: Int): Int { return withContext(backgroundDispatcher) { Settings.Secure.getInt( contentResolver, Loading @@ -99,4 +101,13 @@ class SecureSettingsRepositoryImpl( ) } } override suspend fun getString(name: String): String? { return withContext(backgroundDispatcher) { Settings.Secure.getString( contentResolver, name, ) } } } packages/SystemUI/customization/tests/utils/src/com/android/systemui/shared/settings/data/repository/FakeSecureSettingsRepository.kt +6 −2 Original line number Diff line number Diff line Loading @@ -28,11 +28,15 @@ class FakeSecureSettingsRepository : SecureSettingsRepository { return settings.map { it.getOrDefault(name, defaultValue.toString()) }.map { it.toInt() } } override suspend fun set(name: String, value: Int) { override suspend fun setInt(name: String, value: Int) { settings.value = settings.value.toMutableMap().apply { this[name] = value.toString() } } override suspend fun get(name: String, defaultValue: Int): Int { override suspend fun getInt(name: String, defaultValue: Int): Int { return settings.value[name]?.toInt() ?: defaultValue } override suspend fun getString(name: String): String? { return settings.value[name] } } packages/SystemUI/tests/src/com/android/systemui/shared/notifications/data/repository/NotificationSettingsRepositoryTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -58,13 +58,13 @@ class NotificationSettingsRepositoryTest : SysuiTestCase() { testScope.runTest { val showNotifs by collectLastValue(underTest.isShowNotificationsOnLockScreenEnabled) secureSettingsRepository.set( secureSettingsRepository.setInt( name = Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, value = 1, ) assertThat(showNotifs).isEqualTo(true) secureSettingsRepository.set( secureSettingsRepository.setInt( name = Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, value = 0, ) Loading Loading
packages/SystemUI/customization/src/com/android/systemui/shared/notifications/data/repository/NotificationSettingsRepository.kt +1 −1 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ class NotificationSettingsRepository( suspend fun setShowNotificationsOnLockscreenEnabled(enabled: Boolean) { withContext(backgroundDispatcher) { secureSettingsRepository.set( secureSettingsRepository.setInt( name = Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, value = if (enabled) 1 else 0, ) Loading
packages/SystemUI/customization/src/com/android/systemui/shared/settings/data/repository/SecureSettingsRepository.kt +15 −4 Original line number Diff line number Diff line Loading @@ -37,15 +37,17 @@ interface SecureSettingsRepository { ): Flow<Int> /** Updates the value of the setting with the given name. */ suspend fun set( suspend fun setInt( name: String, value: Int, ) suspend fun get( suspend fun getInt( name: String, defaultValue: Int = 0, ): Int suspend fun getString(name: String): String? } class SecureSettingsRepositoryImpl( Loading Loading @@ -80,7 +82,7 @@ class SecureSettingsRepositoryImpl( .flowOn(backgroundDispatcher) } override suspend fun set(name: String, value: Int) { override suspend fun setInt(name: String, value: Int) { withContext(backgroundDispatcher) { Settings.Secure.putInt( contentResolver, Loading @@ -90,7 +92,7 @@ class SecureSettingsRepositoryImpl( } } override suspend fun get(name: String, defaultValue: Int): Int { override suspend fun getInt(name: String, defaultValue: Int): Int { return withContext(backgroundDispatcher) { Settings.Secure.getInt( contentResolver, Loading @@ -99,4 +101,13 @@ class SecureSettingsRepositoryImpl( ) } } override suspend fun getString(name: String): String? { return withContext(backgroundDispatcher) { Settings.Secure.getString( contentResolver, name, ) } } }
packages/SystemUI/customization/tests/utils/src/com/android/systemui/shared/settings/data/repository/FakeSecureSettingsRepository.kt +6 −2 Original line number Diff line number Diff line Loading @@ -28,11 +28,15 @@ class FakeSecureSettingsRepository : SecureSettingsRepository { return settings.map { it.getOrDefault(name, defaultValue.toString()) }.map { it.toInt() } } override suspend fun set(name: String, value: Int) { override suspend fun setInt(name: String, value: Int) { settings.value = settings.value.toMutableMap().apply { this[name] = value.toString() } } override suspend fun get(name: String, defaultValue: Int): Int { override suspend fun getInt(name: String, defaultValue: Int): Int { return settings.value[name]?.toInt() ?: defaultValue } override suspend fun getString(name: String): String? { return settings.value[name] } }
packages/SystemUI/tests/src/com/android/systemui/shared/notifications/data/repository/NotificationSettingsRepositoryTest.kt +2 −2 Original line number Diff line number Diff line Loading @@ -58,13 +58,13 @@ class NotificationSettingsRepositoryTest : SysuiTestCase() { testScope.runTest { val showNotifs by collectLastValue(underTest.isShowNotificationsOnLockScreenEnabled) secureSettingsRepository.set( secureSettingsRepository.setInt( name = Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, value = 1, ) assertThat(showNotifs).isEqualTo(true) secureSettingsRepository.set( secureSettingsRepository.setInt( name = Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS, value = 0, ) Loading