From 738abf603a254401199b6197867d58792ec5a21b Mon Sep 17 00:00:00 2001 From: Jiashen Wang Date: Mon, 9 Nov 2020 20:28:52 -0800 Subject: Init DownloadableSubscription with Confirmation Code Currently carrier apps are not able to pass the confirmation code along with the downloadable subscription because carrier apps do not have the permission to set the CC. So carrier apps have to rely on LUI's scree for entering the confirmation code. In order to make the process more flexable for carriers, we decided to add a method to initialize a Downloadable Subscription with the confirmation code. Test: ag/13028582 Bug: 169276772 Change-Id: Icfa8b0f5b1699d24d8e39c3297ed25c7d1607739 Merged-In: Icfa8b0f5b1699d24d8e39c3297ed25c7d1607739 --- core/api/current.txt | 8 +++ core/api/system-current.txt | 8 +-- .../telephony/euicc/DownloadableSubscription.java | 57 +++++++++++++++++++--- 3 files changed, 60 insertions(+), 13 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index b0534a141520..3274d02d9bf4 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -41712,6 +41712,14 @@ package android.telephony.euicc { field @NonNull public static final android.os.Parcelable.Creator CREATOR; } + public static final class DownloadableSubscription.Builder { + ctor public DownloadableSubscription.Builder(@NonNull android.telephony.euicc.DownloadableSubscription); + ctor public DownloadableSubscription.Builder(@NonNull String); + method @NonNull public android.telephony.euicc.DownloadableSubscription build(); + method @NonNull public android.telephony.euicc.DownloadableSubscription.Builder setConfirmationCode(@NonNull String); + method @NonNull public android.telephony.euicc.DownloadableSubscription.Builder setEncodedActivationCode(@NonNull String); + } + public final class EuiccInfo implements android.os.Parcelable { ctor public EuiccInfo(@Nullable String); method public int describeContents(); diff --git a/core/api/system-current.txt b/core/api/system-current.txt index ea2370987971..c8f09fc52e7d 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -10878,12 +10878,8 @@ package android.telephony.euicc { public static final class DownloadableSubscription.Builder { ctor public DownloadableSubscription.Builder(); - ctor public DownloadableSubscription.Builder(android.telephony.euicc.DownloadableSubscription); - method public android.telephony.euicc.DownloadableSubscription build(); - method public android.telephony.euicc.DownloadableSubscription.Builder setAccessRules(java.util.List); - method public android.telephony.euicc.DownloadableSubscription.Builder setCarrierName(String); - method public android.telephony.euicc.DownloadableSubscription.Builder setConfirmationCode(String); - method public android.telephony.euicc.DownloadableSubscription.Builder setEncodedActivationCode(String); + method @NonNull public android.telephony.euicc.DownloadableSubscription.Builder setAccessRules(@NonNull java.util.List); + method @NonNull public android.telephony.euicc.DownloadableSubscription.Builder setCarrierName(@NonNull String); } public class EuiccCardManager { diff --git a/telephony/java/android/telephony/euicc/DownloadableSubscription.java b/telephony/java/android/telephony/euicc/DownloadableSubscription.java index 52b31d7f9611..34120790b25a 100644 --- a/telephony/java/android/telephony/euicc/DownloadableSubscription.java +++ b/telephony/java/android/telephony/euicc/DownloadableSubscription.java @@ -15,6 +15,7 @@ */ package android.telephony.euicc; +import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; import android.app.PendingIntent; @@ -102,44 +103,86 @@ public final class DownloadableSubscription implements Parcelable { this.accessRules = accessRules; } - /** @hide */ - @SystemApi public static final class Builder { @Nullable private String encodedActivationCode; @Nullable private String confirmationCode; @Nullable private String carrierName; List accessRules; + /** @hide */ + @SystemApi public Builder() {} - public Builder(DownloadableSubscription baseSubscription) { + public Builder(@NonNull DownloadableSubscription baseSubscription) { encodedActivationCode = baseSubscription.getEncodedActivationCode(); confirmationCode = baseSubscription.getConfirmationCode(); carrierName = baseSubscription.getCarrierName(); accessRules = baseSubscription.getAccessRules(); } + public Builder(@NonNull String encodedActivationCode) { + Preconditions.checkNotNull(encodedActivationCode, "Activation code may not be null"); + this.encodedActivationCode = encodedActivationCode; + } + + /** + * Builds a {@link DownloadableSubscription} object. If the encoded activation code is + * {@code null}, a {@link NullPointerException} will be thrown. + * @return a non-null {@link DownloadableSubscription} object. + */ + @NonNull public DownloadableSubscription build() { + Preconditions.checkNotNull(encodedActivationCode, "Activation code may not be null"); return new DownloadableSubscription(encodedActivationCode, confirmationCode, carrierName, accessRules); } - public Builder setEncodedActivationCode(String value) { + /** + * Sets the encoded activation code. If the encoded activation code is {@code null}, a + * {@link NullPointerException} will be thrown. + * @param value the activation code to use. An activation code can be parsed from a user + * scanned QR code. The format of activation code is defined in SGP.22. For + * example, "1$SMDP.GSMA.COM$04386-AGYFT-A74Y8-3F815$1.3.6.1.4.1.31746". For + * detail, see {@code com.android.euicc.data.ActivationCode}. Must not be null. + */ + @NonNull + public Builder setEncodedActivationCode(@NonNull String value) { + Preconditions.checkNotNull(encodedActivationCode, "Activation code may not be null"); encodedActivationCode = value; return this; } - public Builder setConfirmationCode(String value) { + /** + * Sets the confirmation code. + * @param value the confirmation code to use to authenticate the carrier server got + * subscription download. + */ + @NonNull + public Builder setConfirmationCode(@NonNull String value) { confirmationCode = value; return this; } - public Builder setCarrierName(String value) { + /** + * Sets the user-visible carrier name. + * @param value carrier name. + * @hide + */ + @NonNull + @SystemApi + public Builder setCarrierName(@NonNull String value) { carrierName = value; return this; } - public Builder setAccessRules(List value) { + /** + * Sets the {@link UiccAccessRule}s dictating access to this subscription. + * @param value A list of {@link UiccAccessRule}s. + * @hide + */ + @NonNull + @SystemApi + public Builder setAccessRules(@NonNull List value) { accessRules = value; return this; } -- cgit v1.2.3-59-g8ed1b