Fix permission checking for IsDataRoamingEnabled
Per documentation, it should work with any of the following permission:
1) ACCESS_NETWORK_STATE
2) READ_PHONE_STATE
3) Carrier Privilege
Test: cts
Bug: 141865257
Change-Id: I20ca6ccf41e2b5658e71da6201f1c8faeb5b05e2
Merged-In: I32e63363f8a97fce057eed7a2ef8f0381e58f1a8
(cherry picked from commit 093013d93e4a7d81f3322a2eb925524aeec2ca46)
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index c4a669d..cae99f4 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -7429,17 +7429,19 @@
*/
@Override
public boolean isDataRoamingEnabled(int subId) {
- mApp.enforceCallingOrSelfPermission(android.Manifest.permission.ACCESS_NETWORK_STATE,
- null /* message */);
+ try {
+ mApp.enforceCallingOrSelfPermission(android.Manifest.permission.ACCESS_NETWORK_STATE,
+ null);
+ } catch (Exception e) {
+ TelephonyPermissions.enforeceCallingOrSelfReadPhoneStatePermissionOrCarrierPrivilege(
+ mApp, subId, "isDataRoamingEnabled");
+ }
boolean isEnabled = false;
final long identity = Binder.clearCallingIdentity();
try {
Phone phone = getPhone(subId);
isEnabled = phone != null ? phone.getDataRoamingEnabled() : false;
- } catch (Exception e) {
- TelephonyPermissions.enforeceCallingOrSelfReadPhoneStatePermissionOrCarrierPrivilege(
- mApp, subId, "isDataRoamingEnabled");
} finally {
Binder.restoreCallingIdentity(identity);
}