diff --git a/api/system-current.txt b/api/system-current.txt index 6f20cd1cfafcb..5fe3c039bb7da 100755 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -9722,6 +9722,11 @@ package android.telephony.euicc { method @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void getDefaultDownloadableSubscriptionList(android.app.PendingIntent); method @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void getDownloadableSubscriptionMetadata(android.telephony.euicc.DownloadableSubscription, android.app.PendingIntent); method @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public int getOtaStatus(); + method @NonNull @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public java.util.List getSupportedCountries(); + method @NonNull @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public java.util.List getUnsupportedCountries(); + method @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public boolean isSupportedCountry(@NonNull String); + method @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void setSupportedCountries(@NonNull java.util.List); + method @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void setUnsupportedCountries(@NonNull java.util.List); field public static final String ACTION_DELETE_SUBSCRIPTION_PRIVILEGED = "android.telephony.euicc.action.DELETE_SUBSCRIPTION_PRIVILEGED"; field @RequiresPermission(android.Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public static final String ACTION_OTA_STATUS_CHANGED = "android.telephony.euicc.action.OTA_STATUS_CHANGED"; field public static final String ACTION_PROVISION_EMBEDDED_SUBSCRIPTION = "android.telephony.euicc.action.PROVISION_EMBEDDED_SUBSCRIPTION"; diff --git a/telephony/java/android/telephony/euicc/EuiccManager.java b/telephony/java/android/telephony/euicc/EuiccManager.java index cb66a9650f2ff..ccd28f433e402 100644 --- a/telephony/java/android/telephony/euicc/EuiccManager.java +++ b/telephony/java/android/telephony/euicc/EuiccManager.java @@ -38,6 +38,9 @@ import com.android.internal.telephony.euicc.IEuiccController; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; /** * EuiccManager is the application interface to eUICCs, or eSIMs/embedded SIMs. @@ -938,6 +941,138 @@ public class EuiccManager { } } + /** + * Sets the supported countries for eUICC. + * + *

Requires that the calling app has the + * {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. + * + *

The supported country list will be replaced by {@code supportedCountries}. For how we + * determine whether a country is supported please check {@link #isSupportedCountry}. + * + * @param supportedCountries is a list of strings contains country ISO codes in uppercase. + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) + public void setSupportedCountries(@NonNull List supportedCountries) { + if (!isEnabled()) { + return; + } + try { + getIEuiccController().setSupportedCountries( + true /* isSupported */, + supportedCountries.stream() + .map(String::toUpperCase).collect(Collectors.toList())); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Sets the unsupported countries for eUICC. + * + *

Requires that the calling app has the + * {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. + * + *

The unsupported country list will be replaced by {@code unsupportedCountries}. For how we + * determine whether a country is supported please check {@link #isSupportedCountry}. + * + * @param unsupportedCountries is a list of strings contains country ISO codes in uppercase. + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) + public void setUnsupportedCountries(@NonNull List unsupportedCountries) { + if (!isEnabled()) { + return; + } + try { + getIEuiccController().setSupportedCountries( + false /* isSupported */, + unsupportedCountries.stream() + .map(String::toUpperCase).collect(Collectors.toList())); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Gets the supported countries for eUICC. + * + *

Requires that the calling app has the + * {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. + * + * @return list of strings contains country ISO codes in uppercase. + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) + @NonNull + public List getSupportedCountries() { + if (!isEnabled()) { + return Collections.emptyList(); + } + try { + return getIEuiccController().getSupportedCountries(true /* isSupported */); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Gets the unsupported countries for eUICC. + * + *

Requires that the calling app has the + * {@code android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. + * + * @return list of strings contains country ISO codes in uppercase. + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) + @NonNull + public List getUnsupportedCountries() { + if (!isEnabled()) { + return Collections.emptyList(); + } + try { + return getIEuiccController().getSupportedCountries(false /* isSupported */); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Returns whether the given country supports eUICC. + * + *

Supported country list has a higher prority than unsupported country list. If the + * supported country list is not empty, {@code countryIso} will be considered as supported when + * it exists in the supported country list. Otherwise {@code countryIso} is not supported. If + * the supported country list is empty, {@code countryIso} will be considered as supported if it + * does not exist in the unsupported country list. Otherwise {@code countryIso} is not + * supported. If both supported and unsupported country lists are empty, then all countries are + * consider be supported. For how to set supported and unsupported country list, please check + * {@link #setSupportedCountries} and {@link #setUnsupportedCountries}. + * + * @param countryIso should be the ISO-3166 country code is provided in uppercase 2 character + * format. + * @return whether the given country supports eUICC or not. + * @hide + */ + @SystemApi + @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) + public boolean isSupportedCountry(@NonNull String countryIso) { + if (!isEnabled()) { + return false; + } + try { + return getIEuiccController().isSupportedCountry(countryIso.toUpperCase()); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + /** * Refreshes the cardId if its uninitialized, and returns whether we should continue the * operation. diff --git a/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl b/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl index 7422863d862c1..35e8a12e898a9 100644 --- a/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl +++ b/telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl @@ -21,6 +21,7 @@ import android.content.Intent; import android.os.Bundle; import android.telephony.euicc.DownloadableSubscription; import android.telephony.euicc.EuiccInfo; +import java.util.List; /** @hide */ interface IEuiccController { @@ -47,4 +48,7 @@ interface IEuiccController { oneway void eraseSubscriptionsWithOptions( int cardId, int options, in PendingIntent callbackIntent); oneway void retainSubscriptionsForFactoryReset(int cardId, in PendingIntent callbackIntent); + void setSupportedCountries(boolean isSupported, in List countriesList); + List getSupportedCountries(boolean isSupported); + boolean isSupportedCountry(String countryIso); }