[MEP] set removable eSIM as default eUICC to pass GCF/PTCRB
To support removable esim to pass GCT/PTCRB test in DSDS mode, we should make sure all the download/activation requests are by default route to the removable esim slot. In order to satisfy this use case, we should return removable esim cardId as default.
1. Add switch UI in RadioInfo hidden activity to set removable esim as default eUICC.
2. When switch is checked/unchecked, corresponding flag is set in UiccController and intent is broadcasted to LPA.
3. TelephonyManager#getCardIdForDefaultEuicc API returns removable esim cardId if switch is checked.
Bug: 228640832
Test: Manual verification (Verified intent broadcast is received at LPA and flag is set in the UiccController)
Change-Id: If8e2e75137ccb89be2ae410dc8c5d2a504188416
diff --git a/res/layout/radio_info.xml b/res/layout/radio_info.xml
index 1f137b0..6d1439e 100644
--- a/res/layout/radio_info.xml
+++ b/res/layout/radio_info.xml
@@ -258,6 +258,14 @@
android:layout_height="wrap_content"
android:text="@string/dsds_switch_string" />
+ <!-- Set removable eSIM as default eUICC. -->
+ <Switch android:id="@+id/removable_esim_switch"
+ android:textSize="14sp"
+ android:layout_marginTop="8dip"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/removable_esim_string" />
+
<!-- Horizontal Rule -->
<View
android:layout_width="fill_parent"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c17f9b9..38a86f9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2004,6 +2004,9 @@
<!-- UI debug setting: Enable/Disable DSDS [CHAR LIMIT=none] -->
<string name="dsds_dialog_cancel">Cancel</string>
+ <!-- Setting Removable esim as default. Only shown in diagnostic screen, so precise translation is not needed -->
+ <string name="removable_esim_string">Set Removable eSIM as Default</string>
+
<!-- Title for controlling on/off for Mobile phone's radio power. Only shown in diagnostic screen, so precise translation is not needed. -->
<string name="radio_info_radio_power">Mobile Radio Power</string>
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index bb38ef0..acf9db5 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -11293,4 +11293,42 @@
Binder.restoreCallingIdentity(identity);
}
}
+
+ /**
+ * set removable eSIM as default eUICC.
+ *
+ * @hide
+ */
+ @Override
+ public void setRemovableEsimAsDefaultEuicc(boolean isDefault, String callingPackage) {
+ enforceModifyPermission();
+ mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
+
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ UiccController.getInstance().setRemovableEsimAsDefaultEuicc(isDefault);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ /**
+ * Returns whether the removable eSIM is default eUICC or not.
+ *
+ * @hide
+ */
+ @Override
+ public boolean isRemovableEsimDefaultEuicc(String callingPackage) {
+ enforceReadPrivilegedPermission("isRemovableEsimDefaultEuicc");
+ mAppOps.checkPackage(Binder.getCallingUid(), callingPackage);
+
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ return UiccController.getInstance().isRemovableEsimDefaultEuicc();
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+
}
diff --git a/src/com/android/phone/settings/RadioInfo.java b/src/com/android/phone/settings/RadioInfo.java
index f6fe33e..ef31298 100644
--- a/src/com/android/phone/settings/RadioInfo.java
+++ b/src/com/android/phone/settings/RadioInfo.java
@@ -24,6 +24,7 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.pm.ComponentInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
@@ -96,6 +97,7 @@
import com.android.ims.ImsManager;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
+import com.android.internal.telephony.euicc.EuiccConnector;
import com.android.phone.R;
import java.io.IOException;
@@ -225,6 +227,9 @@
private static final String TRIGGER_CARRIER_PROVISIONING_ACTION =
"com.android.phone.settings.TRIGGER_CARRIER_PROVISIONING";
+ private static final String ACTION_REMOVABLE_ESIM_AS_DEFAULT =
+ "android.telephony.euicc.action.REMOVABLE_ESIM_AS_DEFAULT";
+
private TextView mDeviceId; //DeviceId is the IMEI in GSM and the MEID in CDMA
private TextView mLine1Number;
private TextView mSubscriptionId;
@@ -273,6 +278,7 @@
private Switch mEabProvisionedSwitch;
private Switch mCbrsDataSwitch;
private Switch mDsdsSwitch;
+ private Switch mRemovableEsimSwitch;
private Spinner mPreferredNetworkType;
private Spinner mSelectPhoneIndex;
private Spinner mCellInfoRefreshRateSpinner;
@@ -573,6 +579,13 @@
mDsdsSwitch.setVisibility(View.GONE);
}
+ mRemovableEsimSwitch = (Switch) findViewById(R.id.removable_esim_switch);
+ mRemovableEsimSwitch.setEnabled(!IS_USER_BUILD && isDsdsEnabled());
+ if (!IS_USER_BUILD) {
+ mRemovableEsimSwitch.setChecked(mTelephonyManager.isRemovableEsimDefaultEuicc());
+ mRemovableEsimSwitch.setOnCheckedChangeListener(mRemovableEsimChangeListener);
+ }
+
mRadioPowerOnSwitch = (Switch) findViewById(R.id.radio_power);
mDownlinkKbps = (TextView) findViewById(R.id.dl_kbps);
@@ -1857,6 +1870,9 @@
private void performDsdsSwitch() {
mTelephonyManager.switchMultiSimConfig(mDsdsSwitch.isChecked() ? 2 : 1);
+ if (!IS_USER_BUILD) {
+ mRemovableEsimSwitch.setEnabled(mDsdsSwitch.isChecked());
+ }
}
/**
@@ -1877,4 +1893,27 @@
}
}
};
+
+ OnCheckedChangeListener mRemovableEsimChangeListener = new OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ setRemovableEsimAsDefaultEuicc(isChecked);
+ }
+ };
+
+ private void setRemovableEsimAsDefaultEuicc(boolean isChecked) {
+ Log.d(TAG, "setRemovableEsimAsDefaultEuicc isChecked: " + isChecked);
+ mTelephonyManager.setRemovableEsimAsDefaultEuicc(isChecked);
+ // TODO(b/232528117): Instead of sending intent, add new APIs in platform,
+ // LPA can directly use the API.
+ ComponentInfo componentInfo = EuiccConnector.findBestComponent(getPackageManager());
+ if (componentInfo == null) {
+ Log.d(TAG, "setRemovableEsimAsDefaultEuicc: unable to find suitable component info");
+ return;
+ }
+ final Intent intent = new Intent(ACTION_REMOVABLE_ESIM_AS_DEFAULT);
+ intent.setPackage(componentInfo.packageName);
+ intent.putExtra("isDefault", isChecked);
+ sendBroadcast(intent);
+ }
}