Merge "Refacotr mobile data observer for repository" into 24D1-dev
diff --git a/res/layout/face_enroll_accessibility_toggle.xml b/res/layout/face_enroll_accessibility_toggle.xml
index f2987db..428916e 100644
--- a/res/layout/face_enroll_accessibility_toggle.xml
+++ b/res/layout/face_enroll_accessibility_toggle.xml
@@ -51,7 +51,7 @@
         android:letterSpacing="0"
         android:minHeight="20dp"
         android:fontFamily="@string/sudFontSecondaryText"
-        android:textColor="?androidprv:attr/materialColorOnSurfaceVariant"/>
+        android:textColor="?android:attr/textColorPrimary"/>
 
     <!-- Toggle -->
     <com.google.android.material.materialswitch.MaterialSwitch
diff --git a/src/com/android/settings/network/telephony/CallStateRepository.kt b/src/com/android/settings/network/telephony/CallStateRepository.kt
index 1c93af3..4b6cdc8 100644
--- a/src/com/android/settings/network/telephony/CallStateRepository.kt
+++ b/src/com/android/settings/network/telephony/CallStateRepository.kt
@@ -26,6 +26,7 @@
 import kotlinx.coroutines.flow.combine
 import kotlinx.coroutines.flow.conflate
 import kotlinx.coroutines.flow.flatMapLatest
+import kotlinx.coroutines.flow.flowOf
 import kotlinx.coroutines.flow.flowOn
 import kotlinx.coroutines.flow.onEach
 
@@ -50,8 +51,12 @@
     fun isInCallFlow(): Flow<Boolean> = context.subscriptionsChangedFlow()
         .flatMapLatest {
             val subIds = subscriptionManager.activeSubscriptionIdList
-            combine(subIds.map(::callStateFlow)) { states ->
-                states.any { it != TelephonyManager.CALL_STATE_IDLE }
+            if (subIds.isEmpty()) {
+                flowOf(false)
+            } else {
+                combine(subIds.map(::callStateFlow)) { states ->
+                    states.any { it != TelephonyManager.CALL_STATE_IDLE }
+                }
             }
         }
         .conflate()
diff --git a/tests/spa_unit/src/com/android/settings/network/telephony/CallStateRepositoryTest.kt b/tests/spa_unit/src/com/android/settings/network/telephony/CallStateRepositoryTest.kt
index 8213ecf..55d520f 100644
--- a/tests/spa_unit/src/com/android/settings/network/telephony/CallStateRepositoryTest.kt
+++ b/tests/spa_unit/src/com/android/settings/network/telephony/CallStateRepositoryTest.kt
@@ -35,6 +35,7 @@
 import org.mockito.kotlin.doReturn
 import org.mockito.kotlin.mock
 import org.mockito.kotlin.spy
+import org.mockito.kotlin.stub
 
 @RunWith(AndroidJUnit4::class)
 class CallStateRepositoryTest {
@@ -87,6 +88,17 @@
     }
 
     @Test
+    fun isInCallFlow_noActiveSubscription() = runBlocking {
+        mockSubscriptionManager.stub {
+            on { activeSubscriptionIdList } doReturn intArrayOf()
+        }
+
+        val isInCall = repository.isInCallFlow().firstWithTimeoutOrNull()
+
+        assertThat(isInCall).isFalse()
+    }
+
+    @Test
     fun isInCallFlow_initial() = runBlocking {
         val isInCall = repository.isInCallFlow().firstWithTimeoutOrNull()