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

Commit 30a48d7a authored by Xiangyu/Malcolm Chen's avatar Xiangyu/Malcolm Chen Committed by Android (Google) Code Review
Browse files

Merge "Adding callback for setPreferredDataSubscriptionId."

parents b581ab29 b2b88b37
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -602,6 +602,7 @@ java_defaults {
        "telephony/java/com/android/internal/telephony/IOnSubscriptionsChangedListener.aidl",
        "telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl",
        "telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl",
        "telephony/java/com/android/internal/telephony/ISetOpportunisticDataCallback.aidl",
        "telephony/java/com/android/internal/telephony/ISms.aidl",
        "telephony/java/com/android/internal/telephony/ISub.aidl",
        "telephony/java/com/android/internal/telephony/IOns.aidl",
+3 −0
Original line number Diff line number Diff line
@@ -45242,6 +45242,9 @@ package android.telephony {
    field public static final int PHONE_TYPE_GSM = 1; // 0x1
    field public static final int PHONE_TYPE_NONE = 0; // 0x0
    field public static final int PHONE_TYPE_SIP = 3; // 0x3
    field public static final int SET_OPPORTUNISTIC_SUB_INVALID_PARAMETER = 2; // 0x2
    field public static final int SET_OPPORTUNISTIC_SUB_SUCCESS = 0; // 0x0
    field public static final int SET_OPPORTUNISTIC_SUB_VALIDATION_FAILED = 1; // 0x1
    field public static final int SIM_STATE_ABSENT = 1; // 0x1
    field public static final int SIM_STATE_CARD_IO_ERROR = 8; // 0x8
    field public static final int SIM_STATE_CARD_RESTRICTED = 9; // 0x9
+1 −0
Original line number Diff line number Diff line
@@ -7760,6 +7760,7 @@ package android.telephony {
    method public void requestEmbeddedSubscriptionInfoListRefresh(int);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDefaultDataSubId(int);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setDefaultSmsSubId(int);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void setPreferredDataSubscriptionId(int, boolean, @NonNull java.util.concurrent.Executor, java.util.function.Consumer<java.lang.Integer>);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setSubscriptionEnabled(int, boolean);
    field public static final android.net.Uri ADVANCED_CALLING_ENABLED_CONTENT_URI;
    field public static final int PROFILE_CLASS_DEFAULT = -1; // 0xffffffff
+24 −4
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ import android.util.DisplayMetrics;
import android.util.Log;

import com.android.internal.telephony.IOnSubscriptionsChangedListener;
import com.android.internal.telephony.ISetOpportunisticDataCallback;
import com.android.internal.telephony.ISub;
import com.android.internal.telephony.ITelephonyRegistry;
import com.android.internal.telephony.PhoneConstants;
@@ -72,6 +73,7 @@ import java.util.List;
import java.util.Locale;
import java.util.concurrent.Executor;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.stream.Collectors;

/**
@@ -2573,17 +2575,35 @@ public class SubscriptionManager {
     *              {@link SubscriptionManager#DEFAULT_SUBSCRIPTION_ID}, it means
     *              it's unset and {@link SubscriptionManager#getDefaultDataSubscriptionId()}
     *              is used to determine which modem is preferred.
     * @param needValidation whether validation is needed before switch happens.
     * @param executor The executor of where the callback will execute.
     * @param callback Callback will be triggered once it succeeds or failed.
     *                 See {@link TelephonyManager.SetOpportunisticSubscriptionResult}
     *                 for more details. Pass null if don't care about the result.
     *
     * @hide
     *
     */
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    public void setPreferredDataSubscriptionId(int subId) {
    public void setPreferredDataSubscriptionId(int subId, boolean needValidation,
            @NonNull @CallbackExecutor Executor executor, Consumer<Integer> callback) {
        if (VDBG) logd("[setPreferredDataSubscriptionId]+ subId:" + subId);
        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
            if (iSub != null) {
                iSub.setPreferredDataSubscriptionId(subId);
            if (iSub == null) return;

            ISetOpportunisticDataCallback callbackStub = new ISetOpportunisticDataCallback.Stub() {
                @Override
                public void onComplete(int result) {
                    Binder.withCleanCallingIdentity(() -> executor.execute(() -> {
                        if (callback != null) {
                            callback.accept(result);
                        }
                    }));
                }
            };
            iSub.setPreferredDataSubscriptionId(subId, needValidation, callbackStub);
        } catch (RemoteException ex) {
            // ignore it
        }
+23 −0
Original line number Diff line number Diff line
@@ -10094,6 +10094,29 @@ public class TelephonyManager {
        return false;
    }

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = {"SET_OPPORTUNISTIC_SUB"}, value = {
            SET_OPPORTUNISTIC_SUB_SUCCESS,
            SET_OPPORTUNISTIC_SUB_VALIDATION_FAILED,
            SET_OPPORTUNISTIC_SUB_INVALID_PARAMETER})
    public @interface SetOpportunisticSubscriptionResult {}

    /**
     * No error. Operation succeeded.
     */
    public static final int SET_OPPORTUNISTIC_SUB_SUCCESS = 0;

    /**
     * Validation failed when trying to switch to preferred subscription.
     */
    public static final int SET_OPPORTUNISTIC_SUB_VALIDATION_FAILED = 1;

    /**
     * The parameter passed in is invalid.
     */
    public static final int SET_OPPORTUNISTIC_SUB_INVALID_PARAMETER = 2;

    /**
     * Set preferred opportunistic data subscription id.
     *
Loading