Revert "Move SettingsProxyExt content observer registration call on bg thread."
This reverts commit 0ccaa029c98b89c68c989b0b0436b63157c58acf.
Reason for revert: Droidmonitor triggered revert due to b/357575679.
Change-Id: Icbe8ba2723b1d2a44ce4d3853ef2cfcb5360039a
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index 22bfe90..201aaed 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -1304,14 +1304,4 @@
namespace: "systemui"
description: "Adding haptic component infrastructure to sliders in Compose."
bug: "341968766"
-}
-
-flag {
- namespace: "systemui"
- name: "settings_ext_register_content_observer_on_bg_thread"
- description: "Register content observer in callback flow APIs on background thread in SettingsProxyExt."
- bug: "355389014"
- metadata {
- purpose: PURPOSE_BUGFIX
- }
}
\ No newline at end of file
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/util/settings/SettingsProxyExtTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/util/settings/SettingsProxyExtTest.kt
deleted file mode 100644
index e281894..0000000
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/util/settings/SettingsProxyExtTest.kt
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * Copyright (C) 2024 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.util.settings
-
-import android.database.ContentObserver
-import android.platform.test.annotations.DisableFlags
-import android.platform.test.annotations.EnableFlags
-import androidx.test.ext.junit.runners.AndroidJUnit4
-import androidx.test.filters.SmallTest
-import com.android.systemui.Flags
-import com.android.systemui.SysuiTestCase
-import com.android.systemui.coroutines.collectLastValue
-import com.android.systemui.kosmos.testScope
-import com.android.systemui.testKosmos
-import com.android.systemui.util.settings.SettingsProxyExt.observerFlow
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.Job
-import kotlinx.coroutines.test.runCurrent
-import kotlinx.coroutines.test.runTest
-import org.junit.Before
-import org.junit.Test
-import org.junit.runner.RunWith
-import org.mockito.Mock
-import org.mockito.MockitoAnnotations
-import org.mockito.kotlin.any
-import org.mockito.kotlin.times
-import org.mockito.kotlin.verify
-
-/** Tests for [SettingsProxyExt]. */
-@RunWith(AndroidJUnit4::class)
-@SmallTest
-@OptIn(ExperimentalCoroutinesApi::class)
-class SettingsProxyExtTest : SysuiTestCase() {
- private val kosmos = testKosmos()
- private val testScope = kosmos.testScope
- @Mock lateinit var settingsProxy: SettingsProxy
- @Mock lateinit var userSettingsProxy: UserSettingsProxy
-
- @Before
- fun setUp() {
- MockitoAnnotations.initMocks(this)
- }
-
- @Test
- @EnableFlags(Flags.FLAG_SETTINGS_EXT_REGISTER_CONTENT_OBSERVER_ON_BG_THREAD)
- fun observeFlow_bgFlagEnabled_settingsProxy_registerContentObserverInvoked() =
- testScope.runTest {
- val unused by collectLastValue(settingsProxy.observerFlow(SETTING_1, SETTING_2))
- runCurrent()
- verify(settingsProxy, times(2))
- .registerContentObserver(any<String>(), any<ContentObserver>())
- }
-
- @Test
- @DisableFlags(Flags.FLAG_SETTINGS_EXT_REGISTER_CONTENT_OBSERVER_ON_BG_THREAD)
- fun observeFlow_bgFlagDisabled_multipleSettings_SettingsProxy_registerContentObserverInvoked() =
- testScope.runTest {
- val unused by collectLastValue(settingsProxy.observerFlow(SETTING_1, SETTING_2))
- runCurrent()
- verify(settingsProxy, times(2))
- .registerContentObserverSync(any<String>(), any<ContentObserver>())
- }
-
- @Test
- @EnableFlags(Flags.FLAG_SETTINGS_EXT_REGISTER_CONTENT_OBSERVER_ON_BG_THREAD)
- fun observeFlow_bgFlagEnabled_channelClosed_settingsProxy_unregisterContentObserverInvoked() =
- testScope.runTest {
- val job = Job()
- val unused by
- collectLastValue(settingsProxy.observerFlow(SETTING_1, SETTING_2), context = job)
- runCurrent()
- job.cancel()
- runCurrent()
- verify(settingsProxy).unregisterContentObserverAsync(any<ContentObserver>())
- }
-
- @Test
- @DisableFlags(Flags.FLAG_SETTINGS_EXT_REGISTER_CONTENT_OBSERVER_ON_BG_THREAD)
- fun observeFlow_bgFlagDisabled_channelClosed_settingsProxy_unregisterContentObserverInvoked() =
- testScope.runTest {
- val job = Job()
- val unused by
- collectLastValue(settingsProxy.observerFlow(SETTING_1, SETTING_2), context = job)
- runCurrent()
- job.cancel()
- runCurrent()
- verify(settingsProxy).unregisterContentObserverSync(any<ContentObserver>())
- }
-
- @Test
- @EnableFlags(Flags.FLAG_SETTINGS_EXT_REGISTER_CONTENT_OBSERVER_ON_BG_THREAD)
- fun observeFlow_bgFlagEnabled_userSettingsProxy_registerContentObserverForUserInvoked() =
- testScope.runTest {
- val unused by
- collectLastValue(userSettingsProxy.observerFlow(userId = 0, SETTING_1, SETTING_2))
- runCurrent()
- verify(userSettingsProxy, times(2))
- .registerContentObserverForUser(any<String>(), any<ContentObserver>(), any<Int>())
- }
-
- @Test
- @DisableFlags(Flags.FLAG_SETTINGS_EXT_REGISTER_CONTENT_OBSERVER_ON_BG_THREAD)
- fun observeFlow_bgFlagDisabled_userSettingsProxy_registerContentObserverForUserInvoked() =
- testScope.runTest {
- val unused by
- collectLastValue(userSettingsProxy.observerFlow(userId = 0, SETTING_1, SETTING_2))
- runCurrent()
- verify(userSettingsProxy, times(2))
- .registerContentObserverForUserSync(
- any<String>(),
- any<ContentObserver>(),
- any<Int>()
- )
- }
-
- @Test
- @EnableFlags(Flags.FLAG_SETTINGS_EXT_REGISTER_CONTENT_OBSERVER_ON_BG_THREAD)
- fun observeFlow_bgFlagEnabled_channelClosed_userSettingsProxy_unregisterContentObserverInvoked() =
- testScope.runTest {
- val job = Job()
- val unused by
- collectLastValue(
- userSettingsProxy.observerFlow(userId = 0, SETTING_1, SETTING_2),
- context = job
- )
- runCurrent()
- job.cancel()
- runCurrent()
- verify(userSettingsProxy).unregisterContentObserverAsync(any<ContentObserver>())
- }
-
- @Test
- @DisableFlags(Flags.FLAG_SETTINGS_EXT_REGISTER_CONTENT_OBSERVER_ON_BG_THREAD)
- fun observeFlow_bgFlagDisabled_channelClosed_userSettingsProxy_unregisterContentObserverInvoked() =
- testScope.runTest {
- val job = Job()
- val unused by
- collectLastValue(
- userSettingsProxy.observerFlow(userId = 0, SETTING_1, SETTING_2),
- context = job
- )
- runCurrent()
- job.cancel()
- runCurrent()
- verify(userSettingsProxy).unregisterContentObserverSync(any<ContentObserver>())
- }
-
- private companion object {
- val SETTING_1 = "settings_1"
- val SETTING_2 = "settings_2"
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxyExt.kt b/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxyExt.kt
index 36468144..d757e33 100644
--- a/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxyExt.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/settings/SettingsProxyExt.kt
@@ -19,7 +19,6 @@
import android.annotation.UserIdInt
import android.database.ContentObserver
-import com.android.systemui.Flags
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.Flow
@@ -40,21 +39,9 @@
}
}
- names.forEach { name ->
- if (Flags.settingsExtRegisterContentObserverOnBgThread()) {
- registerContentObserverForUser(name, observer, userId)
- } else {
- registerContentObserverForUserSync(name, observer, userId)
- }
- }
+ names.forEach { name -> registerContentObserverForUserSync(name, observer, userId) }
- awaitClose {
- if (Flags.settingsExtRegisterContentObserverOnBgThread()) {
- unregisterContentObserverAsync(observer)
- } else {
- unregisterContentObserverSync(observer)
- }
- }
+ awaitClose { unregisterContentObserverSync(observer) }
}
}
@@ -70,21 +57,9 @@
}
}
- names.forEach { name ->
- if (Flags.settingsExtRegisterContentObserverOnBgThread()) {
- registerContentObserver(name, observer)
- } else {
- registerContentObserverSync(name, observer)
- }
- }
+ names.forEach { name -> registerContentObserverSync(name, observer) }
- awaitClose {
- if (Flags.settingsExtRegisterContentObserverOnBgThread()) {
- unregisterContentObserverAsync(observer)
- } else {
- unregisterContentObserverSync(observer)
- }
- }
+ awaitClose { unregisterContentObserverSync(observer) }
}
}
}