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

Commit 15e3ae07 authored by Peter Wang's avatar Peter Wang
Browse files

[Telephony Mainline] Expose MAX_NETWORK_TYPE constant

Test: Build
Bug: 140908357
Change-Id: I40cbcdfb8e77b3e01968d008f4359790c4264539
parent 5356d348
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -45592,6 +45592,7 @@ package android.telephony {
    method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) public boolean doesSwitchMultiSimConfigTriggerReboot();
    method public int getActiveModemCount();
    method @RequiresPermission(android.Manifest.permission.ACCESS_FINE_LOCATION) public java.util.List<android.telephony.CellInfo> getAllCellInfo();
    method @NonNull public static int[] getAllNetworkTypes();
    method public int getCallState();
    method public int getCardIdForDefaultEuicc();
    method @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE) @WorkerThread public android.os.PersistableBundle getCarrierConfig();
+1 −1
Original line number Diff line number Diff line
@@ -2422,7 +2422,7 @@ public abstract class BatteryStats implements Parcelable {

    public static final int DATA_CONNECTION_OUT_OF_SERVICE = 0;
    public static final int DATA_CONNECTION_EMERGENCY_SERVICE =
            TelephonyManager.MAX_NETWORK_TYPE + 1;
            TelephonyManager.getAllNetworkTypes().length + 1;
    public static final int DATA_CONNECTION_OTHER = DATA_CONNECTION_EMERGENCY_SERVICE + 1;


+1 −1
Original line number Diff line number Diff line
@@ -5267,7 +5267,7 @@ public class BatteryStatsImpl extends BatteryStats {
        // Unknown is included in DATA_CONNECTION_OTHER.
        int bin = DATA_CONNECTION_OUT_OF_SERVICE;
        if (hasData) {
            if (dataType > 0 && dataType <= TelephonyManager.MAX_NETWORK_TYPE) {
            if (dataType > 0 && dataType <= TelephonyManager.getAllNetworkTypes().length) {
                bin = dataType;
            } else {
                switch (serviceType) {
+2 −1
Original line number Diff line number Diff line
@@ -91,7 +91,8 @@ public class MobileSignalController extends SignalController<
    @VisibleForTesting
    boolean mIsShowingIconGracefully = false;
    // Some specific carriers have 5GE network which is special LTE CA network.
    private static final int NETWORK_TYPE_LTE_CA_5GE = TelephonyManager.MAX_NETWORK_TYPE + 1;
    private static final int NETWORK_TYPE_LTE_CA_5GE =
            TelephonyManager.getAllNetworkTypes().length + 1;

    // TODO: Reduce number of vars passed in, if we have the NetworkController, probably don't
    // need listener lists anymore.
+31 −3
Original line number Diff line number Diff line
@@ -2632,7 +2632,7 @@ public class TelephonyManager {

    /*
     * When adding a network type to the list below, make sure to add the correct icon to
     * MobileSignalController.mapIconSets().
     * MobileSignalController.mapIconSets() as well as NETWORK_TYPES
     * Do not add negative types.
     */
    /** Network type is unknown */
@@ -2680,8 +2680,36 @@ public class TelephonyManager {
    /** Current network is NR(New Radio) 5G. */
    public static final int NETWORK_TYPE_NR = TelephonyProtoEnums.NETWORK_TYPE_NR; // 20.

    /** Max network type number. Update as new types are added. Don't add negative types. {@hide} */
    public static final int MAX_NETWORK_TYPE = NETWORK_TYPE_NR;
    private static final @NetworkType int[] NETWORK_TYPES = {
            NETWORK_TYPE_GPRS,
            NETWORK_TYPE_EDGE,
            NETWORK_TYPE_UMTS,
            NETWORK_TYPE_CDMA,
            NETWORK_TYPE_EVDO_0,
            NETWORK_TYPE_EVDO_A,
            NETWORK_TYPE_1xRTT,
            NETWORK_TYPE_HSDPA,
            NETWORK_TYPE_HSUPA,
            NETWORK_TYPE_HSPA,
            NETWORK_TYPE_IDEN,
            NETWORK_TYPE_EVDO_B,
            NETWORK_TYPE_LTE,
            NETWORK_TYPE_EHRPD,
            NETWORK_TYPE_HSPAP,
            NETWORK_TYPE_GSM,
            NETWORK_TYPE_TD_SCDMA,
            NETWORK_TYPE_IWLAN,
            NETWORK_TYPE_LTE_CA,
            NETWORK_TYPE_NR
    };

    /**
     * Return a collection of all network types
     * @return network types
     */
    public static @NonNull @NetworkType int[] getAllNetworkTypes() {
        return NETWORK_TYPES;
    }

    /**
     * Return the current data network type.