diff --git a/core/api/system-current.txt b/core/api/system-current.txt index ceed59f794642..e1c0d2f58d1c1 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -11773,6 +11773,7 @@ package android.service.euicc { method public int onEraseSubscriptions(int, @android.telephony.euicc.EuiccCardManager.ResetOption int); method public abstract android.service.euicc.GetDefaultDownloadableSubscriptionListResult onGetDefaultDownloadableSubscriptionList(int, boolean); method public abstract android.service.euicc.GetDownloadableSubscriptionMetadataResult onGetDownloadableSubscriptionMetadata(int, android.telephony.euicc.DownloadableSubscription, boolean); + method @NonNull public android.service.euicc.GetDownloadableSubscriptionMetadataResult onGetDownloadableSubscriptionMetadata(int, int, @NonNull android.telephony.euicc.DownloadableSubscription, boolean); method public abstract String onGetEid(int); method @NonNull public abstract android.telephony.euicc.EuiccInfo onGetEuiccInfo(int); method @NonNull public abstract android.service.euicc.GetEuiccProfileInfoListResult onGetEuiccProfileInfoList(int); diff --git a/telephony/java/android/service/euicc/EuiccService.java b/telephony/java/android/service/euicc/EuiccService.java index e19117bc805f2..2c0087eaabf47 100644 --- a/telephony/java/android/service/euicc/EuiccService.java +++ b/telephony/java/android/service/euicc/EuiccService.java @@ -489,6 +489,28 @@ public abstract class EuiccService extends Service { public abstract GetDownloadableSubscriptionMetadataResult onGetDownloadableSubscriptionMetadata( int slotId, DownloadableSubscription subscription, boolean forceDeactivateSim); + /** + * Populate {@link DownloadableSubscription} metadata for the given downloadable subscription. + * + * @param slotId ID of the SIM slot to use for the operation. + * @param portIndex Index of the port from the slot. portIndex is used if the eUICC must + * be activated to perform the operation. + * @param subscription A subscription whose metadata needs to be populated. + * @param forceDeactivateSim If true, and if an active SIM must be deactivated to access the + * eUICC, perform this action automatically. Otherwise, {@link #RESULT_MUST_DEACTIVATE_SIM} + * should be returned to allow the user to consent to this operation first. + * @return The result of the operation. + * @see android.telephony.euicc.EuiccManager#getDownloadableSubscriptionMetadata + */ + @NonNull + public GetDownloadableSubscriptionMetadataResult onGetDownloadableSubscriptionMetadata( + int slotId, int portIndex, @NonNull DownloadableSubscription subscription, + boolean forceDeactivateSim) { + // stub implementation, LPA needs to implement this + throw new UnsupportedOperationException( + "LPA must override onGetDownloadableSubscriptionMetadata"); + } + /** * Return metadata for subscriptions which are available for download for this device. * @@ -833,16 +855,31 @@ public abstract class EuiccService extends Service { } @Override - public void getDownloadableSubscriptionMetadata(int slotId, + public void getDownloadableSubscriptionMetadata(int slotId, int portIndex, DownloadableSubscription subscription, - boolean forceDeactivateSim, + boolean switchAfterDownload, boolean forceDeactivateSim, IGetDownloadableSubscriptionMetadataCallback callback) { mExecutor.execute(new Runnable() { @Override public void run() { - GetDownloadableSubscriptionMetadataResult result = - EuiccService.this.onGetDownloadableSubscriptionMetadata( + GetDownloadableSubscriptionMetadataResult result; + if (switchAfterDownload) { + try { + result = EuiccService.this.onGetDownloadableSubscriptionMetadata( + slotId, portIndex, subscription, forceDeactivateSim); + } catch (UnsupportedOperationException | AbstractMethodError e) { + Log.w(TAG, "The new onGetDownloadableSubscriptionMetadata(int, int, " + + "DownloadableSubscription, boolean) is not implemented." + + " Fall back to the old one.", e); + result = EuiccService.this.onGetDownloadableSubscriptionMetadata( slotId, subscription, forceDeactivateSim); + } + } else { + // When switchAfterDownload is false, this operation is port agnostic. + // Call API without portIndex. + result = EuiccService.this.onGetDownloadableSubscriptionMetadata( + slotId, subscription, forceDeactivateSim); + } try { callback.onComplete(result); } catch (RemoteException e) { diff --git a/telephony/java/android/service/euicc/IEuiccService.aidl b/telephony/java/android/service/euicc/IEuiccService.aidl index 6b0397d67015e..f8d5ae9ca86dd 100644 --- a/telephony/java/android/service/euicc/IEuiccService.aidl +++ b/telephony/java/android/service/euicc/IEuiccService.aidl @@ -38,8 +38,10 @@ oneway interface IEuiccService { void downloadSubscription(int slotId, int portIndex, in DownloadableSubscription subscription, boolean switchAfterDownload, boolean forceDeactivateSim, in Bundle resolvedBundle, in IDownloadSubscriptionCallback callback); - void getDownloadableSubscriptionMetadata(int slotId, in DownloadableSubscription subscription, - boolean forceDeactivateSim, in IGetDownloadableSubscriptionMetadataCallback callback); + void getDownloadableSubscriptionMetadata( + int slotId, int portIndex, in DownloadableSubscription subscription, + boolean switchAfterDownload, boolean forceDeactivateSim, + in IGetDownloadableSubscriptionMetadataCallback callback); void getEid(int slotId, in IGetEidCallback callback); void getOtaStatus(int slotId, in IGetOtaStatusCallback callback); void startOtaIfNecessary(int slotId, in IOtaStatusChangedCallback statusChangedCallback);