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

Commit a335880e authored by danielwbhuang's avatar danielwbhuang
Browse files

Modify API return type and add callback.

1. Modify the type from boolean to void for updateAvailableNetworks().
2. Adding callback for updateAvailableNetworks().
3. Define error codes for update available networks results.

Test: build pass
Bug: 124616182
Merged-In: I32fe1407deabe36485227ec75931bec334d85abe
Change-Id: I32fe1407deabe36485227ec75931bec334d85abe
parent 06d80679
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -558,6 +558,7 @@ java_defaults {
        "telephony/java/com/android/internal/telephony/IOns.aidl",
        "telephony/java/com/android/internal/telephony/IOns.aidl",
        "telephony/java/com/android/internal/telephony/ITelephony.aidl",
        "telephony/java/com/android/internal/telephony/ITelephony.aidl",
        "telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl",
        "telephony/java/com/android/internal/telephony/ITelephonyRegistry.aidl",
        "telephony/java/com/android/internal/telephony/IUpdateAvailableNetworksCallback.aidl",
        "telephony/java/com/android/internal/telephony/IWapPushManager.aidl",
        "telephony/java/com/android/internal/telephony/IWapPushManager.aidl",
        "telephony/java/com/android/internal/telephony/euicc/IAuthenticateServerCallback.aidl",
        "telephony/java/com/android/internal/telephony/euicc/IAuthenticateServerCallback.aidl",
        "telephony/java/com/android/internal/telephony/euicc/ICancelSessionCallback.aidl",
        "telephony/java/com/android/internal/telephony/euicc/ICancelSessionCallback.aidl",
+6 −1
Original line number Original line Diff line number Diff line
@@ -43123,7 +43123,7 @@ package android.telephony {
    method @Deprecated public void setVoicemailRingtoneUri(android.telecom.PhoneAccountHandle, android.net.Uri);
    method @Deprecated public void setVoicemailRingtoneUri(android.telecom.PhoneAccountHandle, android.net.Uri);
    method @Deprecated public void setVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle, boolean);
    method @Deprecated public void setVoicemailVibrationEnabled(android.telecom.PhoneAccountHandle, boolean);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void switchMultiSimConfig(int);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void switchMultiSimConfig(int);
    method public boolean updateAvailableNetworks(java.util.List<android.telephony.AvailableNetworkInfo>);
    method public void updateAvailableNetworks(@NonNull java.util.List<android.telephony.AvailableNetworkInfo>, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
    field public static final String ACTION_CONFIGURE_VOICEMAIL = "android.telephony.action.CONFIGURE_VOICEMAIL";
    field public static final String ACTION_CONFIGURE_VOICEMAIL = "android.telephony.action.CONFIGURE_VOICEMAIL";
    field public static final String ACTION_NETWORK_COUNTRY_CHANGED = "android.telephony.action.NETWORK_COUNTRY_CHANGED";
    field public static final String ACTION_NETWORK_COUNTRY_CHANGED = "android.telephony.action.NETWORK_COUNTRY_CHANGED";
    field @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public static final String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE";
    field @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public static final String ACTION_PHONE_STATE_CHANGED = "android.intent.action.PHONE_STATE";
@@ -43215,6 +43215,11 @@ package android.telephony {
    field public static final int UNINITIALIZED_CARD_ID = -2; // 0xfffffffe
    field public static final int UNINITIALIZED_CARD_ID = -2; // 0xfffffffe
    field public static final int UNKNOWN_CARRIER_ID = -1; // 0xffffffff
    field public static final int UNKNOWN_CARRIER_ID = -1; // 0xffffffff
    field public static final int UNSUPPORTED_CARD_ID = -1; // 0xffffffff
    field public static final int UNSUPPORTED_CARD_ID = -1; // 0xffffffff
    field public static final int UPDATE_AVAILABLE_NETWORKS_ABORTED = 2; // 0x2
    field public static final int UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS = 3; // 0x3
    field public static final int UPDATE_AVAILABLE_NETWORKS_NO_CARRIER_PRIVILEGE = 4; // 0x4
    field public static final int UPDATE_AVAILABLE_NETWORKS_SUCCESS = 0; // 0x0
    field public static final int UPDATE_AVAILABLE_NETWORKS_UNKNOWN_FAILURE = 1; // 0x1
    field public static final int USSD_ERROR_SERVICE_UNAVAIL = -2; // 0xfffffffe
    field public static final int USSD_ERROR_SERVICE_UNAVAIL = -2; // 0xfffffffe
    field public static final int USSD_RETURN_FAILURE = -1; // 0xffffffff
    field public static final int USSD_RETURN_FAILURE = -1; // 0xffffffff
    field public static final String VVM_TYPE_CVVM = "vvm_type_cvvm";
    field public static final String VVM_TYPE_CVVM = "vvm_type_cvvm";
+2 −1
Original line number Original line Diff line number Diff line
@@ -2701,7 +2701,8 @@ public class SubscriptionManager {
     *  1) Even if it's active, it will be dormant most of the time. The modem will not try
     *  1) Even if it's active, it will be dormant most of the time. The modem will not try
     *     to scan or camp until it knows an available network is nearby to save power.
     *     to scan or camp until it knows an available network is nearby to save power.
     *  2) Telephony relies on system app or carrier input to notify nearby available networks.
     *  2) Telephony relies on system app or carrier input to notify nearby available networks.
     *     See {@link TelephonyManager#updateAvailableNetworks(List)} for more information.
     *     See {@link TelephonyManager#updateAvailableNetworks(List, Executor, Consumer)}
     *     for more information.
     *  3) In multi-SIM devices, when the network is nearby and camped, system may automatically
     *  3) In multi-SIM devices, when the network is nearby and camped, system may automatically
     *     switch internet data between it and default data subscription, based on carrier
     *     switch internet data between it and default data subscription, based on carrier
     *     recommendation and its signal strength and metered-ness, etc.
     *     recommendation and its signal strength and metered-ness, etc.
+66 −11
Original line number Original line Diff line number Diff line
@@ -83,6 +83,7 @@ import com.android.internal.telephony.IOns;
import com.android.internal.telephony.IPhoneSubInfo;
import com.android.internal.telephony.IPhoneSubInfo;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.ITelephonyRegistry;
import com.android.internal.telephony.ITelephonyRegistry;
import com.android.internal.telephony.IUpdateAvailableNetworksCallback;
import com.android.internal.telephony.OperatorInfo;
import com.android.internal.telephony.OperatorInfo;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.RILConstants;
import com.android.internal.telephony.RILConstants;
@@ -98,6 +99,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Locale;
import java.util.Map;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
import java.util.regex.Matcher;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.Pattern;


@@ -10132,6 +10134,41 @@ public class TelephonyManager {
     */
     */
    public static final int SET_OPPORTUNISTIC_SUB_INVALID_PARAMETER = 2;
    public static final int SET_OPPORTUNISTIC_SUB_INVALID_PARAMETER = 2;


    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = {"UPDATE_AVAILABLE_NETWORKS"}, value = {
            UPDATE_AVAILABLE_NETWORKS_SUCCESS,
            UPDATE_AVAILABLE_NETWORKS_UNKNOWN_FAILURE,
            UPDATE_AVAILABLE_NETWORKS_ABORTED,
            UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS,
            UPDATE_AVAILABLE_NETWORKS_NO_CARRIER_PRIVILEGE})
    public @interface UpdateAvailableNetworksResult {}

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

    /**
     * There is a unknown failure happened.
     */
    public static final int UPDATE_AVAILABLE_NETWORKS_UNKNOWN_FAILURE = 1;

    /**
     * The request is aborted.
     */
    public static final int UPDATE_AVAILABLE_NETWORKS_ABORTED = 2;

    /**
     * The parameter passed in is invalid.
     */
    public static final int UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS = 3;

    /**
     * No carrier privilege.
     */
    public static final int UPDATE_AVAILABLE_NETWORKS_NO_CARRIER_PRIVILEGE = 4;

    /**
    /**
     * Set preferred opportunistic data subscription id.
     * Set preferred opportunistic data subscription id.
     *
     *
@@ -10192,31 +10229,49 @@ public class TelephonyManager {
    /**
    /**
     * Update availability of a list of networks in the current location.
     * Update availability of a list of networks in the current location.
     *
     *
     * This api should be called to inform OpportunisticNetwork Service about the availability
     * This api should be called by opportunistic network selection app to inform
     * of a network at the current location. This information will be used by OpportunisticNetwork
     * OpportunisticNetwork Service about the availability of a network at the current location.
     * service to decide to attach to the network opportunistically. If an empty list is passed,
     * This information will be used by OpportunisticNetwork service to decide to attach to the
     * it is assumed that no network is available.
     * network opportunistically.
     * If an empty list is passed, it is assumed that no network is available.
     * Requires that the calling app has carrier privileges on both primary and
     * Requires that the calling app has carrier privileges on both primary and
     * secondary subscriptions (see {@link #hasCarrierPrivileges}), or has permission
     * secondary subscriptions (see {@link #hasCarrierPrivileges}), or has permission
     * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}.
     * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}.
     * @param availableNetworks is a list of available network information.
     * @param availableNetworks is a list of available network information.
     * @return true if request is accepted
     * @param executor The executor of where the callback will execute.
     * @param callback Callback will be triggered once it succeeds or failed.
     *
     *
     */
     */
    @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
    @SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
    public boolean updateAvailableNetworks(List<AvailableNetworkInfo> availableNetworks) {
    public void updateAvailableNetworks(@NonNull List<AvailableNetworkInfo> availableNetworks,
            @Nullable @CallbackExecutor Executor executor,
            @UpdateAvailableNetworksResult @Nullable Consumer<Integer> callback) {
        String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>";
        String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>";
        boolean ret = false;
        try {
        try {
            IOns iOpportunisticNetworkService = getIOns();
            IOns iOpportunisticNetworkService = getIOns();
            if (iOpportunisticNetworkService != null && availableNetworks != null) {
            if (iOpportunisticNetworkService == null || availableNetworks == null) {
                ret = iOpportunisticNetworkService.updateAvailableNetworks(availableNetworks,
                Binder.withCleanCallingIdentity(() -> executor.execute(() -> {
                        pkgForDebug);
                    callback.accept(UPDATE_AVAILABLE_NETWORKS_INVALID_ARGUMENTS);
                }));
                return;
            }
            }
            IUpdateAvailableNetworksCallback callbackStub =
                    new IUpdateAvailableNetworksCallback.Stub() {
                        @Override
                        public void onComplete(int result) {
                            if (executor == null || callback == null) {
                                return;
                            }
                            Binder.withCleanCallingIdentity(() -> executor.execute(() -> {
                                callback.accept(result);
                            }));
                        }
                    };
            iOpportunisticNetworkService.updateAvailableNetworks(availableNetworks, callbackStub,
                    pkgForDebug);
        } catch (RemoteException ex) {
        } catch (RemoteException ex) {
            Rlog.e(TAG, "updateAvailableNetworks RemoteException", ex);
            Rlog.e(TAG, "updateAvailableNetworks RemoteException", ex);
        }
        }
        return ret;
    }
    }


    /**
    /**
+4 −3
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.internal.telephony;
package com.android.internal.telephony;


import android.telephony.AvailableNetworkInfo;
import android.telephony.AvailableNetworkInfo;
import com.android.internal.telephony.IUpdateAvailableNetworksCallback;


interface IOns {
interface IOns {


@@ -93,9 +94,9 @@ interface IOns {
     * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}.
     * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}.
     *  @param availableNetworks is a list of available network information.
     *  @param availableNetworks is a list of available network information.
     *  @param callingPackage caller's package name
     *  @param callingPackage caller's package name
     *  @return true if request is accepted
     *  @param callback callback upon request completion.
     *
     *
     */
     */
    boolean updateAvailableNetworks(in List<AvailableNetworkInfo> availableNetworks,
    void updateAvailableNetworks(in List<AvailableNetworkInfo> availableNetworks,
            String callingPackage);
            IUpdateAvailableNetworksCallback callbackStub, String callingPackage);
}
}
Loading