Merge "Add permissions check for getNetworkType"
am: 0c7239996d
Change-Id: Ie8fda088084d6acfc30c43e089d9e05ef9514c65
This commit is contained in:
@@ -2209,7 +2209,7 @@ public class TelephonyManager {
|
|||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
public String getNetworkOperatorForPhone(int phoneId) {
|
public String getNetworkOperatorForPhone(int phoneId) {
|
||||||
return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, "");
|
return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2412,21 +2412,7 @@ public class TelephonyManager {
|
|||||||
* @return the NETWORK_TYPE_xxxx for current data connection.
|
* @return the NETWORK_TYPE_xxxx for current data connection.
|
||||||
*/
|
*/
|
||||||
public @NetworkType int getNetworkType() {
|
public @NetworkType int getNetworkType() {
|
||||||
try {
|
return getNetworkType(getSubId(SubscriptionManager.getDefaultDataSubscriptionId()));
|
||||||
ITelephony telephony = getITelephony();
|
|
||||||
if (telephony != null) {
|
|
||||||
return telephony.getNetworkType();
|
|
||||||
} else {
|
|
||||||
// This can happen when the ITelephony interface is not up yet.
|
|
||||||
return NETWORK_TYPE_UNKNOWN;
|
|
||||||
}
|
|
||||||
} catch(RemoteException ex) {
|
|
||||||
// This shouldn't happen in the normal case
|
|
||||||
return NETWORK_TYPE_UNKNOWN;
|
|
||||||
} catch (NullPointerException ex) {
|
|
||||||
// This could happen before phone restarts due to crashing
|
|
||||||
return NETWORK_TYPE_UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2457,7 +2443,7 @@ public class TelephonyManager {
|
|||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
|
||||||
public int getNetworkType(int subId) {
|
public int getNetworkType(int subId) {
|
||||||
try {
|
try {
|
||||||
ITelephony telephony = getITelephony();
|
ITelephony telephony = getITelephony();
|
||||||
|
|||||||
@@ -457,13 +457,6 @@ interface ITelephony {
|
|||||||
// Send the special dialer code. The IPC caller must be the current default dialer.
|
// Send the special dialer code. The IPC caller must be the current default dialer.
|
||||||
void sendDialerSpecialCode(String callingPackageName, String inputCode);
|
void sendDialerSpecialCode(String callingPackageName, String inputCode);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the network type for data transmission
|
|
||||||
* Legacy call, permission-free
|
|
||||||
*/
|
|
||||||
@UnsupportedAppUsage
|
|
||||||
int getNetworkType();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the network type of a subId.
|
* Returns the network type of a subId.
|
||||||
* @param subId user preferred subId.
|
* @param subId user preferred subId.
|
||||||
|
|||||||
@@ -75,6 +75,16 @@ public final class TelephonyPermissions {
|
|||||||
callingPackage, message);
|
callingPackage, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Identical to checkCallingOrSelfReadPhoneState but never throws SecurityException */
|
||||||
|
public static boolean checkCallingOrSelfReadPhoneStateNoThrow(
|
||||||
|
Context context, int subId, String callingPackage, String message) {
|
||||||
|
try {
|
||||||
|
return checkCallingOrSelfReadPhoneState(context, subId, callingPackage, message);
|
||||||
|
} catch (SecurityException se) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check whether the app with the given pid/uid can read phone state.
|
* Check whether the app with the given pid/uid can read phone state.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user