Loading telephony/java/android/telephony/euicc/EuiccManager.java +31 −19 Original line number Original line Diff line number Diff line Loading @@ -253,7 +253,7 @@ public class EuiccManager { public static final int EUICC_OTA_STATUS_UNAVAILABLE = 5; public static final int EUICC_OTA_STATUS_UNAVAILABLE = 5; private final Context mContext; private final Context mContext; private final int mCardId; private int mCardId; /** @hide */ /** @hide */ public EuiccManager(Context context) { public EuiccManager(Context context) { Loading Loading @@ -291,7 +291,7 @@ public class EuiccManager { public boolean isEnabled() { public boolean isEnabled() { // In the future, this may reach out to IEuiccController (if non-null) to check any dynamic // In the future, this may reach out to IEuiccController (if non-null) to check any dynamic // restrictions. // restrictions. return getIEuiccController() != null && mCardId != TelephonyManager.INVALID_CARD_ID; return getIEuiccController() != null; } } /** /** Loading @@ -301,11 +301,11 @@ public class EuiccManager { * current eUICC. A calling app with carrier privileges for one eUICC may not necessarily have * current eUICC. A calling app with carrier privileges for one eUICC may not necessarily have * access to the EID of another eUICC. * access to the EID of another eUICC. * * * @return the EID. May be null if {@link #isEnabled()} is false or the eUICC is not ready. * @return the EID. May be null if the eUICC is not ready. */ */ @Nullable @Nullable public String getEid() { public String getEid() { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { return null; return null; } } try { try { Loading @@ -320,7 +320,7 @@ public class EuiccManager { * * * <p>Requires the {@link android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. * <p>Requires the {@link android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. * * * @return the status of eUICC OTA. If {@link #isEnabled()} is false or the eUICC is not ready, * @return the status of eUICC OTA. If the eUICC is not ready, * {@link OtaStatus#EUICC_OTA_STATUS_UNAVAILABLE} will be returned. * {@link OtaStatus#EUICC_OTA_STATUS_UNAVAILABLE} will be returned. * * * @hide * @hide Loading @@ -328,7 +328,7 @@ public class EuiccManager { @SystemApi @SystemApi @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public int getOtaStatus() { public int getOtaStatus() { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { return EUICC_OTA_STATUS_UNAVAILABLE; return EUICC_OTA_STATUS_UNAVAILABLE; } } try { try { Loading Loading @@ -363,7 +363,7 @@ public class EuiccManager { @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void downloadSubscription(DownloadableSubscription subscription, public void downloadSubscription(DownloadableSubscription subscription, boolean switchAfterDownload, PendingIntent callbackIntent) { boolean switchAfterDownload, PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading Loading @@ -425,7 +425,7 @@ public class EuiccManager { @SystemApi @SystemApi @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void continueOperation(Intent resolutionIntent, Bundle resolutionExtras) { public void continueOperation(Intent resolutionIntent, Bundle resolutionExtras) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { PendingIntent callbackIntent = PendingIntent callbackIntent = resolutionIntent.getParcelableExtra( resolutionIntent.getParcelableExtra( EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_CALLBACK_INTENT); EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_CALLBACK_INTENT); Loading Loading @@ -462,7 +462,7 @@ public class EuiccManager { @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void getDownloadableSubscriptionMetadata( public void getDownloadableSubscriptionMetadata( DownloadableSubscription subscription, PendingIntent callbackIntent) { DownloadableSubscription subscription, PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading Loading @@ -492,7 +492,7 @@ public class EuiccManager { @SystemApi @SystemApi @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void getDefaultDownloadableSubscriptionList(PendingIntent callbackIntent) { public void getDefaultDownloadableSubscriptionList(PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading @@ -507,12 +507,11 @@ public class EuiccManager { /** /** * Returns information about the eUICC chip/device. * Returns information about the eUICC chip/device. * * * @return the {@link EuiccInfo}. May be null if {@link #isEnabled()} is false or the eUICC is * @return the {@link EuiccInfo}. May be null if the eUICC is not ready. * not ready. */ */ @Nullable @Nullable public EuiccInfo getEuiccInfo() { public EuiccInfo getEuiccInfo() { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { return null; return null; } } try { try { Loading @@ -537,7 +536,7 @@ public class EuiccManager { */ */ @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void deleteSubscription(int subscriptionId, PendingIntent callbackIntent) { public void deleteSubscription(int subscriptionId, PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading Loading @@ -577,7 +576,7 @@ public class EuiccManager { */ */ @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void switchToSubscription(int subscriptionId, PendingIntent callbackIntent) { public void switchToSubscription(int subscriptionId, PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading @@ -603,7 +602,7 @@ public class EuiccManager { @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void updateSubscriptionNickname( public void updateSubscriptionNickname( int subscriptionId, String nickname, PendingIntent callbackIntent) { int subscriptionId, String nickname, PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading @@ -627,7 +626,7 @@ public class EuiccManager { @SystemApi @SystemApi @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void eraseSubscriptions(PendingIntent callbackIntent) { public void eraseSubscriptions(PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading Loading @@ -657,7 +656,7 @@ public class EuiccManager { * @hide * @hide */ */ public void retainSubscriptionsForFactoryReset(PendingIntent callbackIntent) { public void retainSubscriptionsForFactoryReset(PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading @@ -668,6 +667,19 @@ public class EuiccManager { } } } } private boolean refreshCardIdIfInvalid() { if (!isEnabled()) { return false; } // Refresh mCardId if it's invalid. if (mCardId == TelephonyManager.INVALID_CARD_ID) { TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); mCardId = tm.getCardIdForDefaultEuicc(); } return true; } private static void sendUnavailableError(PendingIntent callbackIntent) { private static void sendUnavailableError(PendingIntent callbackIntent) { try { try { callbackIntent.send(EMBEDDED_SUBSCRIPTION_RESULT_ERROR); callbackIntent.send(EMBEDDED_SUBSCRIPTION_RESULT_ERROR); Loading Loading
telephony/java/android/telephony/euicc/EuiccManager.java +31 −19 Original line number Original line Diff line number Diff line Loading @@ -253,7 +253,7 @@ public class EuiccManager { public static final int EUICC_OTA_STATUS_UNAVAILABLE = 5; public static final int EUICC_OTA_STATUS_UNAVAILABLE = 5; private final Context mContext; private final Context mContext; private final int mCardId; private int mCardId; /** @hide */ /** @hide */ public EuiccManager(Context context) { public EuiccManager(Context context) { Loading Loading @@ -291,7 +291,7 @@ public class EuiccManager { public boolean isEnabled() { public boolean isEnabled() { // In the future, this may reach out to IEuiccController (if non-null) to check any dynamic // In the future, this may reach out to IEuiccController (if non-null) to check any dynamic // restrictions. // restrictions. return getIEuiccController() != null && mCardId != TelephonyManager.INVALID_CARD_ID; return getIEuiccController() != null; } } /** /** Loading @@ -301,11 +301,11 @@ public class EuiccManager { * current eUICC. A calling app with carrier privileges for one eUICC may not necessarily have * current eUICC. A calling app with carrier privileges for one eUICC may not necessarily have * access to the EID of another eUICC. * access to the EID of another eUICC. * * * @return the EID. May be null if {@link #isEnabled()} is false or the eUICC is not ready. * @return the EID. May be null if the eUICC is not ready. */ */ @Nullable @Nullable public String getEid() { public String getEid() { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { return null; return null; } } try { try { Loading @@ -320,7 +320,7 @@ public class EuiccManager { * * * <p>Requires the {@link android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. * <p>Requires the {@link android.Manifest.permission#WRITE_EMBEDDED_SUBSCRIPTIONS} permission. * * * @return the status of eUICC OTA. If {@link #isEnabled()} is false or the eUICC is not ready, * @return the status of eUICC OTA. If the eUICC is not ready, * {@link OtaStatus#EUICC_OTA_STATUS_UNAVAILABLE} will be returned. * {@link OtaStatus#EUICC_OTA_STATUS_UNAVAILABLE} will be returned. * * * @hide * @hide Loading @@ -328,7 +328,7 @@ public class EuiccManager { @SystemApi @SystemApi @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public int getOtaStatus() { public int getOtaStatus() { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { return EUICC_OTA_STATUS_UNAVAILABLE; return EUICC_OTA_STATUS_UNAVAILABLE; } } try { try { Loading Loading @@ -363,7 +363,7 @@ public class EuiccManager { @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void downloadSubscription(DownloadableSubscription subscription, public void downloadSubscription(DownloadableSubscription subscription, boolean switchAfterDownload, PendingIntent callbackIntent) { boolean switchAfterDownload, PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading Loading @@ -425,7 +425,7 @@ public class EuiccManager { @SystemApi @SystemApi @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void continueOperation(Intent resolutionIntent, Bundle resolutionExtras) { public void continueOperation(Intent resolutionIntent, Bundle resolutionExtras) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { PendingIntent callbackIntent = PendingIntent callbackIntent = resolutionIntent.getParcelableExtra( resolutionIntent.getParcelableExtra( EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_CALLBACK_INTENT); EuiccManager.EXTRA_EMBEDDED_SUBSCRIPTION_RESOLUTION_CALLBACK_INTENT); Loading Loading @@ -462,7 +462,7 @@ public class EuiccManager { @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void getDownloadableSubscriptionMetadata( public void getDownloadableSubscriptionMetadata( DownloadableSubscription subscription, PendingIntent callbackIntent) { DownloadableSubscription subscription, PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading Loading @@ -492,7 +492,7 @@ public class EuiccManager { @SystemApi @SystemApi @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void getDefaultDownloadableSubscriptionList(PendingIntent callbackIntent) { public void getDefaultDownloadableSubscriptionList(PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading @@ -507,12 +507,11 @@ public class EuiccManager { /** /** * Returns information about the eUICC chip/device. * Returns information about the eUICC chip/device. * * * @return the {@link EuiccInfo}. May be null if {@link #isEnabled()} is false or the eUICC is * @return the {@link EuiccInfo}. May be null if the eUICC is not ready. * not ready. */ */ @Nullable @Nullable public EuiccInfo getEuiccInfo() { public EuiccInfo getEuiccInfo() { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { return null; return null; } } try { try { Loading @@ -537,7 +536,7 @@ public class EuiccManager { */ */ @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void deleteSubscription(int subscriptionId, PendingIntent callbackIntent) { public void deleteSubscription(int subscriptionId, PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading Loading @@ -577,7 +576,7 @@ public class EuiccManager { */ */ @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void switchToSubscription(int subscriptionId, PendingIntent callbackIntent) { public void switchToSubscription(int subscriptionId, PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading @@ -603,7 +602,7 @@ public class EuiccManager { @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void updateSubscriptionNickname( public void updateSubscriptionNickname( int subscriptionId, String nickname, PendingIntent callbackIntent) { int subscriptionId, String nickname, PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading @@ -627,7 +626,7 @@ public class EuiccManager { @SystemApi @SystemApi @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) @RequiresPermission(Manifest.permission.WRITE_EMBEDDED_SUBSCRIPTIONS) public void eraseSubscriptions(PendingIntent callbackIntent) { public void eraseSubscriptions(PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading Loading @@ -657,7 +656,7 @@ public class EuiccManager { * @hide * @hide */ */ public void retainSubscriptionsForFactoryReset(PendingIntent callbackIntent) { public void retainSubscriptionsForFactoryReset(PendingIntent callbackIntent) { if (!isEnabled()) { if (!refreshCardIdIfInvalid()) { sendUnavailableError(callbackIntent); sendUnavailableError(callbackIntent); return; return; } } Loading @@ -668,6 +667,19 @@ public class EuiccManager { } } } } private boolean refreshCardIdIfInvalid() { if (!isEnabled()) { return false; } // Refresh mCardId if it's invalid. if (mCardId == TelephonyManager.INVALID_CARD_ID) { TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); mCardId = tm.getCardIdForDefaultEuicc(); } return true; } private static void sendUnavailableError(PendingIntent callbackIntent) { private static void sendUnavailableError(PendingIntent callbackIntent) { try { try { callbackIntent.send(EMBEDDED_SUBSCRIPTION_RESULT_ERROR); callbackIntent.send(EMBEDDED_SUBSCRIPTION_RESULT_ERROR); Loading