Remove randomized Wifi MAC address test from CTS
MAC address randomization is only a GMS requirement for devices
launching with Q. So it shouldn't be tested in CTS.
Test: atest
com.android.cts.devicepolicy.MixedDeviceOwnerTest#testSetMeteredDataDisabledPackages
Bug: 136997801
Change-Id: Id38c988cf9abe3d639f016c172655783989f43b9
diff --git a/hostsidetests/devicepolicy/Android.bp b/hostsidetests/devicepolicy/Android.bp
index beba9d4..0e89a22 100644
--- a/hostsidetests/devicepolicy/Android.bp
+++ b/hostsidetests/devicepolicy/Android.bp
@@ -21,6 +21,7 @@
"cts-tradefed",
"tradefed",
"compatibility-host-util",
+ "compatibility-host-util-axt",
"guava",
"truth-prebuilt",
],
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/RandomizedWifiMacAddressTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/RandomizedWifiMacAddressTest.java
deleted file mode 100644
index f9db3e5..0000000
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/RandomizedWifiMacAddressTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.deviceandprofileowner;
-
-import static com.google.common.truth.Truth.assertWithMessage;
-
-import android.net.MacAddress;
-import android.net.wifi.WifiConfiguration;
-import android.net.wifi.WifiManager;
-
-import com.android.compatibility.common.util.WifiConfigCreator;
-
-import java.util.List;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-/**
- * Tests that DO/PO can access randomized WiFi addresses.
- */
-public class RandomizedWifiMacAddressTest extends BaseDeviceAdminTest {
- /** Mac address returned when the caller doesn't have access. */
- private static final String DEFAULT_MAC_ADDRESS = "02:00:00:00:00:00";
- /** SSID returned when the caller doesn't have access or if WiFi is not connected. */
- private static final String NETWORK_SSID = "TestSSID";
- private static final String DEFAULT_SSID = "<unknown ssid>";
-
- private int mNetId;
- private WifiConfigCreator mWifiConfigCreator;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mWifiConfigCreator = new WifiConfigCreator(mContext);
- mNetId = mWifiConfigCreator.addNetwork(NETWORK_SSID, false,
- WifiConfigCreator.SECURITY_TYPE_NONE, null);
- assertWithMessage("Fail to create test network")
- .that(mNetId)
- .isNotEqualTo(-1);
- }
-
- @Override
- protected void tearDown() throws Exception {
- mWifiConfigCreator.removeNetwork(mNetId);
- super.tearDown();
- }
- public void testGetRandomizedMacAddress() {
- final WifiManager wifiManager = mContext.getSystemService(WifiManager.class);
-
- final List<WifiConfiguration> wifiConfigs = wifiManager.getConfiguredNetworks();
- for (final WifiConfiguration config : wifiConfigs) {
- if (config.SSID == null) {
- continue;
- }
-
- if (config.SSID.equals("\"" + NETWORK_SSID + "\"")) {
- final MacAddress macAddress = config.getRandomizedMacAddress();
-
- assertWithMessage("Device owner should be able to get the randomized MAC address")
- .that(macAddress)
- .isNotEqualTo((MacAddress.fromString(DEFAULT_MAC_ADDRESS)));
- return;
- }
- }
-
- final String ssids = wifiConfigs.stream()
- .map(c -> c.SSID).filter(Objects::nonNull).collect(Collectors.joining(","));
-
- fail(String.format("Failed to find WifiConfiguration for the current connection, " +
- "current SSID: %s; configured SSIDs: %s", NETWORK_SSID, ssids));
- }
-}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
index 07e0ace..d828b86 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
@@ -28,6 +28,7 @@
import android.platform.test.annotations.RequiresDevice;
import android.stats.devicepolicy.EventId;
+import com.android.compatibility.common.util.LocationModeSetter;
import com.android.cts.devicepolicy.annotations.LockSettingsTest;
import com.android.cts.devicepolicy.metrics.DevicePolicyEventLogVerifier;
import com.android.cts.devicepolicy.metrics.DevicePolicyEventWrapper;
@@ -2048,17 +2049,6 @@
}
@Test
- public void testRandomizedWifiMacAddress() throws Exception {
- if (!mHasFeature || !hasDeviceFeature("android.hardware.wifi")) {
- return;
- }
- try (LocationModeSetter locationModeSetter = new LocationModeSetter(getDevice())) {
- locationModeSetter.setLocationEnabled(true);
- executeDeviceTestClass(".RandomizedWifiMacAddressTest");
- }
- }
-
- @Test
public void testIsDeviceOrganizationOwnedWithManagedProfile() throws Exception {
if (!mHasFeature) {
return;
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
index 93cc6eb..b428d78 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
@@ -29,6 +29,7 @@
import android.stats.devicepolicy.EventId;
import com.android.compatibility.common.tradefed.build.CompatibilityBuildHelper;
+import com.android.compatibility.common.util.LocationModeSetter;
import com.android.cts.devicepolicy.metrics.DevicePolicyEventWrapper;
import com.android.tradefed.device.DeviceNotAvailableException;
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LocationModeSetter.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LocationModeSetter.java
deleted file mode 100644
index f5999bb..0000000
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LocationModeSetter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2020 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.cts.devicepolicy;
-
-import com.android.tradefed.device.ITestDevice;
-
-public class LocationModeSetter implements AutoCloseable {
-
- /**
- * Copied from {@link android.provider.Settings}
- */
- private static final String SETTINGS_SECURE = "secure";
- private static final String LOCATION_MODE = "location_mode";
- private static final String LOCATION_MODE_HIGH_ACCURACY = "3";
- private static final String LOCATION_MODE_OFF = "0";
-
- private final String mOldLocationSetting;
- private final ITestDevice mDevice;
-
- public LocationModeSetter(ITestDevice device) throws Exception {
- mDevice = device;
- mOldLocationSetting = mDevice.getSetting(SETTINGS_SECURE, LOCATION_MODE);
- }
-
- public void setLocationEnabled(boolean enabled) throws Exception {
- if (enabled) {
- mDevice.setSetting(SETTINGS_SECURE, LOCATION_MODE, LOCATION_MODE_HIGH_ACCURACY);
- } else {
- mDevice.setSetting(SETTINGS_SECURE, LOCATION_MODE, LOCATION_MODE_OFF);
- }
- }
-
- @Override
- public void close() throws Exception {
- mDevice.setSetting(SETTINGS_SECURE, LOCATION_MODE, mOldLocationSetting);
- }
-}
\ No newline at end of file
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
index e452368..e84e26f 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
@@ -26,6 +26,7 @@
import android.platform.test.annotations.LargeTest;
import android.stats.devicepolicy.EventId;
+import com.android.compatibility.common.util.LocationModeSetter;
import com.android.cts.devicepolicy.metrics.DevicePolicyEventWrapper;
import com.android.ddmlib.Log.LogLevel;
import com.android.tradefed.device.DeviceNotAvailableException;