Merge "Add permissions check for getNetworkType" into qt-dev am: ecd1e039a3

am: be113ab4aa

Change-Id: Ib37299d571aa080a01c69c7be2c5ea35650a56d0
This commit is contained in:
Nathan Harold
2019-05-22 22:11:21 -07:00
committed by android-build-merger
3 changed files with 13 additions and 24 deletions

View File

@@ -2246,7 +2246,7 @@ public class TelephonyManager {
@UnsupportedAppUsage
public String getNetworkOperatorForPhone(int phoneId) {
return getTelephonyProperty(phoneId, TelephonyProperties.PROPERTY_OPERATOR_NUMERIC, "");
}
}
/**
@@ -2449,21 +2449,7 @@ public class TelephonyManager {
* @return the NETWORK_TYPE_xxxx for current data connection.
*/
public @NetworkType int getNetworkType() {
try {
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;
}
return getNetworkType(getSubId(SubscriptionManager.getDefaultDataSubscriptionId()));
}
/**
@@ -2494,7 +2480,7 @@ public class TelephonyManager {
* @hide
*/
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
@UnsupportedAppUsage
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P)
public int getNetworkType(int subId) {
try {
ITelephony telephony = getITelephony();

View File

@@ -459,13 +459,6 @@ interface ITelephony {
// Send the special dialer code. The IPC caller must be the current default dialer.
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.
* @param subId user preferred subId.

View File

@@ -102,6 +102,16 @@ public final class TelephonyPermissions {
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.
*