Merge "[MEP] set removable eSIM as default eUICC to pass GCF/PTCRB" into tm-dev am: 7cbf1c926d
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/services/Telephony/+/18281785
Change-Id: I8b1e61bbc971170dbba38bceda23218800e6207a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
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 a5168ef..66cef64 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -11302,4 +11302,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);
+ }
}