Loading src/com/android/settings/network/SimOnboardingActivity.kt +5 −0 Original line number Diff line number Diff line Loading @@ -401,6 +401,11 @@ class SimOnboardingActivity : SpaBaseDialogActivity() { Log.d(TAG, "startSimSwitching:") var targetSubInfo = onboardingService.targetSubInfo if(onboardingService.doesTargetSimActive) { Log.d(TAG, "target subInfo is already active") callbackListener(CallbackType.CALLBACK_SETUP_NAME) return } targetSubInfo?.let { var removedSubInfo = onboardingService.getRemovedSim() if (targetSubInfo.isEmbedded) { Loading src/com/android/settings/network/SimOnboardingService.kt +34 −19 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.settings.network import android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID import android.telephony.SubscriptionManager.INVALID_SIM_SLOT_INDEX import android.content.Context import android.telephony.SubscriptionInfo import android.telephony.SubscriptionManager Loading @@ -40,26 +43,26 @@ class SimOnboardingService { var subscriptionManager:SubscriptionManager? = null var telephonyManager:TelephonyManager? = null var targetSubId: Int = INVALID var targetSubId: Int = INVALID_SUBSCRIPTION_ID var targetSubInfo: SubscriptionInfo? = null var availableSubInfoList: List<SubscriptionInfo> = listOf() var activeSubInfoList: List<SubscriptionInfo> = listOf() var slotInfoList: List<UiccSlotInfo> = listOf() var uiccCardInfoList: List<UiccCardInfo> = listOf() var targetPrimarySimCalls: Int = SubscriptionManager.INVALID_SUBSCRIPTION_ID var targetPrimarySimTexts: Int = SubscriptionManager.INVALID_SUBSCRIPTION_ID var targetPrimarySimMobileData: Int = SubscriptionManager.INVALID_SUBSCRIPTION_ID var targetPrimarySimCalls: Int = INVALID_SUBSCRIPTION_ID var targetPrimarySimTexts: Int = INVALID_SUBSCRIPTION_ID var targetPrimarySimMobileData: Int = INVALID_SUBSCRIPTION_ID val targetPrimarySimAutoDataSwitch = MutableStateFlow(false) var targetNonDds: Int = SubscriptionManager.INVALID_SUBSCRIPTION_ID var targetNonDds: Int = INVALID_SUBSCRIPTION_ID get() { if(targetPrimarySimMobileData == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { if(targetPrimarySimMobileData == INVALID_SUBSCRIPTION_ID) { Log.w(TAG, "No DDS") return SubscriptionManager.INVALID_SUBSCRIPTION_ID return INVALID_SUBSCRIPTION_ID } return userSelectedSubInfoList .filter { info -> info.subscriptionId != targetPrimarySimMobileData } .map { it.subscriptionId } .firstOrNull() ?: SubscriptionManager.INVALID_SUBSCRIPTION_ID .firstOrNull() ?: INVALID_SUBSCRIPTION_ID } var callback: (CallbackType) -> Unit = {} Loading @@ -84,6 +87,11 @@ class SimOnboardingService { activeSubInfoList.stream().anyMatch { it.isEmbedded } return false } var doesTargetSimActive = false get() { return targetSubInfo?.getSimSlotIndex() ?: INVALID_SIM_SLOT_INDEX >= 0 } var doesTargetSimHaveEsimOperation = false get() { return targetSubInfo?.isEmbedded ?: false Loading @@ -95,7 +103,7 @@ class SimOnboardingService { } var getActiveModemCount = 0 get() { return telephonyManager?.getActiveModemCount() ?: 0 return (telephonyManager?.getActiveModemCount() ?: 0) } var renameMutableMap : MutableMap<Int, String> = mutableMapOf() Loading @@ -103,16 +111,18 @@ class SimOnboardingService { var isSimSelectionFinished = false get() { return getActiveModemCount != 0 && userSelectedSubInfoList.size == getActiveModemCount val activeModem = getActiveModemCount return activeModem != 0 && userSelectedSubInfoList.size == activeModem } var isAllOfSlotAssigned = false get() { if(getActiveModemCount == 0){ val activeModem = getActiveModemCount if(activeModem == 0){ Log.e(TAG, "isAllOfSlotAssigned: getActiveModemCount is 0") return true } return getActiveModemCount != 0 && activeSubInfoList.size == getActiveModemCount return getActiveModemCount != 0 && activeSubInfoList.size == activeModem } var isMultiSimEnabled = false get() { Loading @@ -129,7 +139,7 @@ class SimOnboardingService { } fun isValid(): Boolean { return targetSubId != INVALID return targetSubId != INVALID_SUBSCRIPTION_ID && targetSubInfo != null && activeSubInfoList.isNotEmpty() && slotInfoList.isNotEmpty() Loading @@ -156,14 +166,15 @@ class SimOnboardingService { fun initData(inputTargetSubId: Int, context: Context, callback: (CallbackType) -> Unit) { clear() this.callback = callback targetSubId = inputTargetSubId subscriptionManager = context.getSystemService(SubscriptionManager::class.java) telephonyManager = context.getSystemService(TelephonyManager::class.java) activeSubInfoList = SubscriptionUtil.getActiveSubscriptions(subscriptionManager) Log.d( TAG, "startInit: targetSubId:$targetSubId, activeSubInfoList: $activeSubInfoList" ) activeSubInfoList = SubscriptionUtil.getActiveSubscriptions(subscriptionManager) ThreadUtils.postOnBackgroundThread { availableSubInfoList = SubscriptionUtil.getAvailableSubscriptions(context) Loading Loading @@ -242,15 +253,20 @@ class SimOnboardingService { fun addCurrentItemForSelectedSim() { if (userSelectedSubInfoList.size < getActiveModemCount) { userSelectedSubInfoList.addAll(activeSubInfoList) Log.d(TAG, "addCurrentItemForSelectedSim: userSelectedSubInfoList:" + ", $userSelectedSubInfoList") userSelectedSubInfoList.addAll( activeSubInfoList.filter { !userSelectedSubInfoList.contains(it) } ) Log.d(TAG, "addCurrentItemForSelectedSim: userSelectedSubInfoList: $userSelectedSubInfoList" ) } } fun addItemForSelectedSim(selectedSubInfo: SubscriptionInfo) { if (!userSelectedSubInfoList.contains(selectedSubInfo)) { userSelectedSubInfoList.add(selectedSubInfo) } } fun removeItemForSelectedSim(selectedSubInfo: SubscriptionInfo) { if (userSelectedSubInfoList.contains(selectedSubInfo)) { Loading Loading @@ -370,7 +386,6 @@ class SimOnboardingService { companion object{ private const val TAG = "SimOnboardingService" private const val INVALID = SubscriptionManager.INVALID_SUBSCRIPTION_ID const val NUM_OF_SIMS_FOR_DSDS = 2 } } No newline at end of file src/com/android/settings/spa/network/SimOnboardingPageProvider.kt +2 −1 Original line number Diff line number Diff line Loading @@ -107,7 +107,8 @@ fun PageImpl(onboardingService:SimOnboardingService,navHostController: NavHostCo composable(route = SimOnboardingScreen.LabelSim.name) { val nextPage = if (onboardingService.isMultipleEnabledProfilesSupported && onboardingService.isAllOfSlotAssigned) { && onboardingService.isAllOfSlotAssigned && !onboardingService.doesTargetSimActive) { SimOnboardingScreen.SelectSim.name } else { LaunchedEffect(Unit) { Loading tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingPageProviderTest.kt +1 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,7 @@ class SimOnboardingPageProviderTest { mockSimOnboardingService.stub { on { isMultipleEnabledProfilesSupported }.thenReturn(true) on { isAllOfSlotAssigned }.thenReturn(true) on { doesTargetSimActive }.thenReturn(false) } composeTestRule.setContent { Loading Loading
src/com/android/settings/network/SimOnboardingActivity.kt +5 −0 Original line number Diff line number Diff line Loading @@ -401,6 +401,11 @@ class SimOnboardingActivity : SpaBaseDialogActivity() { Log.d(TAG, "startSimSwitching:") var targetSubInfo = onboardingService.targetSubInfo if(onboardingService.doesTargetSimActive) { Log.d(TAG, "target subInfo is already active") callbackListener(CallbackType.CALLBACK_SETUP_NAME) return } targetSubInfo?.let { var removedSubInfo = onboardingService.getRemovedSim() if (targetSubInfo.isEmbedded) { Loading
src/com/android/settings/network/SimOnboardingService.kt +34 −19 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.settings.network import android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID import android.telephony.SubscriptionManager.INVALID_SIM_SLOT_INDEX import android.content.Context import android.telephony.SubscriptionInfo import android.telephony.SubscriptionManager Loading @@ -40,26 +43,26 @@ class SimOnboardingService { var subscriptionManager:SubscriptionManager? = null var telephonyManager:TelephonyManager? = null var targetSubId: Int = INVALID var targetSubId: Int = INVALID_SUBSCRIPTION_ID var targetSubInfo: SubscriptionInfo? = null var availableSubInfoList: List<SubscriptionInfo> = listOf() var activeSubInfoList: List<SubscriptionInfo> = listOf() var slotInfoList: List<UiccSlotInfo> = listOf() var uiccCardInfoList: List<UiccCardInfo> = listOf() var targetPrimarySimCalls: Int = SubscriptionManager.INVALID_SUBSCRIPTION_ID var targetPrimarySimTexts: Int = SubscriptionManager.INVALID_SUBSCRIPTION_ID var targetPrimarySimMobileData: Int = SubscriptionManager.INVALID_SUBSCRIPTION_ID var targetPrimarySimCalls: Int = INVALID_SUBSCRIPTION_ID var targetPrimarySimTexts: Int = INVALID_SUBSCRIPTION_ID var targetPrimarySimMobileData: Int = INVALID_SUBSCRIPTION_ID val targetPrimarySimAutoDataSwitch = MutableStateFlow(false) var targetNonDds: Int = SubscriptionManager.INVALID_SUBSCRIPTION_ID var targetNonDds: Int = INVALID_SUBSCRIPTION_ID get() { if(targetPrimarySimMobileData == SubscriptionManager.INVALID_SUBSCRIPTION_ID) { if(targetPrimarySimMobileData == INVALID_SUBSCRIPTION_ID) { Log.w(TAG, "No DDS") return SubscriptionManager.INVALID_SUBSCRIPTION_ID return INVALID_SUBSCRIPTION_ID } return userSelectedSubInfoList .filter { info -> info.subscriptionId != targetPrimarySimMobileData } .map { it.subscriptionId } .firstOrNull() ?: SubscriptionManager.INVALID_SUBSCRIPTION_ID .firstOrNull() ?: INVALID_SUBSCRIPTION_ID } var callback: (CallbackType) -> Unit = {} Loading @@ -84,6 +87,11 @@ class SimOnboardingService { activeSubInfoList.stream().anyMatch { it.isEmbedded } return false } var doesTargetSimActive = false get() { return targetSubInfo?.getSimSlotIndex() ?: INVALID_SIM_SLOT_INDEX >= 0 } var doesTargetSimHaveEsimOperation = false get() { return targetSubInfo?.isEmbedded ?: false Loading @@ -95,7 +103,7 @@ class SimOnboardingService { } var getActiveModemCount = 0 get() { return telephonyManager?.getActiveModemCount() ?: 0 return (telephonyManager?.getActiveModemCount() ?: 0) } var renameMutableMap : MutableMap<Int, String> = mutableMapOf() Loading @@ -103,16 +111,18 @@ class SimOnboardingService { var isSimSelectionFinished = false get() { return getActiveModemCount != 0 && userSelectedSubInfoList.size == getActiveModemCount val activeModem = getActiveModemCount return activeModem != 0 && userSelectedSubInfoList.size == activeModem } var isAllOfSlotAssigned = false get() { if(getActiveModemCount == 0){ val activeModem = getActiveModemCount if(activeModem == 0){ Log.e(TAG, "isAllOfSlotAssigned: getActiveModemCount is 0") return true } return getActiveModemCount != 0 && activeSubInfoList.size == getActiveModemCount return getActiveModemCount != 0 && activeSubInfoList.size == activeModem } var isMultiSimEnabled = false get() { Loading @@ -129,7 +139,7 @@ class SimOnboardingService { } fun isValid(): Boolean { return targetSubId != INVALID return targetSubId != INVALID_SUBSCRIPTION_ID && targetSubInfo != null && activeSubInfoList.isNotEmpty() && slotInfoList.isNotEmpty() Loading @@ -156,14 +166,15 @@ class SimOnboardingService { fun initData(inputTargetSubId: Int, context: Context, callback: (CallbackType) -> Unit) { clear() this.callback = callback targetSubId = inputTargetSubId subscriptionManager = context.getSystemService(SubscriptionManager::class.java) telephonyManager = context.getSystemService(TelephonyManager::class.java) activeSubInfoList = SubscriptionUtil.getActiveSubscriptions(subscriptionManager) Log.d( TAG, "startInit: targetSubId:$targetSubId, activeSubInfoList: $activeSubInfoList" ) activeSubInfoList = SubscriptionUtil.getActiveSubscriptions(subscriptionManager) ThreadUtils.postOnBackgroundThread { availableSubInfoList = SubscriptionUtil.getAvailableSubscriptions(context) Loading Loading @@ -242,15 +253,20 @@ class SimOnboardingService { fun addCurrentItemForSelectedSim() { if (userSelectedSubInfoList.size < getActiveModemCount) { userSelectedSubInfoList.addAll(activeSubInfoList) Log.d(TAG, "addCurrentItemForSelectedSim: userSelectedSubInfoList:" + ", $userSelectedSubInfoList") userSelectedSubInfoList.addAll( activeSubInfoList.filter { !userSelectedSubInfoList.contains(it) } ) Log.d(TAG, "addCurrentItemForSelectedSim: userSelectedSubInfoList: $userSelectedSubInfoList" ) } } fun addItemForSelectedSim(selectedSubInfo: SubscriptionInfo) { if (!userSelectedSubInfoList.contains(selectedSubInfo)) { userSelectedSubInfoList.add(selectedSubInfo) } } fun removeItemForSelectedSim(selectedSubInfo: SubscriptionInfo) { if (userSelectedSubInfoList.contains(selectedSubInfo)) { Loading Loading @@ -370,7 +386,6 @@ class SimOnboardingService { companion object{ private const val TAG = "SimOnboardingService" private const val INVALID = SubscriptionManager.INVALID_SUBSCRIPTION_ID const val NUM_OF_SIMS_FOR_DSDS = 2 } } No newline at end of file
src/com/android/settings/spa/network/SimOnboardingPageProvider.kt +2 −1 Original line number Diff line number Diff line Loading @@ -107,7 +107,8 @@ fun PageImpl(onboardingService:SimOnboardingService,navHostController: NavHostCo composable(route = SimOnboardingScreen.LabelSim.name) { val nextPage = if (onboardingService.isMultipleEnabledProfilesSupported && onboardingService.isAllOfSlotAssigned) { && onboardingService.isAllOfSlotAssigned && !onboardingService.doesTargetSimActive) { SimOnboardingScreen.SelectSim.name } else { LaunchedEffect(Unit) { Loading
tests/spa_unit/src/com/android/settings/spa/network/SimOnboardingPageProviderTest.kt +1 −0 Original line number Diff line number Diff line Loading @@ -91,6 +91,7 @@ class SimOnboardingPageProviderTest { mockSimOnboardingService.stub { on { isMultipleEnabledProfilesSupported }.thenReturn(true) on { isAllOfSlotAssigned }.thenReturn(true) on { doesTargetSimActive }.thenReturn(false) } composeTestRule.setContent { Loading