Squashed merge of master-sim into master.
Includes the following commits:
==
New system feature: eUICC.
Presence of this feature implies that eUICC-related APIs are expected
to function as long as an eUICC is present in the device. Note that an
eUICC may be embedded in the device but may also be removable.
==
Add empty EuiccManager API and plumbing.
==
Add stub EuiccService.
EuiccService is the class that the LPA app must implement; for now,
just define the action and priority so that the implementation can be
found. Actual methods will come later.
Also declare two relevant permissions: BIND_EUICC_SERVICE, which the
implementation must require (so that nobody else can bind to the
service directly), and WRITE_EMBEDDED_SUBSCRIPTIONS, which permits
signature|privileged apps and CTS (via development) to access
EuiccManager APIs.
==
Add UiccAccessRule based off UiccCarrierPrivilegeRules#AccessRule.
This class can be used to transfer access rules between an
EuiccService implementation and the platform.
We also add a simple encoding/decoding of a list of rules so that they
may be stored in the subscription info table.
==
Add getEid() to EuiccManager/EuiccService.
getEid() fetches the EID. It requires either a privileged permission
(READ_PRIVILEGED_PHONE_STATE) or carrier privileges on the
currently-active profile. Until there is a use case that requires
opening this up to apps with only READ_PHONE_STATE, we shouldn't do
so.
To avoid churn in the future, the API signatures for EuiccService
include a slot ID to identify which SIM slot is being used. However,
this parameter is currently not populated correctly (nor is it usable,
as no Telephony APIs accept a slot ID to address commands). There is
no need to expose it yet in the EuiccManager APIs as we expect to
follow the TelephonyManager pattern of allowing per-slot instances of
EuiccManager in the future while keeping other method signatures the
same.
==
Define Euicc UI actions in EuiccManager/EuiccService.
The EuiccManager actions are to be implemented by the platform (and
only the platform), which forwards the actions to the active
implementation.
Also, remove our explicit priority meta-data tag as we can just rely
on android:priority in the corresponding intent-filter.
==
APIs for downloading embedded subscriptions.
Includes:
-getDownloadableSubscriptionMetadata, used by the platform and LUI to
fetch metadata about a downloadable subscription. The platform will
use this to perform the necessary permission checks (only allowing
otherwise-unprivileged apps to download profiles that are permitted
per the subscription metadata), and the LUI can use this to present
the name of the profile.
-downloadSubscription, to actually perform a profile download.
The stub for startResolutionActivity is included but not implemented;
resolution activities will be handled in a follow-up change.
==
Test: TreeHugger
Change-Id: I47b1da5a69f0736012cb137e02cd6c4e07fdaace
diff --git a/core/java/android/service/euicc/GetDownloadableSubscriptionMetadataResult.java b/core/java/android/service/euicc/GetDownloadableSubscriptionMetadataResult.java
new file mode 100644
index 0000000..b7f46fa
--- /dev/null
+++ b/core/java/android/service/euicc/GetDownloadableSubscriptionMetadataResult.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.IntDef;
+import android.annotation.Nullable;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.telephony.euicc.DownloadableSubscription;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Result of a {@link EuiccService#getDownloadableSubscriptionMetadata} operation.
+ * @hide
+ *
+ * TODO(b/35851809): Make this a SystemApi.
+ */
+public final class GetDownloadableSubscriptionMetadataResult implements Parcelable {
+
+ public static final 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 */
+ @IntDef({
+ RESULT_OK,
+ RESULT_GENERIC_ERROR,
+ RESULT_MUST_DEACTIVATE_REMOVABLE_SIM,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface ResultCode {}
+
+ public static final int RESULT_OK = 0;
+ public static final int RESULT_MUST_DEACTIVATE_REMOVABLE_SIM = 1;
+ public static final int RESULT_GENERIC_ERROR = 2;
+
+ /** Result of the operation - one of the RESULT_* constants. */
+ public final @ResultCode int result;
+
+ /**
+ * The {@link DownloadableSubscription} with filled-in metadata.
+ *
+ * <p>Only non-null if {@link #result} is {@link #RESULT_OK}.
+ */
+ @Nullable
+ public final DownloadableSubscription subscription;
+
+ /** Implementation-defined detailed error code in case of a failure not covered here. */
+ public final int detailedCode;
+
+ private GetDownloadableSubscriptionMetadataResult(int result,
+ @Nullable DownloadableSubscription subscription, int detailedCode) {
+ this.result = result;
+ this.subscription = subscription;
+ this.detailedCode = detailedCode;
+ }
+
+ private GetDownloadableSubscriptionMetadataResult(Parcel in) {
+ this.result = in.readInt();
+ this.subscription = DownloadableSubscription.CREATOR.createFromParcel(in);
+ this.detailedCode = in.readInt();
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(result);
+ this.subscription.writeToParcel(dest, 0);
+ dest.writeInt(detailedCode);
+ }
+
+ /** Return a result indicating that the download was successful. */
+ public static GetDownloadableSubscriptionMetadataResult success(
+ DownloadableSubscription subscription) {
+ return new GetDownloadableSubscriptionMetadataResult(RESULT_OK, subscription,
+ 0 /* detailedCode */);
+ }
+
+ /**
+ * Return a result indicating that the removable SIM must be deactivated to perform the
+ * operation.
+ */
+ public static GetDownloadableSubscriptionMetadataResult mustDeactivateRemovableSim() {
+ return new GetDownloadableSubscriptionMetadataResult(RESULT_MUST_DEACTIVATE_REMOVABLE_SIM,
+ null /* subscription */, 0 /* detailedCode */);
+ }
+
+ /**
+ * Return a result indicating that an error occurred for which no other more specific error
+ * code has been defined.
+ *
+ * @param detailedCode an implementation-defined detailed error code for debugging purposes.
+ */
+ public static GetDownloadableSubscriptionMetadataResult genericError(int detailedCode) {
+ return new GetDownloadableSubscriptionMetadataResult(RESULT_GENERIC_ERROR,
+ null /* subscription */, detailedCode);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+}
\ No newline at end of file