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

Commit 31c7607e authored by Sooraj Sasindran's avatar Sooraj Sasindran Committed by Gerrit Code Review
Browse files

Merge changes from topic "Porting-ONSAPIChanges"

* changes:
  Should not turn on validation for data
  Provide network bands in AvailableNetworkInfo
parents 16eab7c1 3b09d711
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -42099,9 +42099,10 @@ package android.telephony {
  }
  public final class AvailableNetworkInfo implements android.os.Parcelable {
    ctor public AvailableNetworkInfo(int, int, java.util.List<java.lang.String>);
    ctor public AvailableNetworkInfo(int, int, @NonNull java.util.List<java.lang.String>, @NonNull java.util.List<java.lang.Integer>);
    method public int describeContents();
    method public java.util.List<java.lang.String> getMccMncs();
    method @NonNull public java.util.List<java.lang.Integer> getBands();
    method @NonNull public java.util.List<java.lang.String> getMccMncs();
    method public int getPriority();
    method public int getSubId();
    method public void writeToParcel(android.os.Parcel, int);
@@ -43117,7 +43118,7 @@ package android.telephony {
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setNetworkSelectionModeManual(String, boolean);
    method public boolean setOperatorBrandOverride(String);
    method public boolean setPreferredNetworkTypeToGlobal();
    method public boolean setPreferredOpportunisticDataSubscription(int);
    method public void setPreferredOpportunisticDataSubscription(int, boolean, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
    method public void setVisualVoicemailSmsFilterSettings(android.telephony.VisualVoicemailSmsFilterSettings);
    method public boolean setVoiceMailNumber(String, String);
    method @Deprecated public void setVoicemailRingtoneUri(android.telecom.PhoneAccountHandle, android.net.Uri);
+1 −1
Original line number Diff line number Diff line
@@ -6314,7 +6314,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 void setPreferredDataSubscriptionId(int, boolean, @Nullable java.util.concurrent.Executor, @Nullable java.util.function.Consumer<java.lang.Integer>);
    method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public boolean setSubscriptionEnabled(int, boolean);
    field @NonNull public static final android.net.Uri ADVANCED_CALLING_ENABLED_CONTENT_URI;
    field public static final int PROFILE_CLASS_DEFAULT = -1; // 0xffffffff
+39 −11
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.telephony;

import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;

@@ -62,10 +63,21 @@ public final class AvailableNetworkInfo implements Parcelable {
    /**
     * Describes the List of PLMN ids (MCC-MNC) associated with mSubId.
     * If this entry is left empty, then the platform software will not scan the network
     * to revalidate the input.
     * to revalidate the input else platform will scan and verify specified PLMNs are available.
     */
    private ArrayList<String> mMccMncs;

    /**
     * Returns the frequency bands associated with the {@link #getMccMncs() MCC/MNCs}.
     * Opportunistic network service will use these bands to scan.
     *
     * When no specific bands are specified (empty array or null) CBRS band (B48) will be
     * used for network scan.
     *
     * See {@link AccessNetworkConstants} for details.
     */
    private ArrayList<Integer> mBands;

    /**
     * Return subscription Id of the available network.
     * This value must be one of the entry retrieved from
@@ -91,10 +103,20 @@ public final class AvailableNetworkInfo implements Parcelable {
     * to revalidate the input.
     * @return list of PLMN ids
     */
    public List<String> getMccMncs() {
    public @NonNull List<String> getMccMncs() {
        return (List<String>) mMccMncs.clone();
    }

    /**
     * Returns the frequency bands that need to be scanned by opportunistic network service
     *
     * The returned value is defined in either of {@link AccessNetworkConstants.GeranBand},
     * {@link AccessNetworkConstants.UtranBand} and {@link AccessNetworkConstants.EutranBand}
     */
    public @NonNull List<Integer> getBands() {
        return (List<Integer>) mBands.clone();
    }

    @Override
    public int describeContents() {
        return 0;
@@ -105,6 +127,7 @@ public final class AvailableNetworkInfo implements Parcelable {
        dest.writeInt(mSubId);
        dest.writeInt(mPriority);
        dest.writeStringList(mMccMncs);
        dest.writeList(mBands);
    }

    private AvailableNetworkInfo(Parcel in) {
@@ -112,12 +135,16 @@ public final class AvailableNetworkInfo implements Parcelable {
        mPriority = in.readInt();
        mMccMncs = new ArrayList<>();
        in.readStringList(mMccMncs);
        mBands = new ArrayList<>();
        in.readList(mBands, Integer.class.getClassLoader());
    }

    public AvailableNetworkInfo(int subId, int priority, List<String> mccMncs) {
    public AvailableNetworkInfo(int subId, int priority, @NonNull List<String> mccMncs,
            @NonNull List<Integer> bands) {
        mSubId = subId;
        mPriority = priority;
        mMccMncs = new ArrayList<String>(mccMncs);
        mBands = new ArrayList<Integer>(bands);
    }

    @Override
@@ -137,12 +164,13 @@ public final class AvailableNetworkInfo implements Parcelable {
        return (mSubId == ani.mSubId
            && mPriority == ani.mPriority
            && (((mMccMncs != null)
                && mMccMncs.equals(ani.mMccMncs))));
            && mMccMncs.equals(ani.mMccMncs)))
            && mBands.equals(ani.mBands));
    }

    @Override
    public int hashCode() {
        return Objects.hash(mSubId, mPriority, mMccMncs);
        return Objects.hash(mSubId, mPriority, mMccMncs, mBands);
    }

    public static final Parcelable.Creator<AvailableNetworkInfo> CREATOR =
@@ -163,7 +191,7 @@ public final class AvailableNetworkInfo implements Parcelable {
        return ("AvailableNetworkInfo:"
            + " mSubId: " + mSubId
            + " mPriority: " + mPriority
                + " mMccMncs: " + Arrays.toString(mMccMncs.toArray()));
            + " mMccMncs: " + Arrays.toString(mMccMncs.toArray())
            + " mBands: " + Arrays.toString(mBands.toArray()));
    }
}
+5 −4
Original line number Diff line number Diff line
@@ -2606,7 +2606,7 @@ public class SubscriptionManager {
    @SystemApi
    @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
    public void setPreferredDataSubscriptionId(int subId, boolean needValidation,
            @NonNull @CallbackExecutor Executor executor, Consumer<Integer> callback) {
            @Nullable @CallbackExecutor Executor executor, @Nullable  Consumer<Integer> callback) {
        if (VDBG) logd("[setPreferredDataSubscriptionId]+ subId:" + subId);
        try {
            ISub iSub = ISub.Stub.asInterface(ServiceManager.getService("isub"));
@@ -2615,10 +2615,11 @@ public class SubscriptionManager {
            ISetOpportunisticDataCallback callbackStub = new ISetOpportunisticDataCallback.Stub() {
                @Override
                public void onComplete(int result) {
                    if (executor == null || callback == null) {
                        return;
                    }
                    Binder.withCleanCallingIdentity(() -> executor.execute(() -> {
                        if (callback != null) {
                        callback.accept(result);
                        }
                    }));
                }
            };
+31 −11
Original line number Diff line number Diff line
@@ -81,6 +81,7 @@ import com.android.internal.telephony.CellNetworkScanResult;
import com.android.internal.telephony.INumberVerificationCallback;
import com.android.internal.telephony.IOns;
import com.android.internal.telephony.IPhoneSubInfo;
import com.android.internal.telephony.ISetOpportunisticDataCallback;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.ITelephonyRegistry;
import com.android.internal.telephony.IUpdateAvailableNetworksCallback;
@@ -10195,21 +10196,40 @@ public class TelephonyManager {
     * @param subId which opportunistic subscription
     * {@link SubscriptionManager#getOpportunisticSubscriptions} is preferred for cellular data.
     * Pass {@link SubscriptionManager#DEFAULT_SUBSCRIPTION_ID} to unset the preference
     * @return true if request is accepted, else false.
     * @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.
     *
     */
    public boolean setPreferredOpportunisticDataSubscription(int subId) {
    public void setPreferredOpportunisticDataSubscription(int subId, boolean needValidation,
            @Nullable @CallbackExecutor Executor executor, @Nullable Consumer<Integer> callback) {
        String pkgForDebug = mContext != null ? mContext.getOpPackageName() : "<unknown>";
        try {
            IOns iOpportunisticNetworkService = getIOns();
            if (iOpportunisticNetworkService != null) {
                return iOpportunisticNetworkService
                        .setPreferredDataSubscriptionId(subId, pkgForDebug);
            if (iOpportunisticNetworkService == null) {
                return;
            }
            ISetOpportunisticDataCallback callbackStub = new ISetOpportunisticDataCallback.Stub() {
                @Override
                public void onComplete(int result) {
                    if (executor == null || callback == null) {
                        return;
                    }
                    Binder.withCleanCallingIdentity(() -> executor.execute(() -> {
                        callback.accept(result);
                    }));
                }
            };

            iOpportunisticNetworkService
                    .setPreferredDataSubscriptionId(subId, needValidation, callbackStub,
                            pkgForDebug);
        } catch (RemoteException ex) {
            Rlog.e(TAG, "setPreferredDataSubscriptionId RemoteException", ex);
        }
        return false;
        return;
    }

    /**
@@ -10244,11 +10264,11 @@ public class TelephonyManager {
    /**
     * Update availability of a list of networks in the current location.
     *
     * This api should be called by opportunistic network selection app to inform
     * OpportunisticNetwork Service about the availability of a network at the current location.
     * This information will be used by OpportunisticNetwork service to decide to attach to the
     * network opportunistically.
     * If an empty list is passed, it is assumed that no network is available.
     * This api should be called to inform OpportunisticNetwork Service about the availability
     * of a network at the current location. This information will be used by OpportunisticNetwork
     * service to decide to attach to the network opportunistically. If an empty list is passed,
     * it is assumed that no network is available and will result in disabling the modem stack
     * to save power.
     * Requires that the calling app has carrier privileges on both primary and
     * secondary subscriptions (see {@link #hasCarrierPrivileges}), or has permission
     * {@link android.Manifest.permission#MODIFY_PHONE_STATE MODIFY_PHONE_STATE}.
Loading