Merge "Modify the condition for showing DSDS dialog" into main

This commit is contained in:
SongFerng Wang
2024-10-28 02:59:18 +00:00
committed by Android (Google) Code Review
5 changed files with 269 additions and 43 deletions

View File

@@ -74,8 +74,11 @@ class SimOnboardingService {
}
var isEsimProfileEnabled: Boolean = false
get() {
activeSubInfoList.stream().anyMatch { it.isEmbedded }
return false
return activeSubInfoList.stream().anyMatch { it.isEmbedded }
}
var isRemovableSimProfileEnabled: Boolean = false
get() {
return activeSubInfoList.stream().anyMatch { !it.isEmbedded }
}
var doesTargetSimActive = false
get() {
@@ -288,8 +291,8 @@ class SimOnboardingService {
Log.d(TAG, "Hardware does not support DSDS.")
return false
}
val isActiveSim = activeSubInfoList.isNotEmpty()
if (isMultipleEnabledProfilesSupported && isActiveSim) {
val anyActiveSim = activeSubInfoList.isNotEmpty()
if (isMultipleEnabledProfilesSupported && anyActiveSim) {
Log.d(TAG,
"Device supports MEP and eSIM operation and eSIM profile is enabled."
+ " DSDS condition satisfied."
@@ -297,15 +300,13 @@ class SimOnboardingService {
return true
}
if (doesTargetSimHaveEsimOperation) {
if (UiccSlotRepository(telephonyManager).anyRemovablePhysicalSimEnabled()) {
Log.d(
TAG,
"eSIM operation and removable PSIM is enabled. DSDS condition satisfied."
)
return true
}
} else if (isEsimProfileEnabled) {
if (doesTargetSimHaveEsimOperation && isRemovableSimProfileEnabled) {
Log.d(TAG,
"eSIM operation and removable PSIM is enabled. DSDS condition satisfied."
)
return true
}
if (!doesTargetSimHaveEsimOperation && isEsimProfileEnabled) {
Log.d(TAG,
"Removable SIM operation and eSIM profile is enabled. DSDS condition"
+ " satisfied."

View File

@@ -557,15 +557,17 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc
Log.d(TAG, "Hardware does not support DSDS.");
return false;
}
boolean isActiveSim = SubscriptionUtil.getActiveSubscriptions(
boolean anyActiveSim = SubscriptionUtil.getActiveSubscriptions(
mSubscriptionManager).size() > 0;
if (isMultipleEnabledProfilesSupported() && isActiveSim) {
if (isMultipleEnabledProfilesSupported() && anyActiveSim) {
Log.d(TAG,
"Device supports MEP and eSIM operation and eSIM profile is enabled."
+ " DSDS condition satisfied.");
return true;
}
boolean isRemovableSimEnabled = isRemovableSimEnabled();
boolean isRemovableSimEnabled =
SubscriptionUtil.getActiveSubscriptions(mSubscriptionManager).stream()
.anyMatch(subInfo-> !subInfo.isEmbedded());
if (mIsEsimOperation && isRemovableSimEnabled) {
Log.d(TAG, "eSIM operation and removable SIM is enabled. DSDS condition satisfied.");
return true;
@@ -583,7 +585,7 @@ public class ToggleSubscriptionDialogActivity extends SubscriptionActionDialogAc
}
private boolean isRemovableSimEnabled() {
return new UiccSlotRepository(mTelMgr).anyRemovablePhysicalSimEnabled();
return new UiccSlotRepository(mTelMgr).anyRemovablePhysicalSimSlotActiveAndInserted();
}
private boolean isMultipleEnabledProfilesSupported() {

View File

@@ -22,17 +22,17 @@ import android.util.Log
class UiccSlotRepository(private val telephonyManager: TelephonyManager?) {
/** Returns whether any removable physical sim is enabled. */
fun anyRemovablePhysicalSimEnabled(): Boolean {
/** Returns whether any removable physical sim slot is active and the sim is inserted. */
fun anyRemovablePhysicalSimSlotActiveAndInserted(): Boolean {
val result =
telephonyManager?.uiccSlotsInfo?.any { uiccSlotInfo: UiccSlotInfo? ->
uiccSlotInfo.isRemovablePhysicalSimEnabled()
uiccSlotInfo.isRemovablePhysicalSimSlotActiveAndInserted()
} ?: false
Log.i(TAG, "anyRemovablePhysicalSimEnabled: $result")
return result
}
private fun UiccSlotInfo?.isRemovablePhysicalSimEnabled(): Boolean {
private fun UiccSlotInfo?.isRemovablePhysicalSimSlotActiveAndInserted(): Boolean {
return this != null &&
isRemovable &&
!isEuicc &&