Merge "Revert "Fixed the set/getAllowedNetworkTypes debug messages""

This commit is contained in:
Jack Yu
2023-01-18 22:19:49 +00:00
committed by Android (Google) Code Review
2 changed files with 70 additions and 51 deletions

View File

@@ -3976,6 +3976,66 @@ public class TelephonyRegistry extends ITelephonyRegistry.Stub {
}
}
/**
* Returns a string representation of the radio technology (network type)
* currently in use on the device.
* @param type for which network type is returned
* @return the name of the radio technology
*
*/
private String getNetworkTypeName(@Annotation.NetworkType int type) {
switch (type) {
case TelephonyManager.NETWORK_TYPE_GPRS:
return "GPRS";
case TelephonyManager.NETWORK_TYPE_EDGE:
return "EDGE";
case TelephonyManager.NETWORK_TYPE_UMTS:
return "UMTS";
case TelephonyManager.NETWORK_TYPE_HSDPA:
return "HSDPA";
case TelephonyManager.NETWORK_TYPE_HSUPA:
return "HSUPA";
case TelephonyManager.NETWORK_TYPE_HSPA:
return "HSPA";
case TelephonyManager.NETWORK_TYPE_CDMA:
return "CDMA";
case TelephonyManager.NETWORK_TYPE_EVDO_0:
return "CDMA - EvDo rev. 0";
case TelephonyManager.NETWORK_TYPE_EVDO_A:
return "CDMA - EvDo rev. A";
case TelephonyManager.NETWORK_TYPE_EVDO_B:
return "CDMA - EvDo rev. B";
case TelephonyManager.NETWORK_TYPE_1xRTT:
return "CDMA - 1xRTT";
case TelephonyManager.NETWORK_TYPE_LTE:
return "LTE";
case TelephonyManager.NETWORK_TYPE_EHRPD:
return "CDMA - eHRPD";
case TelephonyManager.NETWORK_TYPE_IDEN:
return "iDEN";
case TelephonyManager.NETWORK_TYPE_HSPAP:
return "HSPA+";
case TelephonyManager.NETWORK_TYPE_GSM:
return "GSM";
case TelephonyManager.NETWORK_TYPE_TD_SCDMA:
return "TD_SCDMA";
case TelephonyManager.NETWORK_TYPE_IWLAN:
return "IWLAN";
//TODO: This network type is marked as hidden because it is not a
// true network type and we are looking to remove it completely from the available list
// of network types. Since this method is only used for logging, in the event that this
// network type is selected, the log will read as "Unknown."
//case TelephonyManager.NETWORK_TYPE_LTE_CA:
// return "LTE_CA";
case TelephonyManager.NETWORK_TYPE_NR:
return "NR";
default:
return "UNKNOWN";
}
}
/** Returns a new PreciseCallState object with default values. */
private static PreciseCallState createPreciseCallState() {
return new PreciseCallState(PreciseCallState.PRECISE_CALL_STATE_NOT_VALID,

View File

@@ -3242,17 +3242,17 @@ public class TelephonyManager {
case NETWORK_TYPE_CDMA:
return "CDMA";
case NETWORK_TYPE_EVDO_0:
return "EVDO-0";
return "CDMA - EvDo rev. 0";
case NETWORK_TYPE_EVDO_A:
return "EVDO-A";
return "CDMA - EvDo rev. A";
case NETWORK_TYPE_EVDO_B:
return "EVDO-B";
return "CDMA - EvDo rev. B";
case NETWORK_TYPE_1xRTT:
return "1xRTT";
return "CDMA - 1xRTT";
case NETWORK_TYPE_LTE:
return "LTE";
case NETWORK_TYPE_EHRPD:
return "eHRPD";
return "CDMA - eHRPD";
case NETWORK_TYPE_IDEN:
return "iDEN";
case NETWORK_TYPE_HSPAP:
@@ -3260,7 +3260,7 @@ public class TelephonyManager {
case NETWORK_TYPE_GSM:
return "GSM";
case NETWORK_TYPE_TD_SCDMA:
return "TD-SCDMA";
return "TD_SCDMA";
case NETWORK_TYPE_IWLAN:
return "IWLAN";
case NETWORK_TYPE_LTE_CA:
@@ -9574,10 +9574,10 @@ public class TelephonyManager {
*/
public static boolean isValidAllowedNetworkTypesReason(@AllowedNetworkTypesReason int reason) {
switch (reason) {
case ALLOWED_NETWORK_TYPES_REASON_USER:
case ALLOWED_NETWORK_TYPES_REASON_POWER:
case ALLOWED_NETWORK_TYPES_REASON_CARRIER:
case ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G:
case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_USER:
case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_POWER:
case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_CARRIER:
case TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G:
case ALLOWED_NETWORK_TYPES_REASON_USER_RESTRICTIONS:
return true;
}
@@ -18034,45 +18034,4 @@ public class TelephonyManager {
return "UNKNOWN(" + state + ")";
}
}
/**
* Convert the allowed network types reason to string.
*
* @param reason The allowed network types reason.
* @return The converted string.
*
* @hide
*/
@NonNull
public static String allowedNetworkTypesReasonToString(@AllowedNetworkTypesReason int reason) {
switch (reason) {
case ALLOWED_NETWORK_TYPES_REASON_USER: return "user";
case ALLOWED_NETWORK_TYPES_REASON_POWER: return "power";
case ALLOWED_NETWORK_TYPES_REASON_CARRIER: return "carrier";
case ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G: return "enable_2g";
case ALLOWED_NETWORK_TYPES_REASON_USER_RESTRICTIONS: return "user_restrictions";
default: return "unknown(" + reason + ")";
}
}
/**
* Convert the allowed network types reason from string.
*
* @param reason The reason in string format.
* @return The allowed network types reason.
*
* @hide
*/
@AllowedNetworkTypesReason
public static int allowedNetworkTypesReasonFromString(@NonNull String reason) {
switch (reason) {
case "user": return ALLOWED_NETWORK_TYPES_REASON_USER;
case "power": return ALLOWED_NETWORK_TYPES_REASON_POWER;
case "carrier": return ALLOWED_NETWORK_TYPES_REASON_CARRIER;
case "enable_2g": return ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G;
case "user_restrictions": return ALLOWED_NETWORK_TYPES_REASON_USER_RESTRICTIONS;
default: throw new IllegalArgumentException("allowedNetworkTypesReasonFromString: "
+ "invalid reason " + reason);
}
}
}