Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e7bf9e3 authored by Jiuyu Sun's avatar Jiuyu Sun Committed by Android (Google) Code Review
Browse files

Merge "Add EuiccCardManager and EuiccCardController."

parents 606c532d 5c11024d
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -519,7 +519,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/IWifiAwareDiscoverySessionCallback.aidl",
        "wifi/java/android/net/wifi/aware/IWifiAwareEventCallback.aidl",
+8 −0
Original line number Diff line number Diff line
@@ -136,6 +136,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.util.StatsManager;
@@ -519,6 +520,13 @@ final class SystemServiceRegistry {
                return new EuiccManager(ctx.getOuterContext());
            }});

        registerService(Context.EUICC_CARD_SERVICE, EuiccCardManager.class,
                new CachedServiceFetcher<EuiccCardManager>() {
                    @Override
                    public EuiccCardManager createService(ContextImpl ctx) {
                        return new EuiccCardManager(ctx.getOuterContext());
                    }});

        registerService(Context.UI_MODE_SERVICE, UiModeManager.class,
                new CachedServiceFetcher<UiModeManager>() {
            @Override
+11 −0
Original line number Diff line number Diff line
@@ -3658,6 +3658,17 @@ public abstract class Context {
     */
    public static final String EUICC_SERVICE = "euicc_service";

    /**
     * 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
+18 −0
Original line number Diff line number Diff line
/*
 * 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;
+88 −0
Original line number Diff line number Diff line
/*
 * 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 <T> Type of the result.
     */
    public interface ResultCallback<T> {
        /**
         * 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<EuiccProfileInfo[]> 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();
        }
    }
}
Loading