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

Commit b16594c0 authored by Rafael Higuera Silva's avatar Rafael Higuera Silva
Browse files

Add APIs for available memory on eUICC.

Add an API that allows other apps to know about the available
non-volatile memory on the eUICC. When querying the api, the
app needs to have: READ_PHONE_STATE permission or
READ_PHONE_STATE_PRIVILEGED or carrier privilege.

Bug: 312793756
Test: m, atest EuiccServiceTest EuiccConnectorTest EuiccControllerTest EuiccManagerTest CtsTelephony2TestCases
Change-Id: Ibbb2cdd9edee188e328c6e0eebe8e436ec355d1e
parent 5f5068de
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -46301,6 +46301,7 @@ package android.telephony.euicc {
    method @NonNull public android.telephony.euicc.EuiccManager createForCardId(int);
    method @RequiresPermission("android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS") public void deleteSubscription(int, android.app.PendingIntent);
    method @RequiresPermission("android.permission.WRITE_EMBEDDED_SUBSCRIPTIONS") public void downloadSubscription(android.telephony.euicc.DownloadableSubscription, boolean, android.app.PendingIntent);
    method @FlaggedApi("com.android.internal.telephony.flags.esim_available_memory") @RequiresPermission(anyOf={android.Manifest.permission.READ_PHONE_STATE, "android.permission.READ_PRIVILEGED_PHONE_STATE", "carrier privileges"}) public long getAvailableMemoryInBytes();
    method @Nullable public String getEid();
    method @Nullable public android.telephony.euicc.EuiccInfo getEuiccInfo();
    method public boolean isEnabled();
@@ -46333,6 +46334,7 @@ package android.telephony.euicc {
    field public static final int ERROR_SIM_MISSING = 10008; // 0x2718
    field public static final int ERROR_TIME_OUT = 10005; // 0x2715
    field public static final int ERROR_UNSUPPORTED_VERSION = 10007; // 0x2717
    field @FlaggedApi("com.android.internal.telephony.flags.esim_available_memory") public static final long EUICC_MEMORY_FIELD_UNAVAILABLE = -1L; // 0xffffffffffffffffL
    field public static final String EXTRA_EMBEDDED_SUBSCRIPTION_DETAILED_CODE = "android.telephony.euicc.extra.EMBEDDED_SUBSCRIPTION_DETAILED_CODE";
    field public static final String EXTRA_EMBEDDED_SUBSCRIPTION_DOWNLOADABLE_SUBSCRIPTION = "android.telephony.euicc.extra.EMBEDDED_SUBSCRIPTION_DOWNLOADABLE_SUBSCRIPTION";
    field public static final String EXTRA_EMBEDDED_SUBSCRIPTION_ERROR_CODE = "android.telephony.euicc.extra.EMBEDDED_SUBSCRIPTION_ERROR_CODE";
+1 −0
Original line number Diff line number Diff line
@@ -12400,6 +12400,7 @@ package android.service.euicc {
    method @Deprecated public int onDownloadSubscription(int, @NonNull android.telephony.euicc.DownloadableSubscription, boolean, boolean);
    method @Deprecated public abstract int onEraseSubscriptions(int);
    method public int onEraseSubscriptions(int, int);
    method @FlaggedApi("com.android.internal.telephony.flags.esim_available_memory") public long onGetAvailableMemoryInBytes(int);
    method public abstract android.service.euicc.GetDefaultDownloadableSubscriptionListResult onGetDefaultDownloadableSubscriptionList(int, boolean);
    method public abstract android.service.euicc.GetDownloadableSubscriptionMetadataResult onGetDownloadableSubscriptionMetadata(int, android.telephony.euicc.DownloadableSubscription, boolean);
    method @NonNull public android.service.euicc.GetDownloadableSubscriptionMetadataResult onGetDownloadableSubscriptionMetadata(int, int, @NonNull android.telephony.euicc.DownloadableSubscription, boolean);
+33 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import static android.telephony.euicc.EuiccCardManager.ResetOption;

import android.Manifest;
import android.annotation.CallSuper;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -38,6 +39,8 @@ import android.telephony.euicc.EuiccManager.OtaStatus;
import android.text.TextUtils;
import android.util.Log;

import com.android.internal.telephony.flags.Flags;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.annotation.Retention;
@@ -758,6 +761,20 @@ public abstract class EuiccService extends Service {
     */
    public abstract int onRetainSubscriptionsForFactoryReset(int slotId);

    /**
     * Return the available memory in bytes of the eUICC.
     *
     * @param slotId ID of the SIM slot being queried.
     * @return the available memory in bytes.
     * @see android.telephony.euicc.EuiccManager#getAvailableMemoryInBytes
     */
    @FlaggedApi(Flags.FLAG_ESIM_AVAILABLE_MEMORY)
    public long onGetAvailableMemoryInBytes(int slotId) {
        // stub implementation, LPA needs to implement this
        throw new UnsupportedOperationException("The connected LPA does not implement"
                + "EuiccService#onGetAvailableMemoryInBytes(int)");
    }

    /**
     * Dump to a provided printWriter.
     */
@@ -833,6 +850,22 @@ public abstract class EuiccService extends Service {
            });
        }

        @Override
        @FlaggedApi(Flags.FLAG_ESIM_AVAILABLE_MEMORY)
        public void getAvailableMemoryInBytes(
                int slotId, IGetAvailableMemoryInBytesCallback callback) {
            mExecutor.execute(
                    () -> {
                        long availableMemoryInBytes =
                                EuiccService.this.onGetAvailableMemoryInBytes(slotId);
                        try {
                            callback.onSuccess(availableMemoryInBytes);
                        } catch (RemoteException e) {
                            // Can't communicate with the phone process; ignore.
                        }
                    });
        }

        @Override
        public void startOtaIfNecessary(
                int slotId, IOtaStatusChangedCallback statusChangedCallback) {
+3 −1
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.service.euicc;
import android.service.euicc.IDeleteSubscriptionCallback;
import android.service.euicc.IDownloadSubscriptionCallback;
import android.service.euicc.IEraseSubscriptionsCallback;
import android.service.euicc.IGetAvailableMemoryInBytesCallback;
import android.service.euicc.IGetDefaultDownloadableSubscriptionListCallback;
import android.service.euicc.IGetDownloadableSubscriptionMetadataCallback;
import android.service.euicc.IGetEidCallback;
@@ -60,4 +61,5 @@ oneway interface IEuiccService {
    void retainSubscriptionsForFactoryReset(
            int slotId, in IRetainSubscriptionsForFactoryResetCallback callback);
    void dump(in IEuiccServiceDumpResultCallback callback);
    void getAvailableMemoryInBytes(int slotId, in IGetAvailableMemoryInBytesCallback callback);
}
+22 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 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 IGetAvailableMemoryInBytesCallback {
    void onSuccess(long availableMemoryInBytes);
}
Loading