Merge "[Telephony Mainline] Expose MAX_NETWORK_TYPE constant"

am: 23019528ec

Change-Id: If620508739fccc330383f52592ed060777b83cff
This commit is contained in:
Peter Wang
2019-12-17 11:15:51 -08:00
committed by android-build-merger
5 changed files with 36 additions and 6 deletions

View File

@@ -45147,6 +45147,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();

View File

@@ -2421,7 +2421,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;

View File

@@ -5266,7 +5266,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) {

View File

@@ -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.

View File

@@ -2425,7 +2425,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 */
@@ -2473,8 +2473,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.