From 3d6b53c075cf6d8dc5934baac45768b253d93bd1 Mon Sep 17 00:00:00 2001 From: Holly Jiuyu Sun Date: Thu, 21 Dec 2017 18:44:59 -0800 Subject: [PATCH] Add EuiccCardManager and EuiccCardController. EuiccCardManager is in the same path with EuiccManager. EuiccCardController is in the same path with EuiccController. Use getAllProfiles() as an example interface. The implementation of EuiccCard and its content will be added in a follow up CL. The new API is marked as @hide and TODO for @SystemApi. Bug: 38206971 Test: test on phone Change-Id: I153937c0f79bdd1a00b06b234a6e254a3f43072c Merged-In: I153937c0f79bdd1a00b06b234a6e254a3f43072c --- Android.bp | 2 + .../android/app/SystemServiceRegistry.java | 12 ++- core/java/android/content/Context.java | 14 ++- .../service/euicc/EuiccProfileInfo.aidl | 18 ++++ .../telephony/euicc/EuiccCardManager.java | 88 +++++++++++++++++++ .../telephony/euicc/IEuiccCardController.aidl | 24 +++++ .../euicc/IGetAllProfilesCallback.aidl | 23 +++++ 7 files changed, 177 insertions(+), 4 deletions(-) create mode 100644 core/java/android/service/euicc/EuiccProfileInfo.aidl create mode 100644 telephony/java/android/telephony/euicc/EuiccCardManager.java create mode 100644 telephony/java/com/android/internal/telephony/euicc/IEuiccCardController.aidl create mode 100644 telephony/java/com/android/internal/telephony/euicc/IGetAllProfilesCallback.aidl diff --git a/Android.bp b/Android.bp index 34cc52c466939..facc741578e07 100644 --- a/Android.bp +++ b/Android.bp @@ -510,7 +510,9 @@ java_library { "telephony/java/com/android/internal/telephony/ITelephony.aidl", "telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl", "telephony/java/com/android/internal/telephony/IWapPushManager.aidl", + "telephony/java/com/android/internal/telephony/euicc/IEuiccCardController.aidl", "telephony/java/com/android/internal/telephony/euicc/IEuiccController.aidl", + "telephony/java/com/android/internal/telephony/euicc/IGetAllProfilesCallback.aidl", "wifi/java/android/net/wifi/IWifiManager.aidl", "wifi/java/android/net/wifi/aware/IWifiAwareEventCallback.aidl", "wifi/java/android/net/wifi/aware/IWifiAwareManager.aidl", diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index ab70f0e712161..97c668117ee03 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -81,10 +81,10 @@ import android.net.INetworkPolicyManager; import android.net.IpSecManager; import android.net.NetworkPolicyManager; import android.net.NetworkScoreManager; -import android.net.nsd.INsdManager; -import android.net.nsd.NsdManager; import android.net.lowpan.ILowpanManager; import android.net.lowpan.LowpanManager; +import android.net.nsd.INsdManager; +import android.net.nsd.NsdManager; import android.net.wifi.IRttManager; import android.net.wifi.IWifiManager; import android.net.wifi.IWifiScanner; @@ -130,6 +130,7 @@ import android.telecom.TelecomManager; import android.telephony.CarrierConfigManager; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; +import android.telephony.euicc.EuiccCardManager; import android.telephony.euicc.EuiccManager; import android.util.Log; import android.view.ContextThemeWrapper; @@ -504,6 +505,13 @@ final class SystemServiceRegistry { return new EuiccManager(ctx.getOuterContext()); }}); + registerService(Context.EUICC_CARD_SERVICE, EuiccCardManager.class, + new CachedServiceFetcher() { + @Override + public EuiccCardManager createService(ContextImpl ctx) { + return new EuiccCardManager(ctx.getOuterContext()); + }}); + registerService(Context.UI_MODE_SERVICE, UiModeManager.class, new CachedServiceFetcher() { @Override diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 7e2ac63728419..70087daf51926 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -3589,8 +3589,18 @@ public abstract class Context { public static final String EUICC_SERVICE = "euicc_service"; /** - * Use with {@link #getSystemService} to retrieve a - * {@link android.text.ClipboardManager} for accessing and modifying + * Use with {@link #getSystemService(String)} to retrieve a + * {@link android.telephony.euicc.EuiccCardManager} to access the device eUICC (embedded SIM). + * + * @see #getSystemService(String) + * @see android.telephony.euicc.EuiccCardManager + * TODO(b/35851809): Make this a SystemApi. + * @hide + */ + public static final String EUICC_CARD_SERVICE = "euicc_card_service"; + + /** + * Use with {@link #getSystemService(String)} to retrieve a * {@link android.content.ClipboardManager} for accessing and modifying * the contents of the global clipboard. * diff --git a/core/java/android/service/euicc/EuiccProfileInfo.aidl b/core/java/android/service/euicc/EuiccProfileInfo.aidl new file mode 100644 index 0000000000000..321021b5273c9 --- /dev/null +++ b/core/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/telephony/euicc/EuiccCardManager.java b/telephony/java/android/telephony/euicc/EuiccCardManager.java new file mode 100644 index 0000000000000..29849c1f9ccdb --- /dev/null +++ b/telephony/java/android/telephony/euicc/EuiccCardManager.java @@ -0,0 +1,88 @@ +/* + * 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.telephony.euicc; + +import android.content.Context; +import android.os.RemoteException; +import android.os.ServiceManager; +import android.service.euicc.EuiccProfileInfo; +import android.util.Log; + +import com.android.internal.telephony.euicc.IEuiccCardController; +import com.android.internal.telephony.euicc.IGetAllProfilesCallback; + +/** + * EuiccCardManager is the application interface to an eSIM card. + * + * @hide + * + * TODO(b/35851809): Make this a SystemApi. + */ +public class EuiccCardManager { + private static final String TAG = "EuiccCardManager"; + + /** Result code of execution with no error. */ + public static final int RESULT_OK = 0; + + /** + * Callback to receive the result of an eUICC card API. + * + * @param Type of the result. + */ + public interface ResultCallback { + /** + * This method will be called when an eUICC card API call is completed. + * + * @param resultCode This can be {@link #RESULT_OK} or other positive values returned by the + * eUICC. + * @param result The result object. It can be null if the {@code resultCode} is not + * {@link #RESULT_OK}. + */ + void onComplete(int resultCode, T result); + } + + private final Context mContext; + + /** @hide */ + public EuiccCardManager(Context context) { + mContext = context; + } + + private IEuiccCardController getIEuiccCardController() { + return IEuiccCardController.Stub.asInterface( + ServiceManager.getService("euicc_card_controller")); + } + + /** + * Gets all the profiles on eUicc. + * + * @param callback the callback to get the result code and all the profiles. + */ + public void getAllProfiles(ResultCallback callback) { + try { + getIEuiccCardController().getAllProfiles(mContext.getOpPackageName(), + new IGetAllProfilesCallback.Stub() { + @Override + public void onComplete(int resultCode, EuiccProfileInfo[] profiles) { + callback.onComplete(resultCode, profiles); + } + }); + } catch (RemoteException e) { + Log.e(TAG, "Error calling getAllProfiles", e); + throw e.rethrowFromSystemServer(); + } + } +} diff --git a/telephony/java/com/android/internal/telephony/euicc/IEuiccCardController.aidl b/telephony/java/com/android/internal/telephony/euicc/IEuiccCardController.aidl new file mode 100644 index 0000000000000..2846a1ad1f9f4 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/euicc/IEuiccCardController.aidl @@ -0,0 +1,24 @@ +/* + * 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 com.android.internal.telephony.euicc; + +import com.android.internal.telephony.euicc.IGetAllProfilesCallback; + +/** @hide */ +interface IEuiccCardController { + oneway void getAllProfiles(String callingPackage, in IGetAllProfilesCallback callback); +} diff --git a/telephony/java/com/android/internal/telephony/euicc/IGetAllProfilesCallback.aidl b/telephony/java/com/android/internal/telephony/euicc/IGetAllProfilesCallback.aidl new file mode 100644 index 0000000000000..97b0768465348 --- /dev/null +++ b/telephony/java/com/android/internal/telephony/euicc/IGetAllProfilesCallback.aidl @@ -0,0 +1,23 @@ +/* + * 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 com.android.internal.telephony.euicc; + +import android.service.euicc.EuiccProfileInfo; + +/** @hide */ +oneway interface IGetAllProfilesCallback { + void onComplete(int resultCode, in EuiccProfileInfo[] profiles); +}