diff options
author | Philip P. Moltmann <moltmann@google.com> | 2019-10-18 02:26:07 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-10-18 02:26:07 +0000 |
commit | 0a308844646788cb649df8831696a4b359af381b (patch) | |
tree | 31edbfb8a6864edcf424f6e4034ced602aaaa9e7 | |
parent | 95ec2663cd0b59d5db0948b1218142d0770e0c44 (diff) | |
parent | e7ea17eac4eed154a6d2a7e787855d99250db401 (diff) |
Merge "Adapt to changed app-ops api in WifiPermissionsUtil"
-rw-r--r-- | service/java/com/android/server/wifi/util/WifiPermissionsUtil.java | 5 | ||||
-rw-r--r-- | tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java | 24 |
2 files changed, 15 insertions, 14 deletions
diff --git a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java index d767deb6e..5207bbbc4 100644 --- a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java +++ b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java @@ -367,7 +367,8 @@ public class WifiPermissionsUtil { } private boolean noteAppOpAllowed(String op, String pkgName, int uid) { - return mAppOps.noteOp(op, uid, pkgName, null) == AppOpsManager.MODE_ALLOWED; + // TODO moltmann: Set correct featureId + return mAppOps.noteOp(op, uid, pkgName, null, null) == AppOpsManager.MODE_ALLOWED; } private boolean checkAppOpAllowed(String op, String pkgName, int uid) { @@ -462,7 +463,7 @@ public class WifiPermissionsUtil { */ public boolean checkSystemAlertWindowPermission(int callingUid, String callingPackage) { final int mode = mAppOps.noteOp(AppOpsManager.OPSTR_SYSTEM_ALERT_WINDOW, callingUid, - callingPackage, null); + callingPackage, null, null); if (mode == AppOpsManager.MODE_DEFAULT) { return mWifiPermissionsWrapper.getUidPermission( Manifest.permission.SYSTEM_ALERT_WINDOW, callingUid) diff --git a/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java b/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java index d262514f1..222c70621 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java @@ -702,7 +702,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest { // verify that checking FINE for legacy apps! verify(mMockAppOps).noteOp(eq(AppOpsManager.OPSTR_FINE_LOCATION), anyInt(), anyString(), - any()); + any(), any()); } /** @@ -723,7 +723,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest { mMockContext, mMockUserManager, mWifiInjector); codeUnderTest.enforceLocationPermission(TEST_PACKAGE_NAME, mUid); verify(mMockAppOps) - .noteOp(eq(AppOpsManager.OPSTR_FINE_LOCATION), anyInt(), anyString(), any()); + .noteOp(eq(AppOpsManager.OPSTR_FINE_LOCATION), anyInt(), anyString(), any(), any()); } /** @@ -805,7 +805,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest { mMockContext, mMockUserManager, mWifiInjector); when(mMockAppOps.noteOp(AppOpsManager.OPSTR_SYSTEM_ALERT_WINDOW, MANAGED_PROFILE_UID, - TEST_PACKAGE_NAME, null)) + TEST_PACKAGE_NAME, null, null)) .thenReturn(AppOpsManager.MODE_DEFAULT); when(mMockPermissionsWrapper.getUidPermission( Manifest.permission.SYSTEM_ALERT_WINDOW, MANAGED_PROFILE_UID)) @@ -814,7 +814,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest { MANAGED_PROFILE_UID, TEST_PACKAGE_NAME)); when(mMockAppOps.noteOp(AppOpsManager.OPSTR_SYSTEM_ALERT_WINDOW, MANAGED_PROFILE_UID, - TEST_PACKAGE_NAME, null)) + TEST_PACKAGE_NAME, null, null)) .thenReturn(AppOpsManager.MODE_DEFAULT); when(mMockPermissionsWrapper.getUidPermission( Manifest.permission.SYSTEM_ALERT_WINDOW, MANAGED_PROFILE_UID)) @@ -966,7 +966,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest { verify(mMockAppOps, never()) .unsafeCheckOp(AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME); verify(mMockAppOps) - .noteOp(AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME, null); + .noteOp(AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME, null, null); } /** @@ -996,7 +996,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest { verify(mMockAppOps).unsafeCheckOp(AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME); verify(mMockAppOps, never()).noteOp( - AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME, null); + AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME, null, null); } @@ -1217,12 +1217,12 @@ public class WifiPermissionsUtilTest extends WifiBaseTest { when(mMockPkgMgr.getApplicationInfoAsUser(eq(TEST_PACKAGE_NAME), eq(0), anyInt())) .thenReturn(mMockApplInfo); when(mMockContext.getPackageManager()).thenReturn(mMockPkgMgr); - when(mMockAppOps.noteOp(AppOpsManager.OPSTR_WIFI_SCAN, mUid, TEST_PACKAGE_NAME, null)) - .thenReturn(mWifiScanAllowApps); - when(mMockAppOps.noteOp(AppOpsManager.OPSTR_COARSE_LOCATION, mUid, TEST_PACKAGE_NAME, null)) - .thenReturn(mAllowCoarseLocationApps); - when(mMockAppOps.noteOp(AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME, null)) - .thenReturn(mAllowFineLocationApps); + when(mMockAppOps.noteOp(AppOpsManager.OPSTR_WIFI_SCAN, mUid, TEST_PACKAGE_NAME, null, null)) + .thenReturn(mWifiScanAllowApps); + when(mMockAppOps.noteOp(AppOpsManager.OPSTR_COARSE_LOCATION, mUid, TEST_PACKAGE_NAME, null, + null)).thenReturn(mAllowCoarseLocationApps); + when(mMockAppOps.noteOp(AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME, null, + null)).thenReturn(mAllowFineLocationApps); when(mMockAppOps.unsafeCheckOp(AppOpsManager.OPSTR_FINE_LOCATION, mUid, TEST_PACKAGE_NAME)) .thenReturn(mAllowFineLocationApps); if (mThrowSecurityException) { |