Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6caf486e authored by Haijie Hong's avatar Haijie Hong Committed by Android (Google) Code Review
Browse files

Merge "Fix coroutine scope issue in DeviceSettingServiceConnection" into main

parents a2ddc394 f86b52b6
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -160,6 +160,12 @@ class DeviceSettingServiceConnection(
            }
            .shareIn(scope = coroutineScope, started = SharingStarted.WhileSubscribed(), replay = 1)

    private val services =
        ConcurrentHashMap<
            EndPoint,
            StateFlow<ServiceConnectionStatus<IDeviceSettingsProviderService>>,
        >()

    /** Gets [DeviceSettingsConfig] for the device, return null when failed. */
    suspend fun getDeviceSettingsConfig(): DeviceSettingsConfig? {
        if (!isServiceEnabled.await()) {
@@ -320,11 +326,5 @@ class DeviceSettingServiceConnection(
        const val CONFIG_SERVICE_PACKAGE_NAME = "DEVICE_SETTINGS_CONFIG_PACKAGE_NAME"
        const val CONFIG_SERVICE_CLASS_NAME = "DEVICE_SETTINGS_CONFIG_CLASS"
        const val CONFIG_SERVICE_INTENT_ACTION = "DEVICE_SETTINGS_CONFIG_ACTION"

        val services =
            ConcurrentHashMap<
                EndPoint,
                StateFlow<ServiceConnectionStatus<IDeviceSettingsProviderService>>,
            >()
    }
}
+0 −6
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@@ -140,11 +139,6 @@ class DeviceSettingRepositoryTest {
            )
    }

    @After
    fun clean() {
        DeviceSettingServiceConnection.services.clear()
    }

    @Test
    fun getDeviceSettingsConfig_withMetadata_success() {
        testScope.runTest {