Note ENABLE_MOBILE_DATA_BY_USER after clearing calling identity
Bug: 222650148
Test: atest SettingsSpaUnitTests
Change-Id: Ic72dd6bd4c6db18b4c0a4635ceb4887d73d1ee6e
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index e53a674..c396391 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -9453,17 +9453,17 @@
enforceModifyPermission();
}
- if (reason == TelephonyManager.DATA_ENABLED_REASON_USER && enabled
- && null != callingPackage && opEnableMobileDataByUser()) {
- mAppOps.noteOp(AppOpsManager.OPSTR_ENABLE_MOBILE_DATA_BY_USER, Binder.getCallingUid(),
- callingPackage, null, null);
- }
-
enforceTelephonyFeatureWithException(callingPackage,
PackageManager.FEATURE_TELEPHONY_DATA, "setDataEnabledForReason");
+ int callingUid = Binder.getCallingUid();
final long identity = Binder.clearCallingIdentity();
try {
+ if (reason == TelephonyManager.DATA_ENABLED_REASON_USER && enabled
+ && null != callingPackage && opEnableMobileDataByUser()) {
+ mAppOps.noteOp(AppOpsManager.OPSTR_ENABLE_MOBILE_DATA_BY_USER,
+ callingUid, callingPackage, null, null);
+ }
Phone phone = getPhone(subId);
if (phone != null) {
if (reason == TelephonyManager.DATA_ENABLED_REASON_CARRIER) {