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

Commit 8d2c1597 authored by Jack Nudelman's avatar Jack Nudelman
Browse files

Enable specification of 5G network info and carrier configs for ONS changes

Bug: 191878731
Bug: 186688084
Test: Will test locally once partner device and infrastructure is ready.

Change-Id: I7c866741dd86c3d675ea7c4dfe50d0992ab145f1
Merged-In: I7c866741dd86c3d675ea7c4dfe50d0992ab145f1
parent 1f5ba0b2
Loading
Loading
Loading
Loading
+115 −4
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.telephony;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.RadioAccessSpecifier;

import java.util.ArrayList;
import java.util.Arrays;
@@ -76,12 +77,27 @@ public final class AvailableNetworkInfo implements Parcelable {
     * Opportunistic network service will use these bands to scan.
     *
     * When no specific bands are specified (empty array or null) CBRS band
     * {@link AccessNetworkConstants.EutranBand.BAND_48} will be used for network scan.
     * {@link AccessNetworkConstants.EutranBand.BAND_48
     * } will be used for network scan.
     *
     * See {@link AccessNetworkConstants} for details.
     *
     * @deprecated use {@link #mRadioAccessSpecifiers} instead
     */
    @Deprecated
    private ArrayList<Integer> mBands;

    /**
     * Returns a list of {@link RadioAccessSpecifier} associated with the available network.
     * Opportunistic network service will use this to determine which bands to scan for.
     *
     * If this entry is left empty, {@link RadioAcccessSpecifier}s with {@link AccessNetworkType}s
     * of {@link AccessNetworkConstants.AccessNetworkType.EUTRAN} and {@link
     * AccessNetworkConstants.AccessNetworkType.NGRAN} with bands 48 and 71 on each will be assumed
     * by Opportunistic network service.
     */
    private ArrayList<RadioAccessSpecifier> mRadioAccessSpecifiers;

    /**
     * Return subscription Id of the available network.
     * This value must be one of the entry retrieved from
@@ -129,6 +145,22 @@ public final class AvailableNetworkInfo implements Parcelable {
        return (List<Integer>) mBands.clone();
    }

    /**
     * Returns a list of {@link RadioAccessSpecifier} associated with the available network.
     * Opportunistic network service will use this to determine which bands to scan for.
     *
     * the returned value is one of {@link AccessNetworkConstants.AccessNetworkType}. When no
     * specific access network type is specified, {@link RadioAccessSpecifier}s with {@link
     * AccessNetworkType}s of {@link AccessNetworkConstants.AccessNetworkType.EUTRAN} and {@link
     * AccessNetworkConstants.AccessNetworkType.NGRAN} with bands 48 and 71 on each will be assumed
     * by Opportunistic network service.
     * @return the access network type associated with the available network.
     * @hide
     */
    public List<RadioAccessSpecifier>  getRadioAccessSpecifiers() {
        return (List<RadioAccessSpecifier>) mRadioAccessSpecifiers.clone();
    }

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

    private AvailableNetworkInfo(Parcel in) {
@@ -149,14 +182,25 @@ public final class AvailableNetworkInfo implements Parcelable {
        in.readStringList(mMccMncs);
        mBands = new ArrayList<>();
        in.readList(mBands, Integer.class.getClassLoader());
        mRadioAccessSpecifiers = new ArrayList<>();
        in.readList(mRadioAccessSpecifiers, RadioAccessSpecifier.class.getClassLoader());
    }

    public AvailableNetworkInfo(int subId, int priority, @NonNull List<String> mccMncs,
            @NonNull List<Integer> bands) {
        this(subId, priority, mccMncs, bands,
                new ArrayList<RadioAccessSpecifier>());
    }

    /** @hide */
    private AvailableNetworkInfo(int subId, int priority, @NonNull List<String> mccMncs,
            @NonNull List<Integer> bands, @NonNull List<RadioAccessSpecifier>
            radioAccessSpecifiers) {
        mSubId = subId;
        mPriority = priority;
        mMccMncs = new ArrayList<String>(mccMncs);
        mBands = new ArrayList<Integer>(bands);
        mRadioAccessSpecifiers = new ArrayList<RadioAccessSpecifier>(radioAccessSpecifiers);
    }

    @Override
@@ -177,12 +221,13 @@ public final class AvailableNetworkInfo implements Parcelable {
            && mPriority == ani.mPriority
            && (((mMccMncs != null)
            && mMccMncs.equals(ani.mMccMncs)))
            && mBands.equals(ani.mBands));
            && mBands.equals(ani.mBands))
            && mRadioAccessSpecifiers.equals(ani.getRadioAccessSpecifiers());
    }

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

    public static final @android.annotation.NonNull Parcelable.Creator<AvailableNetworkInfo> CREATOR =
@@ -204,6 +249,72 @@ public final class AvailableNetworkInfo implements Parcelable {
            + " mSubId: " + mSubId
            + " mPriority: " + mPriority
            + " mMccMncs: " + Arrays.toString(mMccMncs.toArray())
            + " mBands: " + Arrays.toString(mBands.toArray()));
            + " mBands: " + Arrays.toString(mBands.toArray())
            + " mRadioAccessSpecifiers: " + Arrays.toString(mRadioAccessSpecifiers.toArray()));
    }

    /**
     * Provides a convenient way to set the fields of a {@link AvailableNetworkInfo} when
     * creating a new instance.
     *
     * <p>The example below shows how you might create a new {@code AvailableNetworkInfo}:
     *
     * <pre><code>
     *
     * AvailableNetworkInfo aNI = new AvailableNetworkInfo.Builder()
     *     .setSubId(1)
     *     .setPriority(AvailableNetworkInfo.PRIORITY_MED)
     *     .build();
     * </code></pre>
     *
     * @hide
     */
    public static final class Builder {
        private int mSubId = Integer.MIN_VALUE;
        private int mPriority = AvailableNetworkInfo.PRIORITY_LOW;
        private ArrayList<String> mMccMncs = new ArrayList<>();
        private ArrayList<Integer> mBands = new ArrayList<>();
        private ArrayList<RadioAccessSpecifier> mRadioAccessSpecifiers = new ArrayList<>();

        public @NonNull Builder setSubId(int subId) {
            mSubId = subId;
            return this;
        }

        public @NonNull Builder setPriority(int priority) {
            if (priority > AvailableNetworkInfo.PRIORITY_LOW
                    || priority < AvailableNetworkInfo.PRIORITY_HIGH) {
                throw new IllegalArgumentException("A valid priority must be set");
            }
            mPriority = priority;
            return this;
        }

        public @NonNull Builder setMccMncs(@NonNull ArrayList<String> mccMncs) {
            Objects.requireNonNull(mccMncs, "A non-null ArrayList of mccmncs must be set. An empty "
                    + "list is still accepted. Please read documentation in "
                    + "AvailableNetworkService to see consequences of an empty Arraylist.");
            mMccMncs = mccMncs;
            return this;
        }

        public @NonNull Builder setRadioAccessSpecifiers(
                @NonNull ArrayList<RadioAccessSpecifier> radioAccessSpecifiers) {
            Objects.requireNonNull(radioAccessSpecifiers, "A non-null ArrayList of "
                    + "RadioAccessSpecifiers must be set. An empty list is still accepted. Please "
                    + "read documentation in AvailableNetworkService to see consequences of an "
                    + "empty Arraylist.");
            mRadioAccessSpecifiers = radioAccessSpecifiers;
            return this;
        }

        public @NonNull AvailableNetworkInfo build() {
            if (mSubId == Integer.MIN_VALUE) {
                throw new IllegalArgumentException("A valid subId must be set");
            }

            return new AvailableNetworkInfo(mSubId, mPriority, mMccMncs, mBands,
                    mRadioAccessSpecifiers);
        }
    }
}
+122 −0
Original line number Diff line number Diff line
@@ -3612,6 +3612,109 @@ public class CarrierConfigManager {
    public static final String KEY_OPPORTUNISTIC_NETWORK_MAX_BACKOFF_TIME_LONG =
            "opportunistic_network_max_backoff_time_long";

    /**
    * Controls SS-RSRP threshold in dBm at which 5G opportunistic network will be considered good
    * enough for internet data.
    *
    * @hide
    */
    public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_SS_RSRP_INT =
            "opportunistic_network_entry_threshold_ss_rsrp_int";

    /**
    * Controls SS-RSRQ threshold in dB at which 5G opportunistic network will be considered good
    * enough for internet data.
    *
    * @hide
    */
    public static final String KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_SS_RSRQ_DOUBLE =
            "opportunistic_network_entry_threshold_ss_rsrq_double";

    /**
    * Controls SS-RSRP threshold in dBm below which 5G opportunistic network available will not
    * be considered good enough for internet data.
    *
    * @hide
    */
    public static final String KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_SS_RSRP_INT =
            "opportunistic_network_exit_threshold_ss_rsrp_int";

    /**
    * Controls SS-RSRQ threshold in dB below which 5G opportunistic network available will not
    * be considered good enough for internet data.
    *
    * @hide
    */
    public static final String KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_SS_RSRQ_DOUBLE =
            "opportunistic_network_exit_threshold_ss_rsrq_double";

    /**
     * Controls back off time in milliseconds for switching back to
     * 5G opportunistic subscription. This time will be added to
     * {@link CarrierConfigManager#KEY_OPPORTUNISTIC_NETWORK_5G_DATA_SWITCH_HYSTERESIS_TIME_LONG} to
     * determine hysteresis time if there is ping pong situation
     * (determined by system app or 1st party app) between primary and 5G opportunistic
     * subscription. Ping ping situation is defined in
     * #KEY_OPPORTUNISTIC_NETWORK_5G_PING_PONG_TIME_LONG.
     * If ping pong situation continuous #KEY_OPPORTUNISTIC_5G_NETWORK_BACKOFF_TIME_LONG
     * will be added to previously determined hysteresis time.
     *
     * @hide
     */
    public static final String KEY_OPPORTUNISTIC_NETWORK_5G_BACKOFF_TIME_LONG =
            "opportunistic_network_5g_backoff_time_long";

    /**
     * Controls the max back off time in milliseconds for switching back to
     * 5G opportunistic subscription.
     * This time will be the max hysteresis that can be determined irrespective of there is
     * continuous ping pong situation or not as described in
     * #KEY_OPPORTUNISTIC_NETWORK_5G_PING_PONG_TIME_LONG and
     * #KEY_OPPORTUNISTIC_NETWORK_5G_BACKOFF_TIME_LONG.
     *
     * @hide
     */
    public static final String KEY_OPPORTUNISTIC_NETWORK_5G_MAX_BACKOFF_TIME_LONG =
            "opportunistic_network_5g_max_backoff_time_long";

    /**
    * Controls the ping pong determination of 5G opportunistic network.
    * If opportunistic network is determined as out of service or below
    * #KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_SS_RSRP_INT or
    * #KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_SS_RSRQ_INT within
    * #KEY_OPPORTUNISTIC_NETWORK_5G_PING_PONG_TIME_LONG of switching to opportunistic network,
    * it will be determined as ping pong situation by system app or 1st party app.
     *
    * @hide
    */
    public static final String KEY_OPPORTUNISTIC_NETWORK_5G_PING_PONG_TIME_LONG =
            "opportunistic_network_5g_ping_pong_time_long";

    /**
     * Controls hysteresis time in milliseconds for which will be waited before switching
     * data to a 5G opportunistic network.
     *
     * @hide
     */
    public static final String KEY_OPPORTUNISTIC_NETWORK_5G_DATA_SWITCH_HYSTERESIS_TIME_LONG =
            "opportunistic_network_5g_data_switch_hysteresis_time_long";

    /**
     * Controls hysteresis time in milliseconds for which will be waited before switching from
     * 5G opportunistic network to primary network.
     *
     * @hide
     */
    public static final String KEY_OPPORTUNISTIC_NETWORK_5G_DATA_SWITCH_EXIT_HYSTERESIS_TIME_LONG =
            "opportunistic_network_5g_data_switch_exit_hysteresis_time_long";
    /**
     * Controls whether 4G opportunistic networks should be scanned for possible data switch.
     *
     * @hide
     */
    public static final String KEY_ENABLE_4G_OPPORTUNISTIC_NETWORK_SCAN_BOOL =
            "enabled_4g_opportunistic_network_scan_bool";

    /**
     * Indicates zero or more emergency number prefix(es), because some carrier requires
     * if users dial an emergency number address with a specific prefix, the combination of the
@@ -4958,6 +5061,25 @@ public class CarrierConfigManager {
        sDefaults.putLong(KEY_OPPORTUNISTIC_NETWORK_BACKOFF_TIME_LONG, 10000);
        /* Default value is 60 seconds. */
        sDefaults.putLong(KEY_OPPORTUNISTIC_NETWORK_MAX_BACKOFF_TIME_LONG, 60000);
        /* Default value is -111 dBm. */
        sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_SS_RSRP_INT, -111);
        /* Default value is -18.5 dB. */
        sDefaults.putDouble(KEY_OPPORTUNISTIC_NETWORK_ENTRY_THRESHOLD_SS_RSRQ_DOUBLE, -18.5);
        /* Default value is -120 dBm. */
        sDefaults.putInt(KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_SS_RSRP_INT, -120);
        /* Default value is -18.5 dB. */
        sDefaults.putDouble(KEY_OPPORTUNISTIC_NETWORK_EXIT_THRESHOLD_SS_RSRQ_DOUBLE, -18.5);
        /* Default value is 10 seconds. */
        sDefaults.putLong(KEY_OPPORTUNISTIC_NETWORK_5G_BACKOFF_TIME_LONG, 10000);
        /* Default value is 60 seconds. */
        sDefaults.putLong(KEY_OPPORTUNISTIC_NETWORK_5G_MAX_BACKOFF_TIME_LONG, 60000);
        /* Default value is 60 seconds. */
        sDefaults.putLong(KEY_OPPORTUNISTIC_NETWORK_5G_PING_PONG_TIME_LONG, 60000);
        /* Default value is 2 seconds. */
        sDefaults.putLong(KEY_OPPORTUNISTIC_NETWORK_5G_DATA_SWITCH_HYSTERESIS_TIME_LONG, 2000);
        /* Default value is 2 seconds. */
        sDefaults.putLong(KEY_OPPORTUNISTIC_NETWORK_5G_DATA_SWITCH_EXIT_HYSTERESIS_TIME_LONG, 2000);
        sDefaults.putBoolean(KEY_ENABLE_4G_OPPORTUNISTIC_NETWORK_SCAN_BOOL, true);
        sDefaults.putAll(Gps.getDefaults());
        sDefaults.putIntArray(KEY_CDMA_ENHANCED_ROAMING_INDICATOR_FOR_HOME_NETWORK_INT_ARRAY,
                new int[] {