Loading packages/SettingsLib/Spa/spa/build.gradle.kts +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,10 @@ android { minSdk = 23 } testOptions { targetSdk = 36 } sourceSets.getByName("main") { kotlin.setSrcDirs(listOf("src")) res.setSrcDirs(listOf("res")) Loading packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/coroutines/SpaDispatchers.kt 0 → 100644 +26 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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.settingslib.spa.coroutines import com.android.settingslib.spa.framework.common.SpaEnvironmentFactory import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.Dispatchers object SpaDispatchers { val Default: CoroutineContext get() = SpaEnvironmentFactory.optionalInstance?.defaultDispatcher ?: Dispatchers.Default } packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/flow/BroadcastReceiverFlow.kt +3 −3 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import android.content.IntentFilter import android.os.Build import android.util.Log import androidx.annotation.RequiresApi import kotlinx.coroutines.Dispatchers import com.android.settingslib.spa.coroutines.SpaDispatchers import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow Loading @@ -50,7 +50,7 @@ fun Context.broadcastReceiverFlow(intentFilter: IntentFilter, flags: Int): Flow< object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { Log.d(TAG, "onReceive: $intent") trySend(intent) val unused = trySend(intent) } } registerReceiver(broadcastReceiver, intentFilter, flags) Loading @@ -59,4 +59,4 @@ fun Context.broadcastReceiverFlow(intentFilter: IntentFilter, flags: Int): Flow< } .catch { e -> Log.e(TAG, "Error while broadcastReceiverFlow", e) } .conflate() .flowOn(Dispatchers.Default) .flowOn(SpaDispatchers.Default) packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/common/SpaEnvironment.kt +5 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalContext import com.android.settingslib.spa.framework.util.SystemProperties import com.android.settingslib.spa.restricted.RestrictedRepository import kotlinx.coroutines.Dispatchers import kotlin.coroutines.CoroutineContext private const val TAG = "SpaEnvironment" Loading Loading @@ -108,6 +110,9 @@ abstract class SpaEnvironment(context: Context) { // Specify provider authorities for debugging purpose. open val searchProviderAuthorities: String? = null /** Specify default dispatcher. */ open val defaultDispatcher: CoroutineContext = Dispatchers.Default /** Specify whether expressive design is enabled. */ open val isSpaExpressiveEnabled by lazy { SystemProperties.getBoolean("is_expressive_design_enabled", false) Loading packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/util/SpaIntent.kt +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ const val SESSION_BROWSE = "browse" const val SESSION_SEARCH = "search" const val SESSION_EXTERNAL = "external" @VisibleForTesting const val KEY_DESTINATION = "spaActivityDestination" const val KEY_DESTINATION = "spaActivityDestination" @VisibleForTesting const val KEY_HIGHLIGHT_ITEM_KEY = "highlightKey" internal const val KEY_SESSION_SOURCE_NAME = "sessionSource" Loading Loading
packages/SettingsLib/Spa/spa/build.gradle.kts +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,10 @@ android { minSdk = 23 } testOptions { targetSdk = 36 } sourceSets.getByName("main") { kotlin.setSrcDirs(listOf("src")) res.setSrcDirs(listOf("res")) Loading
packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/coroutines/SpaDispatchers.kt 0 → 100644 +26 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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.settingslib.spa.coroutines import com.android.settingslib.spa.framework.common.SpaEnvironmentFactory import kotlin.coroutines.CoroutineContext import kotlinx.coroutines.Dispatchers object SpaDispatchers { val Default: CoroutineContext get() = SpaEnvironmentFactory.optionalInstance?.defaultDispatcher ?: Dispatchers.Default }
packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/flow/BroadcastReceiverFlow.kt +3 −3 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ import android.content.IntentFilter import android.os.Build import android.util.Log import androidx.annotation.RequiresApi import kotlinx.coroutines.Dispatchers import com.android.settingslib.spa.coroutines.SpaDispatchers import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow Loading @@ -50,7 +50,7 @@ fun Context.broadcastReceiverFlow(intentFilter: IntentFilter, flags: Int): Flow< object : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { Log.d(TAG, "onReceive: $intent") trySend(intent) val unused = trySend(intent) } } registerReceiver(broadcastReceiver, intentFilter, flags) Loading @@ -59,4 +59,4 @@ fun Context.broadcastReceiverFlow(intentFilter: IntentFilter, flags: Int): Flow< } .catch { e -> Log.e(TAG, "Error while broadcastReceiverFlow", e) } .conflate() .flowOn(Dispatchers.Default) .flowOn(SpaDispatchers.Default)
packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/common/SpaEnvironment.kt +5 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.platform.LocalContext import com.android.settingslib.spa.framework.util.SystemProperties import com.android.settingslib.spa.restricted.RestrictedRepository import kotlinx.coroutines.Dispatchers import kotlin.coroutines.CoroutineContext private const val TAG = "SpaEnvironment" Loading Loading @@ -108,6 +110,9 @@ abstract class SpaEnvironment(context: Context) { // Specify provider authorities for debugging purpose. open val searchProviderAuthorities: String? = null /** Specify default dispatcher. */ open val defaultDispatcher: CoroutineContext = Dispatchers.Default /** Specify whether expressive design is enabled. */ open val isSpaExpressiveEnabled by lazy { SystemProperties.getBoolean("is_expressive_design_enabled", false) Loading
packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/framework/util/SpaIntent.kt +1 −1 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ const val SESSION_BROWSE = "browse" const val SESSION_SEARCH = "search" const val SESSION_EXTERNAL = "external" @VisibleForTesting const val KEY_DESTINATION = "spaActivityDestination" const val KEY_DESTINATION = "spaActivityDestination" @VisibleForTesting const val KEY_HIGHLIGHT_ITEM_KEY = "highlightKey" internal const val KEY_SESSION_SOURCE_NAME = "sessionSource" Loading