diff options
author | Roshan Pius <rpius@google.com> | 2019-09-18 17:27:41 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-09-18 17:27:41 -0700 |
commit | 2c3e6f177642a3dcd378e0a404d60ba2af2841ed (patch) | |
tree | c9b189f0a7b00deceec18dbf05d2e83607d5e9e5 /tests | |
parent | 4764d08e86004af17e4cfd8e24ad6685b9096c5d (diff) | |
parent | 4ffcc50359495af8d1f5ad94203752a00f32aaeb (diff) |
Merge "WifiPermissionsUtil: Use getApplicationInfoAsUser for target SDK checks" into qt-qpr1-dev am: c9d6806174
am: 4ffcc50359
Change-Id: I89423b1b3b5572d4e0299730fbd5551382585de7
Diffstat (limited to 'tests')
3 files changed, 31 insertions, 26 deletions
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java index 60f14b3c3..137f881d0 100644 --- a/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java +++ b/tests/wifitests/src/com/android/server/wifi/WifiServiceImplTest.java @@ -552,7 +552,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(true); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true); when(mSettingsStore.handleWifiToggled(anyBoolean())).thenReturn(true); when(mSettingsStore.isAirplaneModeOn()).thenReturn(false); @@ -571,7 +571,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(false); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(false); when(mSettingsStore.handleWifiToggled(eq(true))).thenReturn(true); when(mSettingsStore.isAirplaneModeOn()).thenReturn(false); @@ -615,7 +615,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(false); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(false); when(mDevicePolicyManagerInternal.isActiveAdminWithPolicy( Process.myUid(), DeviceAdminInfo.USES_POLICY_DEVICE_OWNER)) .thenReturn(true); @@ -635,7 +635,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(false); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(false); mApplicationInfo.flags = ApplicationInfo.FLAG_SYSTEM; when(mSettingsStore.handleWifiToggled(eq(true))).thenReturn(true); @@ -653,7 +653,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(true); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true); when(mSettingsStore.handleWifiToggled(eq(true))).thenReturn(true); when(mSettingsStore.isAirplaneModeOn()).thenReturn(false); @@ -670,7 +670,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(false); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(false); when(mSettingsStore.handleWifiToggled(eq(true))).thenReturn(true); when(mSettingsStore.isAirplaneModeOn()).thenReturn(false); @@ -687,7 +687,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doThrow(new SecurityException()).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(true); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true); when(mSettingsStore.handleWifiToggled(eq(true))).thenReturn(true); try { mWifiServiceImpl.setWifiEnabled(TEST_PACKAGE_NAME, true); @@ -707,7 +707,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_IGNORED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(true); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true); when(mSettingsStore.handleWifiToggled(eq(true))).thenReturn(true); mWifiServiceImpl.setWifiEnabled(TEST_PACKAGE_NAME, true); @@ -739,7 +739,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(true); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true); when(mSettingsStore.handleWifiToggled(eq(true))).thenReturn(true); when(mSettingsStore.isAirplaneModeOn()).thenReturn(true); when(mContext.checkPermission( @@ -797,7 +797,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(true); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true); when(mSettingsStore.isWifiToggleEnabled()).thenReturn(false); mWifiServiceImpl.checkAndStartWifi(); @@ -875,7 +875,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(false); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(false); when(mDevicePolicyManagerInternal.isActiveAdminWithPolicy( Process.myUid(), DeviceAdminInfo.USES_POLICY_PROFILE_OWNER)) .thenReturn(true); @@ -895,7 +895,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(false); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(false); mApplicationInfo.flags = ApplicationInfo.FLAG_SYSTEM; when(mSettingsStore.handleWifiToggled(eq(false))).thenReturn(true); @@ -914,7 +914,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(true); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true); when(mSettingsStore.handleWifiToggled(eq(false))).thenReturn(true); when(mSettingsStore.isAirplaneModeOn()).thenReturn(false); @@ -931,7 +931,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(false); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(false); when(mSettingsStore.handleWifiToggled(eq(false))).thenReturn(true); when(mSettingsStore.isAirplaneModeOn()).thenReturn(false); @@ -2515,7 +2515,7 @@ public class WifiServiceImplTest extends WifiBaseTest { when(mContext.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(any(), anyInt())).thenReturn(mApplicationInfo); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(true); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true); when(mClientModeImpl.syncAddOrUpdatePasspointConfig(any(), any(PasspointConfiguration.class), anyInt(), eq(TEST_PACKAGE_NAME))).thenReturn( @@ -2661,7 +2661,7 @@ public class WifiServiceImplTest extends WifiBaseTest { when(mWifiPermissionsUtil.checkNetworkSettingsPermission(anyInt())).thenReturn(false); when(mWifiPermissionsUtil.checkNetworkSetupWizardPermission(anyInt())).thenReturn(false); when(mWifiPermissionsUtil.isTargetSdkLessThan(eq(TEST_PACKAGE_NAME), - eq(Build.VERSION_CODES.Q))).thenReturn(true); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true); List<PasspointConfiguration> result = mWifiServiceImpl.getPasspointConfigurations( TEST_PACKAGE_NAME); @@ -2694,7 +2694,7 @@ public class WifiServiceImplTest extends WifiBaseTest { when(mWifiPermissionsUtil.checkNetworkCarrierProvisioningPermission(anyInt())).thenReturn( false); when(mWifiPermissionsUtil.isTargetSdkLessThan(isNull(), - eq(Build.VERSION_CODES.Q))).thenReturn(true); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true); assertFalse(mWifiServiceImpl.removePasspointConfiguration(null, null)); } @@ -3545,7 +3545,7 @@ public class WifiServiceImplTest extends WifiBaseTest { .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mClientModeImpl.syncAddOrUpdateNetwork(any(), any())).thenReturn(0); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(true); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true); WifiConfiguration config = WifiConfigurationTestUtil.createOpenNetwork(); assertEquals(0, mWifiServiceImpl.addOrUpdateNetwork(config, TEST_PACKAGE_NAME)); @@ -3688,7 +3688,7 @@ public class WifiServiceImplTest extends WifiBaseTest { doReturn(AppOpsManager.MODE_ALLOWED).when(mAppOpsManager) .noteOp(AppOpsManager.OPSTR_CHANGE_WIFI_STATE, Process.myUid(), TEST_PACKAGE_NAME); when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), - eq(Build.VERSION_CODES.Q))).thenReturn(true); + eq(Build.VERSION_CODES.Q), anyInt())).thenReturn(true); mWifiServiceImpl.enableNetwork(TEST_NETWORK_ID, true, TEST_PACKAGE_NAME); diff --git a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java index 717dfe6dd..b803dd515 100644 --- a/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java +++ b/tests/wifitests/src/com/android/server/wifi/aware/WifiAwareDataPathStateManagerTest.java @@ -162,7 +162,8 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest { // by default pretend to be an old API: i.e. allow Responders configured as *ANY*. This // allows older (more extrensive) tests to run. - when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), anyInt())).thenReturn(true); + when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), anyInt(), anyInt())) + .thenReturn(true); when(mWifiPermissionsUtil.isLocationModeEnabled()).thenReturn(true); when(mMockNativeManager.isAwareNativeAvailable()).thenReturn(true); @@ -1019,7 +1020,8 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest { */ @Test public void testDataPathResonderMacPassphraseNoPeerIdSuccessNonLegacy() throws Exception { - when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), anyInt())).thenReturn(false); + when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), anyInt(), anyInt())) + .thenReturn(false); testDataPathResponderUtility(false, false, false, true, true); } @@ -1030,7 +1032,8 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest { @Test public void testDataPathResonderMacOpenNoPeerIdNoPmkPassphraseSuccessNonLegacy() throws Exception { - when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), anyInt())).thenReturn(false); + when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), anyInt(), anyInt())) + .thenReturn(false); testDataPathResponderUtility(false, false, false, false, true); } @@ -1076,7 +1079,8 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest { */ @Test public void testDataPathResonderDirectNoMacPassphraseSuccessNonLegacy() throws Exception { - when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), anyInt())).thenReturn(false); + when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), anyInt(), anyInt())) + .thenReturn(false); testDataPathResponderUtility(true, false, false, true, true); } @@ -1086,7 +1090,8 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest { */ @Test public void testDataPathResonderDirectNoMacNoPmkPassphraseSuccessNonLegacy() throws Exception { - when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), anyInt())).thenReturn(false); + when(mWifiPermissionsUtil.isTargetSdkLessThan(anyString(), anyInt(), anyInt())) + .thenReturn(false); testDataPathResponderUtility(true, false, false, false, true); } @@ -1475,7 +1480,7 @@ public class WifiAwareDataPathStateManagerTest extends WifiBaseTest { InOrder inOrderM = inOrder(mAwareMetricsMock); boolean isLegacy = mWifiPermissionsUtil.isTargetSdkLessThan("anything", - Build.VERSION_CODES.P); + Build.VERSION_CODES.P, 0); if (providePmk) { when(mPermissionsWrapperMock.getUidPermission( 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 97d2b9fcb..6241d210e 100644 --- a/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java +++ b/tests/wifitests/src/com/android/server/wifi/util/WifiPermissionsUtilTest.java @@ -1149,7 +1149,7 @@ public class WifiPermissionsUtilTest extends WifiBaseTest { } private void setupMocks() throws Exception { - when(mMockPkgMgr.getApplicationInfo(TEST_PACKAGE_NAME, 0)) + when(mMockPkgMgr.getApplicationInfoAsUser(eq(TEST_PACKAGE_NAME), eq(0), anyInt())) .thenReturn(mMockApplInfo); when(mMockContext.getPackageManager()).thenReturn(mMockPkgMgr); when(mMockAppOps.noteOp(AppOpsManager.OP_WIFI_SCAN, mUid, TEST_PACKAGE_NAME)) |