Don't throw when noting ENABLE_MOBILE_DATA
There not much to do if it does throw, and it breaks some tests
Bug: 325375860
Test: atest BluetoothWiFiResetPreferenceControllerTest
Test: atest PhoneInterfaceManagerTest
Change-Id: I97f6b76252f661b6eeb72a595e65b27b155103ab
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index e18818c..87fe7c5 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -428,11 +428,11 @@
private final SatelliteController mSatelliteController;
private final SatelliteAccessController mSatelliteAccessController;
private final UserManager mUserManager;
- private final AppOpsManager mAppOps;
private final MainThreadHandler mMainThreadHandler;
private final SharedPreferences mTelephonySharedPreferences;
private final PhoneConfigurationManager mPhoneConfigurationManager;
private final RadioInterfaceCapabilityController mRadioInterfaceCapabilities;
+ private AppOpsManager mAppOps;
private PackageManager mPackageManager;
/** User Activity */
@@ -9463,7 +9463,7 @@
try {
if (reason == TelephonyManager.DATA_ENABLED_REASON_USER && enabled
&& null != callingPackage && opEnableMobileDataByUser()) {
- mAppOps.noteOp(AppOpsManager.OPSTR_ENABLE_MOBILE_DATA_BY_USER,
+ mAppOps.noteOpNoThrow(AppOpsManager.OPSTR_ENABLE_MOBILE_DATA_BY_USER,
callingUid, callingPackage, null, null);
}
Phone phone = getPhone(subId);
@@ -14016,6 +14016,16 @@
}
/*
+ * PhoneInterfaceManager is a singleton. Unit test calls the init() with context.
+ * But the context that is passed in is unused if the phone app is already alive.
+ * In this case PackageManager object is different in PhoneInterfaceManager and Unit test.
+ */
+ @VisibleForTesting
+ public void setAppOpsManager(AppOpsManager appOps) {
+ mAppOps = appOps;
+ }
+
+ /*
* PhoneInterfaceManager is a singleton. Unit test calls the init() with FeatureFlags.
* But the FeatureFlags that is passed in is unused if the phone app is already alive.
* In this case FeatureFlags object is different in PhoneInterfaceManager and Unit test.