From e7ea17eac4eed154a6d2a7e787855d99250db401 Mon Sep 17 00:00:00 2001 From: "Philip P. Moltmann" Date: Tue, 8 Oct 2019 16:53:23 -0700 Subject: Adapt to changed app-ops api in WifiPermissionsUtil Bug: 136595429 Test: atest WifiPermissionsUtilTest Change-Id: Ia96207812f6304f7d4368f00e62a0705e86f5475 --- .../server/wifi/util/WifiPermissionsUtil.java | 5 +++-- .../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 3dea2c31b..8b1305b16 100644 --- a/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java +++ b/service/java/com/android/server/wifi/util/WifiPermissionsUtil.java @@ -378,7 +378,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) { @@ -473,7 +474,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 e6541fdf7..4f43fc34c 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java @@ -711,7 +711,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()); } /** @@ -733,7 +733,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()); } /** @@ -816,7 +816,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)) @@ -825,7 +825,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)) @@ -977,7 +977,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); } /** @@ -1007,7 +1007,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); } @@ -1228,12 +1228,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) { -- cgit v1.2.3