Merge "Add intdef for Telephony network type constants"
am: 544b8efa46
Change-Id: I28b2eda8004c5807b454918f98542e098f9718d5
This commit is contained in:
@@ -2089,10 +2089,37 @@ public class TelephonyManager {
|
|||||||
|
|
||||||
/** Max network type number. Update as new types are added. Don't add negative types. {@hide} */
|
/** 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_LTE_CA;
|
public static final int MAX_NETWORK_TYPE = NETWORK_TYPE_LTE_CA;
|
||||||
|
|
||||||
|
/** @hide */
|
||||||
|
@IntDef({
|
||||||
|
NETWORK_TYPE_UNKNOWN,
|
||||||
|
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,
|
||||||
|
})
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
public @interface NetworkType{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the NETWORK_TYPE_xxxx for current data connection.
|
* @return the NETWORK_TYPE_xxxx for current data connection.
|
||||||
*/
|
*/
|
||||||
public int getNetworkType() {
|
public @NetworkType int getNetworkType() {
|
||||||
try {
|
try {
|
||||||
ITelephony telephony = getITelephony();
|
ITelephony telephony = getITelephony();
|
||||||
if (telephony != null) {
|
if (telephony != null) {
|
||||||
@@ -2137,24 +2164,24 @@ public class TelephonyManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public int getNetworkType(int subId) {
|
public int getNetworkType(int subId) {
|
||||||
try {
|
try {
|
||||||
ITelephony telephony = getITelephony();
|
ITelephony telephony = getITelephony();
|
||||||
if (telephony != null) {
|
if (telephony != null) {
|
||||||
return telephony.getNetworkTypeForSubscriber(subId, getOpPackageName());
|
return telephony.getNetworkTypeForSubscriber(subId, getOpPackageName());
|
||||||
} else {
|
} else {
|
||||||
// This can happen when the ITelephony interface is not up yet.
|
// This can happen when the ITelephony interface is not up yet.
|
||||||
return NETWORK_TYPE_UNKNOWN;
|
return NETWORK_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
} catch(RemoteException ex) {
|
} catch (RemoteException ex) {
|
||||||
// This shouldn't happen in the normal case
|
// This shouldn't happen in the normal case
|
||||||
return NETWORK_TYPE_UNKNOWN;
|
return NETWORK_TYPE_UNKNOWN;
|
||||||
} catch (NullPointerException ex) {
|
} catch (NullPointerException ex) {
|
||||||
// This could happen before phone restarts due to crashing
|
// This could happen before phone restarts due to crashing
|
||||||
return NETWORK_TYPE_UNKNOWN;
|
return NETWORK_TYPE_UNKNOWN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a constant indicating the radio technology (network type)
|
* Returns a constant indicating the radio technology (network type)
|
||||||
@@ -2187,7 +2214,7 @@ public class TelephonyManager {
|
|||||||
*/
|
*/
|
||||||
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
|
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
|
||||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||||
public int getDataNetworkType() {
|
public @NetworkType int getDataNetworkType() {
|
||||||
return getDataNetworkType(getSubId(SubscriptionManager.getDefaultDataSubscriptionId()));
|
return getDataNetworkType(getSubId(SubscriptionManager.getDefaultDataSubscriptionId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2227,7 +2254,7 @@ public class TelephonyManager {
|
|||||||
*/
|
*/
|
||||||
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
|
@SuppressAutoDoc // Blocked by b/72967236 - no support for carrier privileges
|
||||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||||
public int getVoiceNetworkType() {
|
public @NetworkType int getVoiceNetworkType() {
|
||||||
return getVoiceNetworkType(getSubId());
|
return getVoiceNetworkType(getSubId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user