summaryrefslogtreecommitdiff
path: root/telephony/java
diff options
context:
space:
mode:
Diffstat (limited to 'telephony/java')
-rw-r--r--telephony/java/android/service/euicc/DownloadSubscriptionResult.aidl19
-rw-r--r--telephony/java/android/service/euicc/DownloadSubscriptionResult.java99
-rw-r--r--telephony/java/android/service/euicc/EuiccProfileInfo.aidl18
-rw-r--r--telephony/java/android/service/euicc/EuiccProfileInfo.java455
-rw-r--r--telephony/java/android/service/euicc/EuiccService.java838
-rw-r--r--telephony/java/android/service/euicc/GetDefaultDownloadableSubscriptionListResult.aidl19
-rw-r--r--telephony/java/android/service/euicc/GetDefaultDownloadableSubscriptionListResult.java118
-rw-r--r--telephony/java/android/service/euicc/GetDownloadableSubscriptionMetadataResult.aidl19
-rw-r--r--telephony/java/android/service/euicc/GetDownloadableSubscriptionMetadataResult.java114
-rw-r--r--telephony/java/android/service/euicc/GetEuiccProfileInfoListResult.aidl19
-rw-r--r--telephony/java/android/service/euicc/GetEuiccProfileInfoListResult.java126
-rw-r--r--telephony/java/android/service/euicc/IDeleteSubscriptionCallback.aidl23
-rw-r--r--telephony/java/android/service/euicc/IDownloadSubscriptionCallback.aidl24
-rw-r--r--telephony/java/android/service/euicc/IEraseSubscriptionsCallback.aidl23
-rw-r--r--telephony/java/android/service/euicc/IEuiccService.aidl59
-rw-r--r--telephony/java/android/service/euicc/IGetDefaultDownloadableSubscriptionListCallback.aidl25
-rw-r--r--telephony/java/android/service/euicc/IGetDownloadableSubscriptionMetadataCallback.aidl25
-rw-r--r--telephony/java/android/service/euicc/IGetEidCallback.aidl23
-rw-r--r--telephony/java/android/service/euicc/IGetEuiccInfoCallback.aidl25
-rw-r--r--telephony/java/android/service/euicc/IGetEuiccProfileInfoListCallback.aidl25
-rw-r--r--telephony/java/android/service/euicc/IGetOtaStatusCallback.aidl22
-rw-r--r--telephony/java/android/service/euicc/IOtaStatusChangedCallback.aidl22
-rw-r--r--telephony/java/android/service/euicc/IRetainSubscriptionsForFactoryResetCallback.aidl23
-rw-r--r--telephony/java/android/service/euicc/ISwitchToSubscriptionCallback.aidl23
-rw-r--r--telephony/java/android/service/euicc/IUpdateSubscriptionNicknameCallback.aidl23
25 files changed, 2209 insertions, 0 deletions
diff --git a/telephony/java/android/service/euicc/DownloadSubscriptionResult.aidl b/telephony/java/android/service/euicc/DownloadSubscriptionResult.aidl
new file mode 100644
index 000000000000..b625fd6d3cb4
--- /dev/null
+++ b/telephony/java/android/service/euicc/DownloadSubscriptionResult.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+parcelable DownloadSubscriptionResult;
diff --git a/telephony/java/android/service/euicc/DownloadSubscriptionResult.java b/telephony/java/android/service/euicc/DownloadSubscriptionResult.java
new file mode 100644
index 000000000000..3b1a2c9def4f
--- /dev/null
+++ b/telephony/java/android/service/euicc/DownloadSubscriptionResult.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.service.euicc;
+
+import android.annotation.SystemApi;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.service.euicc.EuiccService.ResolvableError;
+import android.service.euicc.EuiccService.Result;
+
+/**
+ * Result of a {@link EuiccService#onDownloadSubscription} operation.
+ * @hide
+ */
+@SystemApi
+public final class DownloadSubscriptionResult implements Parcelable {
+
+ public static final @android.annotation.NonNull Creator<DownloadSubscriptionResult> CREATOR =
+ new Creator<DownloadSubscriptionResult>() {
+ @Override
+ public DownloadSubscriptionResult createFromParcel(Parcel in) {
+ return new DownloadSubscriptionResult(in);
+ }
+
+ @Override
+ public DownloadSubscriptionResult[] newArray(int size) {
+ return new DownloadSubscriptionResult[size];
+ }
+ };
+
+ private final @Result int mResult;
+ private final @ResolvableError int mResolvableErrors;
+ private final int mCardId;
+
+ public DownloadSubscriptionResult(@Result int result, @ResolvableError int resolvableErrors,
+ int cardId) {
+ this.mResult = result;
+ this.mResolvableErrors = resolvableErrors;
+ this.mCardId = cardId;
+ }
+
+ /** Gets the result of the operation. */
+ public @Result int getResult() {
+ return mResult;
+ }
+
+ /**
+ * Gets the bit map of resolvable errors.
+ *
+ * <p>The value is passed from EuiccService. The values can be
+ *
+ * <ul>
+ * <li>{@link EuiccService#RESOLVABLE_ERROR_CONFIRMATION_CODE}
+ * <li>{@link EuiccService#RESOLVABLE_ERROR_POLICY_RULES}
+ * </ul>
+ */
+ public @ResolvableError int getResolvableErrors() {
+ return mResolvableErrors;
+ }
+
+ /**
+ * Gets the card Id. This is used when resolving resolvable errors. The value is passed from
+ * EuiccService.
+ */
+ public int getCardId() {
+ return mCardId;
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mResult);
+ dest.writeInt(mResolvableErrors);
+ dest.writeInt(mCardId);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ private DownloadSubscriptionResult(Parcel in) {
+ this.mResult = in.readInt();
+ this.mResolvableErrors = in.readInt();
+ this.mCardId = in.readInt();
+ }
+}
diff --git a/telephony/java/android/service/euicc/EuiccProfileInfo.aidl b/telephony/java/android/service/euicc/EuiccProfileInfo.aidl
new file mode 100644
index 000000000000..321021b5273c
--- /dev/null
+++ b/telephony/java/android/service/euicc/EuiccProfileInfo.aidl
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.service.euicc;
+
+parcelable EuiccProfileInfo;
diff --git a/telephony/java/android/service/euicc/EuiccProfileInfo.java b/telephony/java/android/service/euicc/EuiccProfileInfo.java
new file mode 100644
index 000000000000..6c357ccdd03d
--- /dev/null
+++ b/telephony/java/android/service/euicc/EuiccProfileInfo.java
@@ -0,0 +1,455 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.service.euicc;
+
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.annotation.UnsupportedAppUsage;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.service.carrier.CarrierIdentifier;
+import android.telephony.UiccAccessRule;
+import android.text.TextUtils;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * Information about an embedded profile (subscription) on an eUICC.
+ *
+ * @hide
+ */
+@SystemApi
+public final class EuiccProfileInfo implements Parcelable {
+
+ /** Profile policy rules (bit mask) */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(flag = true, prefix = { "POLICY_RULE_" }, value = {
+ POLICY_RULE_DO_NOT_DISABLE,
+ POLICY_RULE_DO_NOT_DELETE,
+ POLICY_RULE_DELETE_AFTER_DISABLING
+ })
+ /** @hide */
+ public @interface PolicyRule {}
+ /** Once this profile is enabled, it cannot be disabled. */
+ public static final int POLICY_RULE_DO_NOT_DISABLE = 1;
+ /** This profile cannot be deleted. */
+ public static final int POLICY_RULE_DO_NOT_DELETE = 1 << 1;
+ /** This profile should be deleted after being disabled. */
+ public static final int POLICY_RULE_DELETE_AFTER_DISABLING = 1 << 2;
+
+ /** Class of the profile */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = { "PROFILE_CLASS_" }, value = {
+ PROFILE_CLASS_TESTING,
+ PROFILE_CLASS_PROVISIONING,
+ PROFILE_CLASS_OPERATIONAL,
+ PROFILE_CLASS_UNSET
+ })
+ /** @hide */
+ public @interface ProfileClass {}
+ /** Testing profiles */
+ public static final int PROFILE_CLASS_TESTING = 0;
+ /** Provisioning profiles which are pre-loaded on eUICC */
+ public static final int PROFILE_CLASS_PROVISIONING = 1;
+ /** Operational profiles which can be pre-loaded or downloaded */
+ public static final int PROFILE_CLASS_OPERATIONAL = 2;
+ /**
+ * Profile class not set.
+ * @hide
+ */
+ public static final int PROFILE_CLASS_UNSET = -1;
+
+ /** State of the profile */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = { "PROFILE_STATE_" }, value = {
+ PROFILE_STATE_DISABLED,
+ PROFILE_STATE_ENABLED,
+ PROFILE_STATE_UNSET
+ })
+ /** @hide */
+ public @interface ProfileState {}
+ /** Disabled profiles */
+ public static final int PROFILE_STATE_DISABLED = 0;
+ /** Enabled profile */
+ public static final int PROFILE_STATE_ENABLED = 1;
+ /**
+ * Profile state not set.
+ * @hide
+ */
+ public static final int PROFILE_STATE_UNSET = -1;
+
+ /** The iccid of the subscription. */
+ private final String mIccid;
+
+ /** An optional nickname for the subscription. */
+ private final @Nullable String mNickname;
+
+ /** The service provider name for the subscription. */
+ private final String mServiceProviderName;
+
+ /** The profile name for the subscription. */
+ private final String mProfileName;
+
+ /** Profile class for the subscription. */
+ @ProfileClass private final int mProfileClass;
+
+ /** The profile state of the subscription. */
+ @ProfileState private final int mState;
+
+ /** The operator Id of the subscription. */
+ private final CarrierIdentifier mCarrierIdentifier;
+
+ /** The policy rules of the subscription. */
+ @PolicyRule private final int mPolicyRules;
+
+ /**
+ * Optional access rules defining which apps can manage this subscription. If unset, only the
+ * platform can manage it.
+ */
+ private final @Nullable UiccAccessRule[] mAccessRules;
+
+ public static final @android.annotation.NonNull Creator<EuiccProfileInfo> CREATOR = new Creator<EuiccProfileInfo>() {
+ @Override
+ public EuiccProfileInfo createFromParcel(Parcel in) {
+ return new EuiccProfileInfo(in);
+ }
+
+ @Override
+ public EuiccProfileInfo[] newArray(int size) {
+ return new EuiccProfileInfo[size];
+ }
+ };
+
+ // TODO(b/70292228): Remove this method when LPA can be updated.
+ /**
+ * @hide
+ * @deprecated - Do not use.
+ */
+ @Deprecated
+ @UnsupportedAppUsage
+ public EuiccProfileInfo(String iccid, @Nullable UiccAccessRule[] accessRules,
+ @Nullable String nickname) {
+ if (!TextUtils.isDigitsOnly(iccid)) {
+ throw new IllegalArgumentException("iccid contains invalid characters: " + iccid);
+ }
+ this.mIccid = iccid;
+ this.mAccessRules = accessRules;
+ this.mNickname = nickname;
+
+ this.mServiceProviderName = null;
+ this.mProfileName = null;
+ this.mProfileClass = PROFILE_CLASS_UNSET;
+ this.mState = PROFILE_STATE_UNSET;
+ this.mCarrierIdentifier = null;
+ this.mPolicyRules = 0;
+ }
+
+ private EuiccProfileInfo(Parcel in) {
+ mIccid = in.readString();
+ mNickname = in.readString();
+ mServiceProviderName = in.readString();
+ mProfileName = in.readString();
+ mProfileClass = in.readInt();
+ mState = in.readInt();
+ byte exist = in.readByte();
+ if (exist == (byte) 1) {
+ mCarrierIdentifier = CarrierIdentifier.CREATOR.createFromParcel(in);
+ } else {
+ mCarrierIdentifier = null;
+ }
+ mPolicyRules = in.readInt();
+ mAccessRules = in.createTypedArray(UiccAccessRule.CREATOR);
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeString(mIccid);
+ dest.writeString(mNickname);
+ dest.writeString(mServiceProviderName);
+ dest.writeString(mProfileName);
+ dest.writeInt(mProfileClass);
+ dest.writeInt(mState);
+ if (mCarrierIdentifier != null) {
+ dest.writeByte((byte) 1);
+ mCarrierIdentifier.writeToParcel(dest, flags);
+ } else {
+ dest.writeByte((byte) 0);
+ }
+ dest.writeInt(mPolicyRules);
+ dest.writeTypedArray(mAccessRules, flags);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ /** The builder to build a new {@link EuiccProfileInfo} instance. */
+ public static final class Builder {
+ private String mIccid;
+ private List<UiccAccessRule> mAccessRules;
+ private String mNickname;
+ private String mServiceProviderName;
+ private String mProfileName;
+ @ProfileClass private int mProfileClass;
+ @ProfileState private int mState;
+ private CarrierIdentifier mCarrierIdentifier;
+ @PolicyRule private int mPolicyRules;
+
+ public Builder(String value) {
+ if (!TextUtils.isDigitsOnly(value)) {
+ throw new IllegalArgumentException("iccid contains invalid characters: " + value);
+ }
+ mIccid = value;
+ }
+
+ public Builder(EuiccProfileInfo baseProfile) {
+ mIccid = baseProfile.mIccid;
+ mNickname = baseProfile.mNickname;
+ mServiceProviderName = baseProfile.mServiceProviderName;
+ mProfileName = baseProfile.mProfileName;
+ mProfileClass = baseProfile.mProfileClass;
+ mState = baseProfile.mState;
+ mCarrierIdentifier = baseProfile.mCarrierIdentifier;
+ mPolicyRules = baseProfile.mPolicyRules;
+ mAccessRules = Arrays.asList(baseProfile.mAccessRules);
+ }
+
+ /** Builds the profile instance. */
+ public EuiccProfileInfo build() {
+ if (mIccid == null) {
+ throw new IllegalStateException("ICCID must be set for a profile.");
+ }
+ return new EuiccProfileInfo(
+ mIccid,
+ mNickname,
+ mServiceProviderName,
+ mProfileName,
+ mProfileClass,
+ mState,
+ mCarrierIdentifier,
+ mPolicyRules,
+ mAccessRules);
+ }
+
+ /** Sets the iccId of the subscription. */
+ public Builder setIccid(String value) {
+ if (!TextUtils.isDigitsOnly(value)) {
+ throw new IllegalArgumentException("iccid contains invalid characters: " + value);
+ }
+ mIccid = value;
+ return this;
+ }
+
+ /** Sets the nickname of the subscription. */
+ public Builder setNickname(String value) {
+ mNickname = value;
+ return this;
+ }
+
+ /** Sets the service provider name of the subscription. */
+ public Builder setServiceProviderName(String value) {
+ mServiceProviderName = value;
+ return this;
+ }
+
+ /** Sets the profile name of the subscription. */
+ public Builder setProfileName(String value) {
+ mProfileName = value;
+ return this;
+ }
+
+ /** Sets the profile class of the subscription. */
+ public Builder setProfileClass(@ProfileClass int value) {
+ mProfileClass = value;
+ return this;
+ }
+
+ /** Sets the state of the subscription. */
+ public Builder setState(@ProfileState int value) {
+ mState = value;
+ return this;
+ }
+
+ /** Sets the carrier identifier of the subscription. */
+ public Builder setCarrierIdentifier(CarrierIdentifier value) {
+ mCarrierIdentifier = value;
+ return this;
+ }
+
+ /** Sets the policy rules of the subscription. */
+ public Builder setPolicyRules(@PolicyRule int value) {
+ mPolicyRules = value;
+ return this;
+ }
+
+ /** Sets the access rules of the subscription. */
+ public Builder setUiccAccessRule(@Nullable List<UiccAccessRule> value) {
+ mAccessRules = value;
+ return this;
+ }
+ }
+
+ private EuiccProfileInfo(
+ String iccid,
+ @Nullable String nickname,
+ String serviceProviderName,
+ String profileName,
+ @ProfileClass int profileClass,
+ @ProfileState int state,
+ CarrierIdentifier carrierIdentifier,
+ @PolicyRule int policyRules,
+ @Nullable List<UiccAccessRule> accessRules) {
+ this.mIccid = iccid;
+ this.mNickname = nickname;
+ this.mServiceProviderName = serviceProviderName;
+ this.mProfileName = profileName;
+ this.mProfileClass = profileClass;
+ this.mState = state;
+ this.mCarrierIdentifier = carrierIdentifier;
+ this.mPolicyRules = policyRules;
+ if (accessRules != null && accessRules.size() > 0) {
+ this.mAccessRules = accessRules.toArray(new UiccAccessRule[accessRules.size()]);
+ } else {
+ this.mAccessRules = null;
+ }
+ }
+
+ /** Gets the ICCID string. */
+ public String getIccid() {
+ return mIccid;
+ }
+
+ /** Gets the access rules. */
+ @Nullable
+ public List<UiccAccessRule> getUiccAccessRules() {
+ if (mAccessRules == null) return null;
+ return Arrays.asList(mAccessRules);
+ }
+
+ /** Gets the nickname. */
+ @Nullable
+ public String getNickname() {
+ return mNickname;
+ }
+
+ /** Gets the service provider name. */
+ public String getServiceProviderName() {
+ return mServiceProviderName;
+ }
+
+ /** Gets the profile name. */
+ public String getProfileName() {
+ return mProfileName;
+ }
+
+ /** Gets the profile class. */
+ @ProfileClass
+ public int getProfileClass() {
+ return mProfileClass;
+ }
+
+ /** Gets the state of the subscription. */
+ @ProfileState
+ public int getState() {
+ return mState;
+ }
+
+ /** Gets the carrier identifier. */
+ public CarrierIdentifier getCarrierIdentifier() {
+ return mCarrierIdentifier;
+ }
+
+ /** Gets the policy rules. */
+ @PolicyRule
+ public int getPolicyRules() {
+ return mPolicyRules;
+ }
+
+ /** Returns whether any policy rule exists. */
+ public boolean hasPolicyRules() {
+ return mPolicyRules != 0;
+ }
+
+ /** Checks whether a certain policy rule exists. */
+ public boolean hasPolicyRule(@PolicyRule int policy) {
+ return (mPolicyRules & policy) != 0;
+ }
+
+ @Override
+ public boolean equals(@Nullable Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null || getClass() != obj.getClass()) {
+ return false;
+ }
+
+ EuiccProfileInfo that = (EuiccProfileInfo) obj;
+ return Objects.equals(mIccid, that.mIccid)
+ && Objects.equals(mNickname, that.mNickname)
+ && Objects.equals(mServiceProviderName, that.mServiceProviderName)
+ && Objects.equals(mProfileName, that.mProfileName)
+ && mProfileClass == that.mProfileClass
+ && mState == that.mState
+ && Objects.equals(mCarrierIdentifier, that.mCarrierIdentifier)
+ && mPolicyRules == that.mPolicyRules
+ && Arrays.equals(mAccessRules, that.mAccessRules);
+ }
+
+ @Override
+ public int hashCode() {
+ int result = 1;
+ result = 31 * result + Objects.hashCode(mIccid);
+ result = 31 * result + Objects.hashCode(mNickname);
+ result = 31 * result + Objects.hashCode(mServiceProviderName);
+ result = 31 * result + Objects.hashCode(mProfileName);
+ result = 31 * result + mProfileClass;
+ result = 31 * result + mState;
+ result = 31 * result + Objects.hashCode(mCarrierIdentifier);
+ result = 31 * result + mPolicyRules;
+ result = 31 * result + Arrays.hashCode(mAccessRules);
+ return result;
+ }
+
+ @NonNull
+ @Override
+ public String toString() {
+ return "EuiccProfileInfo (nickname="
+ + mNickname
+ + ", serviceProviderName="
+ + mServiceProviderName
+ + ", profileName="
+ + mProfileName
+ + ", profileClass="
+ + mProfileClass
+ + ", state="
+ + mState
+ + ", CarrierIdentifier="
+ + mCarrierIdentifier
+ + ", policyRules="
+ + mPolicyRules
+ + ", accessRules="
+ + Arrays.toString(mAccessRules)
+ + ")";
+ }
+}
diff --git a/telephony/java/android/service/euicc/EuiccService.java b/telephony/java/android/service/euicc/EuiccService.java
new file mode 100644
index 000000000000..bc6a9e848e2a
--- /dev/null
+++ b/telephony/java/android/service/euicc/EuiccService.java
@@ -0,0 +1,838 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.service.euicc;
+
+import static android.telephony.euicc.EuiccCardManager.ResetOption;
+
+import android.annotation.CallSuper;
+import android.annotation.IntDef;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.annotation.SdkConstant;
+import android.annotation.SystemApi;
+import android.app.Service;
+import android.content.Intent;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.telephony.TelephonyManager;
+import android.telephony.euicc.DownloadableSubscription;
+import android.telephony.euicc.EuiccInfo;
+import android.telephony.euicc.EuiccManager.OtaStatus;
+import android.util.Log;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Service interface linking the system with an eUICC local profile assistant (LPA) application.
+ *
+ * <p>An LPA consists of two separate components (which may both be implemented in the same APK):
+ * the LPA backend, and the LPA UI or LUI.
+ *
+ * <p>To implement the LPA backend, you must extend this class and declare this service in your
+ * manifest file. The service must require the
+ * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission and include an intent filter
+ * with the {@link #EUICC_SERVICE_INTERFACE} action. It's suggested that the priority of the intent
+ * filter to be set to a non-zero value in case multiple implementations are present on the device.
+ * See the below example. Note that there will be problem if two LPAs are present and they have the
+ * same priority.
+ * Example:
+ *
+ * <pre>{@code
+ * <service android:name=".MyEuiccService"
+ * android:permission="android.permission.BIND_EUICC_SERVICE">
+ * <intent-filter android:priority="100">
+ * <action android:name="android.service.euicc.EuiccService" />
+ * </intent-filter>
+ * </service>
+ * }</pre>
+ *
+ * <p>To implement the LUI, you must provide an activity for the following actions:
+ *
+ * <ul>
+ * <li>{@link #ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS}
+ * <li>{@link #ACTION_PROVISION_EMBEDDED_SUBSCRIPTION}
+ * </ul>
+ *
+ * <p>As with the service, each activity must require the
+ * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission. Each should have an intent
+ * filter with the appropriate action, the {@link #CATEGORY_EUICC_UI} category, and a non-zero
+ * priority.
+ *
+ * <p>Old implementations of EuiccService may support passing in slot IDs equal to
+ * {@link android.telephony.SubscriptionManager#INVALID_SIM_SLOT_INDEX}, which allows the LPA to
+ * decide which eUICC to target when there are multiple eUICCs. This behavior is not supported in
+ * Android Q or later.
+ *
+ * @hide
+ */
+@SystemApi
+public abstract class EuiccService extends Service {
+ private static final String TAG = "EuiccService";
+
+ /** Action which must be included in this service's intent filter. */
+ public static final String EUICC_SERVICE_INTERFACE = "android.service.euicc.EuiccService";
+
+ /** Category which must be defined to all UI actions, for efficient lookup. */
+ public static final String CATEGORY_EUICC_UI = "android.service.euicc.category.EUICC_UI";
+
+ // LUI actions. These are passthroughs of the corresponding EuiccManager actions.
+
+ /**
+ * Action used to bind the carrier app and get the activation code from the carrier app. This
+ * activation code will be used to download the eSIM profile during eSIM activation flow.
+ */
+ public static final String ACTION_BIND_CARRIER_PROVISIONING_SERVICE =
+ "android.service.euicc.action.BIND_CARRIER_PROVISIONING_SERVICE";
+
+ /**
+ * Intent action sent by the LPA to launch a carrier app Activity for eSIM activation, e.g. a
+ * carrier login screen. Carrier apps wishing to support this activation method must implement
+ * an Activity that responds to this intent action. Upon completion, the Activity must return
+ * one of the following results to the LPA:
+ *
+ * <p>{@code Activity.RESULT_CANCELED}: The LPA should treat this as an back button and abort
+ * the activation flow.
+ * <p>{@code Activity.RESULT_OK}: The LPA should try to get an activation code from the carrier
+ * app by binding to the carrier app service implementing
+ * {@link #ACTION_BIND_CARRIER_PROVISIONING_SERVICE}.
+ * <p>{@code Activity.RESULT_OK} with
+ * {@link android.telephony.euicc.EuiccManager#EXTRA_USE_QR_SCANNER} set to true: The LPA should
+ * start a QR scanner for the user to scan an eSIM profile QR code.
+ * <p>For other results: The LPA should treat this as an error.
+ **/
+ @SdkConstant(SdkConstant.SdkConstantType.ACTIVITY_INTENT_ACTION)
+ public static final String ACTION_START_CARRIER_ACTIVATION =
+ "android.service.euicc.action.START_CARRIER_ACTIVATION";
+
+ /**
+ * @see android.telephony.euicc.EuiccManager#ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS
+ * The difference is this one is used by system to bring up the LUI.
+ */
+ public static final String ACTION_MANAGE_EMBEDDED_SUBSCRIPTIONS =
+ "android.service.euicc.action.MANAGE_EMBEDDED_SUBSCRIPTIONS";
+
+ /** @see android.telephony.euicc.EuiccManager#ACTION_PROVISION_EMBEDDED_SUBSCRIPTION */
+ public static final String ACTION_PROVISION_EMBEDDED_SUBSCRIPTION =
+ "android.service.euicc.action.PROVISION_EMBEDDED_SUBSCRIPTION";
+
+ /**
+ * @see android.telephony.euicc.EuiccManager#ACTION_TOGGLE_SUBSCRIPTION_PRIVILEGED. This is
+ * a protected intent that can only be sent by the system, and requires the
+ * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission.
+ */
+ public static final String ACTION_TOGGLE_SUBSCRIPTION_PRIVILEGED =
+ "android.service.euicc.action.TOGGLE_SUBSCRIPTION_PRIVILEGED";
+
+ /**
+ * @see android.telephony.euicc.EuiccManager#ACTION_DELETE_SUBSCRIPTION_PRIVILEGED. This is
+ * a protected intent that can only be sent by the system, and requires the
+ * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission.
+ */
+ public static final String ACTION_DELETE_SUBSCRIPTION_PRIVILEGED =
+ "android.service.euicc.action.DELETE_SUBSCRIPTION_PRIVILEGED";
+
+ /**
+ * @see android.telephony.euicc.EuiccManager#ACTION_RENAME_SUBSCRIPTION_PRIVILEGED. This is
+ * a protected intent that can only be sent by the system, and requires the
+ * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission.
+ */
+ public static final String ACTION_RENAME_SUBSCRIPTION_PRIVILEGED =
+ "android.service.euicc.action.RENAME_SUBSCRIPTION_PRIVILEGED";
+
+ /**
+ * @see android.telephony.euicc.EuiccManager#ACTION_START_EUICC_ACTIVATION. This is
+ * a protected intent that can only be sent by the system, and requires the
+ * {@link android.Manifest.permission#BIND_EUICC_SERVICE} permission.
+ */
+ @SdkConstant(SdkConstant.SdkConstantType.ACTIVITY_INTENT_ACTION)
+ public static final String ACTION_START_EUICC_ACTIVATION =
+ "android.service.euicc.action.START_EUICC_ACTIVATION";
+
+ // LUI resolution actions. These are called by the platform to resolve errors in situations that
+ // require user interaction.
+ // TODO(b/33075886): Define extras for any input parameters to these dialogs once they are
+ // more scoped out.
+ /**
+ * Alert the user that this action will result in an active SIM being deactivated.
+ * To implement the LUI triggered by the system, you need to define this in AndroidManifest.xml.
+ */
+ public static final String ACTION_RESOLVE_DEACTIVATE_SIM =
+ "android.service.euicc.action.RESOLVE_DEACTIVATE_SIM";
+ /**
+ * Alert the user about a download/switch being done for an app that doesn't currently have
+ * carrier privileges.
+ */
+ public static final String ACTION_RESOLVE_NO_PRIVILEGES =
+ "android.service.euicc.action.RESOLVE_NO_PRIVILEGES";
+
+ /**
+ * Ask the user to input carrier confirmation code.
+ *
+ * @deprecated From Q, the resolvable errors happened in the download step are presented as
+ * bit map in {@link #EXTRA_RESOLVABLE_ERRORS}. The corresponding action would be
+ * {@link #ACTION_RESOLVE_RESOLVABLE_ERRORS}.
+ */
+ @Deprecated
+ public static final String ACTION_RESOLVE_CONFIRMATION_CODE =
+ "android.service.euicc.action.RESOLVE_CONFIRMATION_CODE";
+
+ /** Ask the user to resolve all the resolvable errors. */
+ public static final String ACTION_RESOLVE_RESOLVABLE_ERRORS =
+ "android.service.euicc.action.RESOLVE_RESOLVABLE_ERRORS";
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(flag = true, prefix = { "RESOLVABLE_ERROR_" }, value = {
+ RESOLVABLE_ERROR_CONFIRMATION_CODE,
+ RESOLVABLE_ERROR_POLICY_RULES,
+ })
+ public @interface ResolvableError {}
+
+ /**
+ * Possible value for the bit map of resolvable errors indicating the download process needs
+ * the user to input confirmation code.
+ */
+ public static final int RESOLVABLE_ERROR_CONFIRMATION_CODE = 1 << 0;
+ /**
+ * Possible value for the bit map of resolvable errors indicating the download process needs
+ * the user's consent to allow profile policy rules.
+ */
+ public static final int RESOLVABLE_ERROR_POLICY_RULES = 1 << 1;
+
+ /**
+ * Intent extra set for resolution requests containing the package name of the calling app.
+ * This is used by the above actions including ACTION_RESOLVE_DEACTIVATE_SIM,
+ * ACTION_RESOLVE_NO_PRIVILEGES and ACTION_RESOLVE_RESOLVABLE_ERRORS.
+ */
+ public static final String EXTRA_RESOLUTION_CALLING_PACKAGE =
+ "android.service.euicc.extra.RESOLUTION_CALLING_PACKAGE";
+
+ /**
+ * Intent extra set for resolution requests containing the list of resolvable errors to be
+ * resolved. Each resolvable error is an integer. Its possible values include:
+ * <UL>
+ * <LI>{@link #RESOLVABLE_ERROR_CONFIRMATION_CODE}
+ * <LI>{@link #RESOLVABLE_ERROR_POLICY_RULES}
+ * </UL>
+ */
+ public static final String EXTRA_RESOLVABLE_ERRORS =
+ "android.service.euicc.extra.RESOLVABLE_ERRORS";
+
+ /**
+ * Intent extra set for resolution requests containing a boolean indicating whether to ask the
+ * user to retry another confirmation code.
+ */
+ public static final String EXTRA_RESOLUTION_CONFIRMATION_CODE_RETRIED =
+ "android.service.euicc.extra.RESOLUTION_CONFIRMATION_CODE_RETRIED";
+
+ /**
+ * Intent extra set for resolution requests containing an int indicating the current card Id.
+ */
+ public static final String EXTRA_RESOLUTION_CARD_ID =
+ "android.service.euicc.extra.RESOLUTION_CARD_ID";
+
+ /** @hide */
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(prefix = { "RESULT_" }, value = {
+ RESULT_OK,
+ RESULT_MUST_DEACTIVATE_SIM,
+ RESULT_RESOLVABLE_ERRORS,
+ RESULT_NEED_CONFIRMATION_CODE,
+ RESULT_FIRST_USER,
+ })
+ public @interface Result {}
+
+ /** Result code for a successful operation. */
+ public static final int RESULT_OK = 0;
+ /** Result code indicating that an active SIM must be deactivated to perform the operation. */
+ public static final int RESULT_MUST_DEACTIVATE_SIM = -1;
+ /** Result code indicating that the user must resolve resolvable errors. */
+ public static final int RESULT_RESOLVABLE_ERRORS = -2;
+ /**
+ * Result code indicating that the user must input a carrier confirmation code.
+ *
+ * @deprecated From Q, the resolvable errors happened in the download step are presented as
+ * bit map in {@link #EXTRA_RESOLVABLE_ERRORS}. The corresponding result would be
+ * {@link #RESULT_RESOLVABLE_ERRORS}.
+ */
+ @Deprecated
+ public static final int RESULT_NEED_CONFIRMATION_CODE = -2;
+ // New predefined codes should have negative values.
+
+ /** Start of implementation-specific error results. */
+ public static final int RESULT_FIRST_USER = 1;
+
+ /**
+ * Boolean extra for resolution actions indicating whether the user granted consent.
+ * This is used and set by the implementation and used in {@code EuiccOperation}.
+ */
+ public static final String EXTRA_RESOLUTION_CONSENT =
+ "android.service.euicc.extra.RESOLUTION_CONSENT";
+ /**
+ * String extra for resolution actions indicating the carrier confirmation code.
+ * This is used and set by the implementation and used in {@code EuiccOperation}.
+ */
+ public static final String EXTRA_RESOLUTION_CONFIRMATION_CODE =
+ "android.service.euicc.extra.RESOLUTION_CONFIRMATION_CODE";
+ /**
+ * String extra for resolution actions indicating whether the user allows policy rules.
+ * This is used and set by the implementation and used in {@code EuiccOperation}.
+ */
+ public static final String EXTRA_RESOLUTION_ALLOW_POLICY_RULES =
+ "android.service.euicc.extra.RESOLUTION_ALLOW_POLICY_RULES";
+
+ private final IEuiccService.Stub mStubWrapper;
+
+ private ThreadPoolExecutor mExecutor;
+
+ public EuiccService() {
+ mStubWrapper = new IEuiccServiceWrapper();
+ }
+
+ @Override
+ @CallSuper
+ public void onCreate() {
+ super.onCreate();
+ // We use a oneway AIDL interface to avoid blocking phone process binder threads on IPCs to
+ // an external process, but doing so means the requests are serialized by binder, which is
+ // not desired. Spin up a background thread pool to allow requests to be parallelized.
+ // TODO(b/38206971): Consider removing this if basic card-level functions like listing
+ // profiles are moved to the platform.
+ mExecutor = new ThreadPoolExecutor(
+ 4 /* corePoolSize */,
+ 4 /* maxPoolSize */,
+ 30, TimeUnit.SECONDS, /* keepAliveTime */
+ new LinkedBlockingQueue<>(), /* workQueue */
+ new ThreadFactory() {
+ private final AtomicInteger mCount = new AtomicInteger(1);
+
+ @Override
+ public Thread newThread(Runnable r) {
+ return new Thread(r, "EuiccService #" + mCount.getAndIncrement());
+ }
+ }
+ );
+ mExecutor.allowCoreThreadTimeOut(true);
+ }
+
+ @Override
+ @CallSuper
+ public void onDestroy() {
+ mExecutor.shutdownNow();
+ super.onDestroy();
+ }
+
+ /**
+ * If overriding this method, call through to the super method for any unknown actions.
+ * {@inheritDoc}
+ */
+ @Override
+ @CallSuper
+ public IBinder onBind(Intent intent) {
+ return mStubWrapper;
+ }
+
+ /**
+ * Callback class for {@link #onStartOtaIfNecessary(int, OtaStatusChangedCallback)}
+ *
+ * The status of OTA which can be {@code android.telephony.euicc.EuiccManager#EUICC_OTA_}
+ *
+ * @see IEuiccService#startOtaIfNecessary
+ */
+ public abstract static class OtaStatusChangedCallback {
+ /** Called when OTA status is changed. */
+ public abstract void onOtaStatusChanged(int status);
+ }
+
+ /**
+ * Return the EID of the eUICC.
+ *
+ * @param slotId ID of the SIM slot being queried.
+ * @return the EID.
+ * @see android.telephony.euicc.EuiccManager#getEid
+ */
+ // TODO(b/36260308): Update doc when we have multi-SIM support.
+ public abstract String onGetEid(int slotId);
+
+ /**
+ * Return the status of OTA update.
+ *
+ * @param slotId ID of the SIM slot to use for the operation.
+ * @return The status of Euicc OTA update.
+ * @see android.telephony.euicc.EuiccManager#getOtaStatus
+ */
+ public abstract @OtaStatus int onGetOtaStatus(int slotId);
+
+ /**
+ * Perform OTA if current OS is not the latest one.
+ *
+ * @param slotId ID of the SIM slot to use for the operation.
+ * @param statusChangedCallback Function called when OTA status changed.
+ */
+ public abstract void onStartOtaIfNecessary(
+ int slotId, OtaStatusChangedCallback statusChangedCallback);
+
+ /**
+ * Populate {@link DownloadableSubscription} metadata for the given downloadable subscription.
+ *
+ * @param slotId ID of the SIM slot to use for 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
+ */
+ public abstract GetDownloadableSubscriptionMetadataResult onGetDownloadableSubscriptionMetadata(
+ int slotId, DownloadableSubscription subscription, boolean forceDeactivateSim);
+
+ /**
+ * Return metadata for subscriptions which are available for download for this device.
+ *
+ * @param slotId ID of the SIM slot to use for the operation.
+ * @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 list operation.
+ * @see android.telephony.euicc.EuiccManager#getDefaultDownloadableSubscriptionList
+ */
+ public abstract GetDefaultDownloadableSubscriptionListResult
+ onGetDefaultDownloadableSubscriptionList(int slotId, boolean forceDeactivateSim);
+
+ /**
+ * Download the given subscription.
+ *
+ * @param slotId ID of the SIM slot to use for the operation.
+ * @param subscription The subscription to download.
+ * @param switchAfterDownload If true, the subscription should be enabled upon successful
+ * download.
+ * @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.
+ * @param resolvedBundle The bundle containing information on resolved errors. It can contain
+ * a string of confirmation code for the key {@link #EXTRA_RESOLUTION_CONFIRMATION_CODE},
+ * and a boolean for key {@link #EXTRA_RESOLUTION_ALLOW_POLICY_RULES} indicating whether
+ * the user allows profile policy rules or not.
+ * @return a DownloadSubscriptionResult instance including a result code, a resolvable errors
+ * bit map, and original the card Id. The result code may be one of the predefined
+ * {@code RESULT_} constants or any implementation-specific code starting with
+ * {@link #RESULT_FIRST_USER}. The resolvable error bit map can be either 0 or values
+ * defined in {@code RESOLVABLE_ERROR_}. A subclass should override this method. Otherwise,
+ * this method does nothing and returns null by default.
+ * @see android.telephony.euicc.EuiccManager#downloadSubscription
+ */
+ public DownloadSubscriptionResult onDownloadSubscription(int slotId,
+ @NonNull DownloadableSubscription subscription, boolean switchAfterDownload,
+ boolean forceDeactivateSim, @Nullable Bundle resolvedBundle) {
+ return null;
+ }
+
+ /**
+ * Download the given subscription.
+ *
+ * @param slotId ID of the SIM slot to use for the operation.
+ * @param subscription The subscription to download.
+ * @param switchAfterDownload If true, the subscription should be enabled upon successful
+ * download.
+ * @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 download operation. May be one of the predefined {@code RESULT_}
+ * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}.
+ * @see android.telephony.euicc.EuiccManager#downloadSubscription
+ *
+ * @deprecated From Q, a subclass should use and override the above
+ * {@link #onDownloadSubscription(int, DownloadableSubscription, boolean, boolean, Bundle)}. The
+ * default return value for this one is Integer.MIN_VALUE.
+ */
+ @Deprecated public @Result int onDownloadSubscription(int slotId,
+ @NonNull DownloadableSubscription subscription, boolean switchAfterDownload,
+ boolean forceDeactivateSim) {
+ return Integer.MIN_VALUE;
+ }
+
+ /**
+ * Return a list of all @link EuiccProfileInfo}s.
+ *
+ * @param slotId ID of the SIM slot to use for the operation.
+ * @return The result of the operation.
+ * @see android.telephony.SubscriptionManager#getAvailableSubscriptionInfoList
+ * @see android.telephony.SubscriptionManager#getAccessibleSubscriptionInfoList
+ */
+ public abstract @NonNull GetEuiccProfileInfoListResult onGetEuiccProfileInfoList(int slotId);
+
+ /**
+ * Return info about the eUICC chip/device.
+ *
+ * @param slotId ID of the SIM slot to use for the operation.
+ * @return the {@link EuiccInfo} for the eUICC chip/device.
+ * @see android.telephony.euicc.EuiccManager#getEuiccInfo
+ */
+ public abstract @NonNull EuiccInfo onGetEuiccInfo(int slotId);
+
+ /**
+ * Delete the given subscription.
+ *
+ * <p>If the subscription is currently active, it should be deactivated first (equivalent to a
+ * physical SIM being ejected).
+ *
+ * @param slotId ID of the SIM slot to use for the operation.
+ * @param iccid the ICCID of the subscription to delete.
+ * @return the result of the delete operation. May be one of the predefined {@code RESULT_}
+ * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}.
+ * @see android.telephony.euicc.EuiccManager#deleteSubscription
+ */
+ public abstract @Result int onDeleteSubscription(int slotId, String iccid);
+
+ /**
+ * Switch to the given subscription.
+ *
+ * @param slotId ID of the SIM slot to use for the operation.
+ * @param iccid the ICCID of the subscription to enable. May be null, in which case the current
+ * profile should be deactivated and no profile should be activated to replace it - this is
+ * equivalent to a physical SIM being ejected.
+ * @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 switch operation. May be one of the predefined {@code RESULT_}
+ * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}.
+ * @see android.telephony.euicc.EuiccManager#switchToSubscription
+ */
+ public abstract @Result int onSwitchToSubscription(int slotId, @Nullable String iccid,
+ boolean forceDeactivateSim);
+
+ /**
+ * Update the nickname of the given subscription.
+ *
+ * @param slotId ID of the SIM slot to use for the operation.
+ * @param iccid the ICCID of the subscription to update.
+ * @param nickname the new nickname to apply.
+ * @return the result of the update operation. May be one of the predefined {@code RESULT_}
+ * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}.
+ * @see android.telephony.euicc.EuiccManager#updateSubscriptionNickname
+ */
+ public abstract int onUpdateSubscriptionNickname(int slotId, String iccid,
+ String nickname);
+
+ /**
+ * Erase all operational subscriptions on the device.
+ *
+ * <p>This is intended to be used for device resets. As such, the reset should be performed even
+ * if an active SIM must be deactivated in order to access the eUICC.
+ *
+ * @param slotId ID of the SIM slot to use for the operation.
+ * @return the result of the erase operation. May be one of the predefined {@code RESULT_}
+ * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}.
+ * @see android.telephony.euicc.EuiccManager#eraseSubscriptions
+ *
+ * @deprecated From R, callers should specify a flag for specific set of subscriptions to erase
+ * and use {@link #onEraseSubscriptions(int, int)} instead
+ */
+ @Deprecated
+ public abstract int onEraseSubscriptions(int slotId);
+
+ /**
+ * Erase specific subscriptions on the device.
+ *
+ * <p>This is intended to be used for device resets. As such, the reset should be performed even
+ * if an active SIM must be deactivated in order to access the eUICC.
+ *
+ * @param slotIndex index of the SIM slot to use for the operation.
+ * @param options flag for specific group of subscriptions to erase
+ * @return the result of the erase operation. May be one of the predefined {@code RESULT_}
+ * constants or any implementation-specific code starting with {@link #RESULT_FIRST_USER}.
+ * @see android.telephony.euicc.EuiccManager#eraseSubscriptionsWithOptions
+ */
+ public int onEraseSubscriptions(int slotIndex, @ResetOption int options) {
+ throw new UnsupportedOperationException(
+ "This method must be overridden to enable the ResetOption parameter");
+ }
+
+ /**
+ * Ensure that subscriptions will be retained on the next factory reset.
+ *
+ * <p>Called directly before a factory reset. Assumes that a normal factory reset will lead to
+ * profiles being erased on first boot (to cover fastboot/recovery wipes), so the implementation
+ * should persist some bit that will remain accessible after the factory reset to bypass this
+ * flow when this method is called.
+ *
+ * @param slotId ID of the SIM slot to use for the operation.
+ * @return the result of the operation. May be one of the predefined {@code RESULT_} constants
+ * or any implementation-specific code starting with {@link #RESULT_FIRST_USER}.
+ */
+ public abstract int onRetainSubscriptionsForFactoryReset(int slotId);
+
+ /**
+ * Wrapper around IEuiccService that forwards calls to implementations of {@link EuiccService}.
+ */
+ private class IEuiccServiceWrapper extends IEuiccService.Stub {
+ @Override
+ public void downloadSubscription(int slotId, DownloadableSubscription subscription,
+ boolean switchAfterDownload, boolean forceDeactivateSim, Bundle resolvedBundle,
+ IDownloadSubscriptionCallback callback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ DownloadSubscriptionResult result;
+ try {
+ result =
+ EuiccService.this.onDownloadSubscription(
+ slotId, subscription, switchAfterDownload, forceDeactivateSim,
+ resolvedBundle);
+ } catch (AbstractMethodError e) {
+ Log.w(TAG, "The new onDownloadSubscription(int, "
+ + "DownloadableSubscription, boolean, boolean, Bundle) is not "
+ + "implemented. Fall back to the old one.", e);
+ int resultCode = EuiccService.this.onDownloadSubscription(
+ slotId, subscription, switchAfterDownload, forceDeactivateSim);
+ result = new DownloadSubscriptionResult(resultCode,
+ 0 /* resolvableErrors */, TelephonyManager.UNSUPPORTED_CARD_ID);
+ }
+ try {
+ callback.onComplete(result);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+ }
+
+ @Override
+ public void getEid(int slotId, IGetEidCallback callback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ String eid = EuiccService.this.onGetEid(slotId);
+ try {
+ callback.onSuccess(eid);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+ }
+
+ @Override
+ public void startOtaIfNecessary(
+ int slotId, IOtaStatusChangedCallback statusChangedCallback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ EuiccService.this.onStartOtaIfNecessary(slotId, new OtaStatusChangedCallback() {
+ @Override
+ public void onOtaStatusChanged(int status) {
+ try {
+ statusChangedCallback.onOtaStatusChanged(status);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+ }
+ });
+ }
+
+ @Override
+ public void getOtaStatus(int slotId, IGetOtaStatusCallback callback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ int status = EuiccService.this.onGetOtaStatus(slotId);
+ try {
+ callback.onSuccess(status);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+ }
+
+ @Override
+ public void getDownloadableSubscriptionMetadata(int slotId,
+ DownloadableSubscription subscription,
+ boolean forceDeactivateSim,
+ IGetDownloadableSubscriptionMetadataCallback callback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ GetDownloadableSubscriptionMetadataResult result =
+ EuiccService.this.onGetDownloadableSubscriptionMetadata(
+ slotId, subscription, forceDeactivateSim);
+ try {
+ callback.onComplete(result);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+ }
+
+ @Override
+ public void getDefaultDownloadableSubscriptionList(int slotId, boolean forceDeactivateSim,
+ IGetDefaultDownloadableSubscriptionListCallback callback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ GetDefaultDownloadableSubscriptionListResult result =
+ EuiccService.this.onGetDefaultDownloadableSubscriptionList(
+ slotId, forceDeactivateSim);
+ try {
+ callback.onComplete(result);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+ }
+
+ @Override
+ public void getEuiccProfileInfoList(int slotId, IGetEuiccProfileInfoListCallback callback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ GetEuiccProfileInfoListResult result =
+ EuiccService.this.onGetEuiccProfileInfoList(slotId);
+ try {
+ callback.onComplete(result);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+ }
+
+ @Override
+ public void getEuiccInfo(int slotId, IGetEuiccInfoCallback callback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ EuiccInfo euiccInfo = EuiccService.this.onGetEuiccInfo(slotId);
+ try {
+ callback.onSuccess(euiccInfo);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+
+ }
+
+ @Override
+ public void deleteSubscription(int slotId, String iccid,
+ IDeleteSubscriptionCallback callback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ int result = EuiccService.this.onDeleteSubscription(slotId, iccid);
+ try {
+ callback.onComplete(result);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+ }
+
+ @Override
+ public void switchToSubscription(int slotId, String iccid, boolean forceDeactivateSim,
+ ISwitchToSubscriptionCallback callback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ int result =
+ EuiccService.this.onSwitchToSubscription(
+ slotId, iccid, forceDeactivateSim);
+ try {
+ callback.onComplete(result);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+ }
+
+ @Override
+ public void updateSubscriptionNickname(int slotId, String iccid, String nickname,
+ IUpdateSubscriptionNicknameCallback callback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ int result =
+ EuiccService.this.onUpdateSubscriptionNickname(slotId, iccid, nickname);
+ try {
+ callback.onComplete(result);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+ }
+
+ @Override
+ public void eraseSubscriptions(int slotId, IEraseSubscriptionsCallback callback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ int result = EuiccService.this.onEraseSubscriptions(slotId);
+ try {
+ callback.onComplete(result);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+ }
+
+ @Override
+ public void eraseSubscriptionsWithOptions(
+ int slotIndex, @ResetOption int options, IEraseSubscriptionsCallback callback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ int result = EuiccService.this.onEraseSubscriptions(slotIndex, options);
+ try {
+ callback.onComplete(result);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+ }
+
+ @Override
+ public void retainSubscriptionsForFactoryReset(int slotId,
+ IRetainSubscriptionsForFactoryResetCallback callback) {
+ mExecutor.execute(new Runnable() {
+ @Override
+ public void run() {
+ int result = EuiccService.this.onRetainSubscriptionsForFactoryReset(slotId);
+ try {
+ callback.onComplete(result);
+ } catch (RemoteException e) {
+ // Can't communicate with the phone process; ignore.
+ }
+ }
+ });
+ }
+ }
+}
diff --git a/telephony/java/android/service/euicc/GetDefaultDownloadableSubscriptionListResult.aidl b/telephony/java/android/service/euicc/GetDefaultDownloadableSubscriptionListResult.aidl
new file mode 100644
index 000000000000..c2636a16edee
--- /dev/null
+++ b/telephony/java/android/service/euicc/GetDefaultDownloadableSubscriptionListResult.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+parcelable GetDefaultDownloadableSubscriptionListResult;
diff --git a/telephony/java/android/service/euicc/GetDefaultDownloadableSubscriptionListResult.java b/telephony/java/android/service/euicc/GetDefaultDownloadableSubscriptionListResult.java
new file mode 100644
index 000000000000..c7a985160730
--- /dev/null
+++ b/telephony/java/android/service/euicc/GetDefaultDownloadableSubscriptionListResult.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.service.euicc;
+
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.annotation.UnsupportedAppUsage;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.telephony.euicc.DownloadableSubscription;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Result of a {@link EuiccService#onGetDefaultDownloadableSubscriptionList} operation.
+ * @hide
+ */
+@SystemApi
+public final class GetDefaultDownloadableSubscriptionListResult implements Parcelable {
+
+ public static final @android.annotation.NonNull Creator<GetDefaultDownloadableSubscriptionListResult> CREATOR =
+ new Creator<GetDefaultDownloadableSubscriptionListResult>() {
+ @Override
+ public GetDefaultDownloadableSubscriptionListResult createFromParcel(Parcel in) {
+ return new GetDefaultDownloadableSubscriptionListResult(in);
+ }
+
+ @Override
+ public GetDefaultDownloadableSubscriptionListResult[] newArray(int size) {
+ return new GetDefaultDownloadableSubscriptionListResult[size];
+ }
+ };
+
+ /**
+ * @hide
+ * @deprecated - Do no use. Use getResult() instead.
+ */
+ @Deprecated
+ @UnsupportedAppUsage
+ public final int result;
+
+ @Nullable
+ private final DownloadableSubscription[] mSubscriptions;
+
+ /**
+ * Gets the result of the operation.
+ *
+ * <p>May be one of the predefined {@code RESULT_} constants in EuiccService or any
+ * implementation-specific code starting with {@link EuiccService#RESULT_FIRST_USER}.
+ */
+ public int getResult() {
+ return result;
+ }
+
+ /**
+ * Gets the available {@link DownloadableSubscription}s (with filled-in metadata).
+ *
+ * <p>Only non-null if {@link #result} is {@link EuiccService#RESULT_OK}.
+ */
+ @Nullable
+ public List<DownloadableSubscription> getDownloadableSubscriptions() {
+ if (mSubscriptions == null) return null;
+ return Arrays.asList(mSubscriptions);
+ }
+
+ /**
+ * Construct a new {@link GetDefaultDownloadableSubscriptionListResult}.
+ *
+ * @param result Result of the operation. May be one of the predefined {@code RESULT_} constants
+ * in EuiccService or any implementation-specific code starting with
+ * {@link EuiccService#RESULT_FIRST_USER}.
+ * @param subscriptions The available subscriptions. Should only be provided if the result is
+ * {@link EuiccService#RESULT_OK}.
+ */
+ public GetDefaultDownloadableSubscriptionListResult(int result,
+ @Nullable DownloadableSubscription[] subscriptions) {
+ this.result = result;
+ if (this.result == EuiccService.RESULT_OK) {
+ this.mSubscriptions = subscriptions;
+ } else {
+ if (subscriptions != null) {
+ throw new IllegalArgumentException(
+ "Error result with non-null subscriptions: " + result);
+ }
+ this.mSubscriptions = null;
+ }
+ }
+
+ private GetDefaultDownloadableSubscriptionListResult(Parcel in) {
+ this.result = in.readInt();
+ this.mSubscriptions = in.createTypedArray(DownloadableSubscription.CREATOR);
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(result);
+ dest.writeTypedArray(mSubscriptions, flags);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+}
diff --git a/telephony/java/android/service/euicc/GetDownloadableSubscriptionMetadataResult.aidl b/telephony/java/android/service/euicc/GetDownloadableSubscriptionMetadataResult.aidl
new file mode 100644
index 000000000000..791ad9b469ef
--- /dev/null
+++ b/telephony/java/android/service/euicc/GetDownloadableSubscriptionMetadataResult.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+parcelable GetDownloadableSubscriptionMetadataResult;
diff --git a/telephony/java/android/service/euicc/GetDownloadableSubscriptionMetadataResult.java b/telephony/java/android/service/euicc/GetDownloadableSubscriptionMetadataResult.java
new file mode 100644
index 000000000000..abd4065c754a
--- /dev/null
+++ b/telephony/java/android/service/euicc/GetDownloadableSubscriptionMetadataResult.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.service.euicc;
+
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.annotation.UnsupportedAppUsage;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.telephony.euicc.DownloadableSubscription;
+
+/**
+ * Result of a {@link EuiccService#onGetDownloadableSubscriptionMetadata} operation.
+ * @hide
+ */
+@SystemApi
+public final class GetDownloadableSubscriptionMetadataResult implements Parcelable {
+
+ public static final @android.annotation.NonNull Creator<GetDownloadableSubscriptionMetadataResult> CREATOR =
+ new Creator<GetDownloadableSubscriptionMetadataResult>() {
+ @Override
+ public GetDownloadableSubscriptionMetadataResult createFromParcel(Parcel in) {
+ return new GetDownloadableSubscriptionMetadataResult(in);
+ }
+
+ @Override
+ public GetDownloadableSubscriptionMetadataResult[] newArray(int size) {
+ return new GetDownloadableSubscriptionMetadataResult[size];
+ }
+ };
+
+ /**
+ * @hide
+ * @deprecated - Do no use. Use getResult() instead.
+ */
+ @Deprecated
+ @UnsupportedAppUsage
+ public final int result;
+
+ @Nullable
+ private final DownloadableSubscription mSubscription;
+
+ /**
+ * Gets the result of the operation.
+ *
+ * <p>May be one of the predefined {@code RESULT_} constants in EuiccService or any
+ * implementation-specific code starting with {@link EuiccService#RESULT_FIRST_USER}.
+ */
+ public int getResult() {
+ return result;
+ }
+
+ /**
+ * Gets the {@link DownloadableSubscription} with filled-in metadata.
+ *
+ * <p>Only non-null if {@link #result} is {@link EuiccService#RESULT_OK}.
+ */
+ @Nullable
+ public DownloadableSubscription getDownloadableSubscription() {
+ return mSubscription;
+ }
+
+ /**
+ * Construct a new {@link GetDownloadableSubscriptionMetadataResult}.
+ *
+ * @param result Result of the operation. May be one of the predefined {@code RESULT_} constants
+ * in EuiccService or any implementation-specific code starting with
+ * {@link EuiccService#RESULT_FIRST_USER}.
+ * @param subscription The subscription with filled-in metadata. Should only be provided if the
+ * result is {@link EuiccService#RESULT_OK}.
+ */
+ public GetDownloadableSubscriptionMetadataResult(int result,
+ @Nullable DownloadableSubscription subscription) {
+ this.result = result;
+ if (this.result == EuiccService.RESULT_OK) {
+ this.mSubscription = subscription;
+ } else {
+ if (subscription != null) {
+ throw new IllegalArgumentException(
+ "Error result with non-null subscription: " + result);
+ }
+ this.mSubscription = null;
+ }
+ }
+
+ private GetDownloadableSubscriptionMetadataResult(Parcel in) {
+ this.result = in.readInt();
+ this.mSubscription = in.readTypedObject(DownloadableSubscription.CREATOR);
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(result);
+ dest.writeTypedObject(this.mSubscription, flags);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/GetEuiccProfileInfoListResult.aidl b/telephony/java/android/service/euicc/GetEuiccProfileInfoListResult.aidl
new file mode 100644
index 000000000000..6003b79462da
--- /dev/null
+++ b/telephony/java/android/service/euicc/GetEuiccProfileInfoListResult.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+parcelable GetEuiccProfileInfoListResult;
diff --git a/telephony/java/android/service/euicc/GetEuiccProfileInfoListResult.java b/telephony/java/android/service/euicc/GetEuiccProfileInfoListResult.java
new file mode 100644
index 000000000000..9add38e40d9b
--- /dev/null
+++ b/telephony/java/android/service/euicc/GetEuiccProfileInfoListResult.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.service.euicc;
+
+import android.annotation.Nullable;
+import android.annotation.SystemApi;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Result of a {@link EuiccService#onGetEuiccProfileInfoList} operation.
+ * @hide
+ */
+@SystemApi
+public final class GetEuiccProfileInfoListResult implements Parcelable {
+
+ public static final @android.annotation.NonNull Creator<GetEuiccProfileInfoListResult> CREATOR =
+ new Creator<GetEuiccProfileInfoListResult>() {
+ @Override
+ public GetEuiccProfileInfoListResult createFromParcel(Parcel in) {
+ return new GetEuiccProfileInfoListResult(in);
+ }
+
+ @Override
+ public GetEuiccProfileInfoListResult[] newArray(int size) {
+ return new GetEuiccProfileInfoListResult[size];
+ }
+ };
+
+ /**
+ * @hide
+ * @deprecated - Do no use. Use getResult() instead.
+ */
+ @Deprecated
+ public final int result;
+
+ @Nullable
+ private final EuiccProfileInfo[] mProfiles;
+
+ private final boolean mIsRemovable;
+
+ /**
+ * Gets the result of the operation.
+ *
+ * <p>May be one of the predefined {@code RESULT_} constants in EuiccService or any
+ * implementation-specific code starting with {@link EuiccService#RESULT_FIRST_USER}.
+ */
+ public int getResult() {
+ return result;
+ }
+
+ /** Gets the profile list (only upon success). */
+ @Nullable
+ public List<EuiccProfileInfo> getProfiles() {
+ if (mProfiles == null) return null;
+ return Arrays.asList(mProfiles);
+ }
+
+ /** Gets whether the eUICC is removable. */
+ public boolean getIsRemovable() {
+ return mIsRemovable;
+ }
+
+ /**
+ * Construct a new {@link GetEuiccProfileInfoListResult}.
+ *
+ * @param result Result of the operation. May be one of the predefined {@code RESULT_} constants
+ * in EuiccService or any implementation-specific code starting with
+ * {@link EuiccService#RESULT_FIRST_USER}.
+ * @param profiles the list of profiles. Should only be provided if the result is
+ * {@link EuiccService#RESULT_OK}.
+ * @param isRemovable whether the eUICC in this slot is removable. If true, the profiles
+ * returned here will only be considered accessible as long as this eUICC is present.
+ * Otherwise, they will remain accessible until the next time a response with isRemovable
+ * set to false is returned.
+ */
+ public GetEuiccProfileInfoListResult(
+ int result, @Nullable EuiccProfileInfo[] profiles, boolean isRemovable) {
+ this.result = result;
+ this.mIsRemovable = isRemovable;
+ if (this.result == EuiccService.RESULT_OK) {
+ this.mProfiles = profiles;
+ } else {
+ // For error case, profiles is either null or 0 size.
+ if (profiles != null && profiles.length > 0) {
+ throw new IllegalArgumentException(
+ "Error result with non-empty profiles: " + result);
+ }
+ this.mProfiles = null;
+ }
+ }
+
+ private GetEuiccProfileInfoListResult(Parcel in) {
+ this.result = in.readInt();
+ this.mProfiles = in.createTypedArray(EuiccProfileInfo.CREATOR);
+ this.mIsRemovable = in.readBoolean();
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(result);
+ dest.writeTypedArray(mProfiles, flags);
+ dest.writeBoolean(mIsRemovable);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+}
diff --git a/telephony/java/android/service/euicc/IDeleteSubscriptionCallback.aidl b/telephony/java/android/service/euicc/IDeleteSubscriptionCallback.aidl
new file mode 100644
index 000000000000..aff8f1b7b346
--- /dev/null
+++ b/telephony/java/android/service/euicc/IDeleteSubscriptionCallback.aidl
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+/** @hide */
+oneway interface IDeleteSubscriptionCallback {
+ @UnsupportedAppUsage
+ void onComplete(int result);
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/IDownloadSubscriptionCallback.aidl b/telephony/java/android/service/euicc/IDownloadSubscriptionCallback.aidl
new file mode 100644
index 000000000000..50ecbebf5e84
--- /dev/null
+++ b/telephony/java/android/service/euicc/IDownloadSubscriptionCallback.aidl
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+import android.service.euicc.DownloadSubscriptionResult;
+
+/** @hide */
+oneway interface IDownloadSubscriptionCallback {
+ void onComplete(in DownloadSubscriptionResult result);
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/IEraseSubscriptionsCallback.aidl b/telephony/java/android/service/euicc/IEraseSubscriptionsCallback.aidl
new file mode 100644
index 000000000000..34b53cc71dfb
--- /dev/null
+++ b/telephony/java/android/service/euicc/IEraseSubscriptionsCallback.aidl
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+/** @hide */
+oneway interface IEraseSubscriptionsCallback {
+ @UnsupportedAppUsage
+ void onComplete(int result);
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/IEuiccService.aidl b/telephony/java/android/service/euicc/IEuiccService.aidl
new file mode 100644
index 000000000000..2acc47aae919
--- /dev/null
+++ b/telephony/java/android/service/euicc/IEuiccService.aidl
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+import android.service.euicc.IDeleteSubscriptionCallback;
+import android.service.euicc.IDownloadSubscriptionCallback;
+import android.service.euicc.IEraseSubscriptionsCallback;
+import android.service.euicc.IGetDefaultDownloadableSubscriptionListCallback;
+import android.service.euicc.IGetDownloadableSubscriptionMetadataCallback;
+import android.service.euicc.IGetEidCallback;
+import android.service.euicc.IGetEuiccInfoCallback;
+import android.service.euicc.IGetEuiccProfileInfoListCallback;
+import android.service.euicc.IGetOtaStatusCallback;
+import android.service.euicc.IOtaStatusChangedCallback;
+import android.service.euicc.IRetainSubscriptionsForFactoryResetCallback;
+import android.service.euicc.ISwitchToSubscriptionCallback;
+import android.service.euicc.IUpdateSubscriptionNicknameCallback;
+import android.telephony.euicc.DownloadableSubscription;
+import android.os.Bundle;
+
+/** @hide */
+oneway interface IEuiccService {
+ void downloadSubscription(int slotId, 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 getEid(int slotId, in IGetEidCallback callback);
+ void getOtaStatus(int slotId, in IGetOtaStatusCallback callback);
+ void startOtaIfNecessary(int slotId, in IOtaStatusChangedCallback statusChangedCallback);
+ void getEuiccProfileInfoList(int slotId, in IGetEuiccProfileInfoListCallback callback);
+ void getDefaultDownloadableSubscriptionList(int slotId, boolean forceDeactivateSim,
+ in IGetDefaultDownloadableSubscriptionListCallback callback);
+ void getEuiccInfo(int slotId, in IGetEuiccInfoCallback callback);
+ void deleteSubscription(int slotId, String iccid, in IDeleteSubscriptionCallback callback);
+ void switchToSubscription(int slotId, String iccid, boolean forceDeactivateSim,
+ in ISwitchToSubscriptionCallback callback);
+ void updateSubscriptionNickname(int slotId, String iccid, String nickname,
+ in IUpdateSubscriptionNicknameCallback callback);
+ void eraseSubscriptions(int slotId, in IEraseSubscriptionsCallback callback);
+ void eraseSubscriptionsWithOptions(
+ int slotIndex, int options, in IEraseSubscriptionsCallback callback);
+ void retainSubscriptionsForFactoryReset(
+ int slotId, in IRetainSubscriptionsForFactoryResetCallback callback);
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/IGetDefaultDownloadableSubscriptionListCallback.aidl b/telephony/java/android/service/euicc/IGetDefaultDownloadableSubscriptionListCallback.aidl
new file mode 100644
index 000000000000..ad69ef132428
--- /dev/null
+++ b/telephony/java/android/service/euicc/IGetDefaultDownloadableSubscriptionListCallback.aidl
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+import android.service.euicc.GetDefaultDownloadableSubscriptionListResult;
+
+/** @hide */
+oneway interface IGetDefaultDownloadableSubscriptionListCallback {
+ @UnsupportedAppUsage
+ void onComplete(in GetDefaultDownloadableSubscriptionListResult result);
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/IGetDownloadableSubscriptionMetadataCallback.aidl b/telephony/java/android/service/euicc/IGetDownloadableSubscriptionMetadataCallback.aidl
new file mode 100644
index 000000000000..01f187ed11e2
--- /dev/null
+++ b/telephony/java/android/service/euicc/IGetDownloadableSubscriptionMetadataCallback.aidl
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+import android.service.euicc.GetDownloadableSubscriptionMetadataResult;
+
+/** @hide */
+oneway interface IGetDownloadableSubscriptionMetadataCallback {
+ @UnsupportedAppUsage
+ void onComplete(in GetDownloadableSubscriptionMetadataResult result);
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/IGetEidCallback.aidl b/telephony/java/android/service/euicc/IGetEidCallback.aidl
new file mode 100644
index 000000000000..e405a981c85a
--- /dev/null
+++ b/telephony/java/android/service/euicc/IGetEidCallback.aidl
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+/** @hide */
+oneway interface IGetEidCallback {
+ @UnsupportedAppUsage
+ void onSuccess(String eid);
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/IGetEuiccInfoCallback.aidl b/telephony/java/android/service/euicc/IGetEuiccInfoCallback.aidl
new file mode 100644
index 000000000000..c0611825ff0f
--- /dev/null
+++ b/telephony/java/android/service/euicc/IGetEuiccInfoCallback.aidl
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+import android.telephony.euicc.EuiccInfo;
+
+/** @hide */
+oneway interface IGetEuiccInfoCallback {
+ @UnsupportedAppUsage
+ void onSuccess(in EuiccInfo euiccInfo);
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/IGetEuiccProfileInfoListCallback.aidl b/telephony/java/android/service/euicc/IGetEuiccProfileInfoListCallback.aidl
new file mode 100644
index 000000000000..0485f7be29d3
--- /dev/null
+++ b/telephony/java/android/service/euicc/IGetEuiccProfileInfoListCallback.aidl
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+import android.service.euicc.GetEuiccProfileInfoListResult;
+
+/** @hide */
+oneway interface IGetEuiccProfileInfoListCallback {
+ @UnsupportedAppUsage
+ void onComplete(in GetEuiccProfileInfoListResult result);
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/IGetOtaStatusCallback.aidl b/telephony/java/android/service/euicc/IGetOtaStatusCallback.aidl
new file mode 100644
index 000000000000..f6678889ccc7
--- /dev/null
+++ b/telephony/java/android/service/euicc/IGetOtaStatusCallback.aidl
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+/** @hide */
+oneway interface IGetOtaStatusCallback {
+ void onSuccess(int status);
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/IOtaStatusChangedCallback.aidl b/telephony/java/android/service/euicc/IOtaStatusChangedCallback.aidl
new file mode 100644
index 000000000000..caec75f13f61
--- /dev/null
+++ b/telephony/java/android/service/euicc/IOtaStatusChangedCallback.aidl
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+/** @hide */
+oneway interface IOtaStatusChangedCallback {
+ void onOtaStatusChanged(int status);
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/IRetainSubscriptionsForFactoryResetCallback.aidl b/telephony/java/android/service/euicc/IRetainSubscriptionsForFactoryResetCallback.aidl
new file mode 100644
index 000000000000..340401fe89cb
--- /dev/null
+++ b/telephony/java/android/service/euicc/IRetainSubscriptionsForFactoryResetCallback.aidl
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+/** @hide */
+oneway interface IRetainSubscriptionsForFactoryResetCallback {
+ @UnsupportedAppUsage
+ void onComplete(int result);
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/ISwitchToSubscriptionCallback.aidl b/telephony/java/android/service/euicc/ISwitchToSubscriptionCallback.aidl
new file mode 100644
index 000000000000..b8f984d1c28b
--- /dev/null
+++ b/telephony/java/android/service/euicc/ISwitchToSubscriptionCallback.aidl
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+/** @hide */
+oneway interface ISwitchToSubscriptionCallback {
+ @UnsupportedAppUsage
+ void onComplete(int result);
+} \ No newline at end of file
diff --git a/telephony/java/android/service/euicc/IUpdateSubscriptionNicknameCallback.aidl b/telephony/java/android/service/euicc/IUpdateSubscriptionNicknameCallback.aidl
new file mode 100644
index 000000000000..0aa66978bb91
--- /dev/null
+++ b/telephony/java/android/service/euicc/IUpdateSubscriptionNicknameCallback.aidl
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.service.euicc;
+
+/** @hide */
+oneway interface IUpdateSubscriptionNicknameCallback {
+ @UnsupportedAppUsage
+ void onComplete(int result);
+} \ No newline at end of file