Require READ_PHONE_STATE for getNetworkType
-Remove the non-packagename getNetworkType from PIM
(also removed from AIDL to prevent security workaround).
-Require READ_PHONE_STATE for getNetworkTypeForSubscriber
or soft-deny and return UNKNOWN.
Bug: 132466954
Test: atest TelephonyManagerPermissionTest
Merged-In: I1b47502c9c1ffd4ecec2db548bbdd89d668bd68f
Change-Id: I1b47502c9c1ffd4ecec2db548bbdd89d668bd68f
(cherry picked from commit 9042f0b9eec41aa92fe3fb28e2ebdb9dfa7a6671)
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 9d6baaf..f329150 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -2802,27 +2802,6 @@
}
}
- /**
- * Returns the data network type.
- * Legacy call, permission-free.
- *
- * @Deprecated to be removed Q3 2013 use {@link #getDataNetworkType}.
- */
- @Override
- public int getNetworkType() {
- final long identity = Binder.clearCallingIdentity();
- try {
- final Phone phone = getPhone(getDefaultSubscription());
- if (phone != null) {
- return phone.getServiceState().getDataNetworkType();
- } else {
- return TelephonyManager.NETWORK_TYPE_UNKNOWN;
- }
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
- }
-
@Override
public int getNetworkSelectionMode(int subId) {
if (!isActiveSubscription(subId)) {
@@ -3524,12 +3503,13 @@
}
/**
- * Returns the network type for a subId
+ * Returns the data network type for a subId; does not throw SecurityException.
*/
@Override
public int getNetworkTypeForSubscriber(int subId, String callingPackage) {
- if (!TelephonyPermissions.checkCallingOrSelfReadPhoneState(
- mApp, subId, callingPackage, "getNetworkTypeForSubscriber")) {
+ if (getTargetSdk(callingPackage) >= android.os.Build.VERSION_CODES.Q
+ && !TelephonyPermissions.checkCallingOrSelfReadPhoneStateNoThrow(
+ mApp, subId, callingPackage, "getNetworkTypeForSubscriber")) {
return TelephonyManager.NETWORK_TYPE_UNKNOWN;
}