Add the condition to show the eSIM convert menu.

When pSIM converts to eSIM, the new eSIM is downloaded and pSIM is disabled.
However, if the pSIM is in the preferred SIM, a pop-up occurs that says the downloaded eSIM is preferred.
This may cause confusion for users regarding seamless pSIM conversion.
Therefore, change the condition to show the convert menu if there is a pSIM, pSIM conversion is supported, and there is no active eSIM.

Bug: b/314881248
Test: manual done
Change-Id: I10134057a9ae7845ab9fb8b9b8b9f85629d33fa0
This commit is contained in:
Hyunho
2023-12-08 13:21:38 +00:00
parent 013626ebff
commit 036ed3fcee

View File

@@ -43,6 +43,7 @@ import androidx.preference.PreferenceScreen;
import com.android.internal.telephony.util.TelephonyUtils;
import com.android.settings.network.MobileNetworkRepository;
import com.android.settings.network.SubscriptionUtil;
import com.android.settingslib.core.lifecycle.Lifecycle;
import com.android.settingslib.mobile.dataservice.SubscriptionInfoEntity;
@@ -98,10 +99,21 @@ public class ConvertToEsimPreferenceController extends TelephonyBasePreferenceCo
@Override
public int getAvailabilityStatus(int subId) {
// TODO(b/262195754): Need the intent to enabled the feature.
// TODO(b/315073761) : Add a new API to set whether the profile has been
// converted/transferred. Remove any confusion to the user according to the set value.
/*
* If pSIM is set to preferred SIM and there is an active eSIM, convert the pSIM to eSIM
* and then disable the pSIM.
* This causes a dialog to switch the preferred SIM to downloaded new eSIM.
* This may cause confusion for the user about the seamless conversion.
* To avoid showing users dialogs that can cause confusion,
* add conditions to allow conversion in the absence of active eSIM.
*/
if (findConversionSupportComponent()) {
return mSubscriptionInfoEntity != null && mSubscriptionInfoEntity.isActiveSubscriptionId
&& !mSubscriptionInfoEntity.isEmbedded && isActiveSubscription(subId)
&& !hasActiveEsimProfiles()
? AVAILABLE
: CONDITIONALLY_UNAVAILABLE;
}
@@ -135,7 +147,6 @@ public class ConvertToEsimPreferenceController extends TelephonyBasePreferenceCo
@Override
public void onActiveSubInfoChanged(List<SubscriptionInfoEntity> subInfoEntityList) {
// TODO(b/262195754): Need the intent to enabled the feature.
mSubscriptionInfoEntityList = subInfoEntityList;
mSubscriptionInfoEntityList.forEach(entity -> {
if (Integer.parseInt(entity.subId) == mSubId) {
@@ -155,6 +166,24 @@ public class ConvertToEsimPreferenceController extends TelephonyBasePreferenceCo
return true;
}
private boolean hasActiveEsimProfiles() {
SubscriptionManager subscriptionManager = mContext.getSystemService(
SubscriptionManager.class);
List<SubscriptionInfo> subscriptionInfoList =
SubscriptionUtil.getActiveSubscriptions(subscriptionManager);
if (subscriptionInfoList == null || subscriptionInfoList.isEmpty()) {
return false;
}
int activatedEsimCount = (int) subscriptionInfoList
.stream()
.filter(SubscriptionInfo::isEmbedded)
.count();
if (activatedEsimCount > 0) {
return true;
}
return false;
}
private boolean findConversionSupportComponent() {
Intent intent = new Intent(EuiccService.ACTION_CONVERT_TO_EMBEDDED_SUBSCRIPTION);
PackageManager packageManager = mContext.getPackageManager();