Snap for 5932576 from 2f2d8ca38169ccc86aeafd6674df04d502cf356a to android10-tests-release
Change-Id: I05c67604e07ce63edcf2fc2b8ad735d036c13f90
diff --git a/hostsidetests/appsecurity/test-apps/SplitApp/src/com/android/cts/splitapp/SplitAppTest.java b/hostsidetests/appsecurity/test-apps/SplitApp/src/com/android/cts/splitapp/SplitAppTest.java
index de7c837..15aa05e 100644
--- a/hostsidetests/appsecurity/test-apps/SplitApp/src/com/android/cts/splitapp/SplitAppTest.java
+++ b/hostsidetests/appsecurity/test-apps/SplitApp/src/com/android/cts/splitapp/SplitAppTest.java
@@ -514,7 +514,7 @@
// enforcement, so we verify that total/free space are identical.
final long totalDelta = Math.abs(current.getTotalSpace() - primary.getTotalSpace());
final long freeDelta = Math.abs(current.getFreeSpace() - primary.getFreeSpace());
- if (totalDelta > MB_IN_BYTES || freeDelta > MB_IN_BYTES) {
+ if (totalDelta > MB_IN_BYTES * 300 || freeDelta > MB_IN_BYTES * 300) {
fail("Expected primary storage to be on same volume as app");
}
}
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/AdbProvisioningTests.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/AdbProvisioningTests.java
index 218d6b7..5100aca 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/AdbProvisioningTests.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/AdbProvisioningTests.java
@@ -19,6 +19,7 @@
import static com.android.cts.devicepolicy.DeviceAndProfileOwnerTest.DEVICE_ADMIN_APK;
import static com.android.cts.devicepolicy.DeviceAndProfileOwnerTest.DEVICE_ADMIN_PKG;
import static com.android.cts.devicepolicy.metrics.DevicePolicyEventLogVerifier.assertMetricsLogged;
+import static com.android.cts.devicepolicy.metrics.DevicePolicyEventLogVerifier.isStatsdEnabled;
import com.android.cts.devicepolicy.metrics.DevicePolicyEventWrapper;
import com.android.tradefed.device.DeviceNotAvailableException;
@@ -47,7 +48,7 @@
}
public void testAdbDeviceOwnerLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
@@ -61,7 +62,7 @@
}
public void testAdbProfileOwnerLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CrossProfileAppsHostSideTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CrossProfileAppsHostSideTest.java
index b59222e..f5c099d 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CrossProfileAppsHostSideTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/CrossProfileAppsHostSideTest.java
@@ -1,6 +1,7 @@
package com.android.cts.devicepolicy;
import static com.android.cts.devicepolicy.metrics.DevicePolicyEventLogVerifier.assertMetricsLogged;
+import static com.android.cts.devicepolicy.metrics.DevicePolicyEventLogVerifier.isStatsdEnabled;
import android.stats.devicepolicy.EventId;
@@ -105,7 +106,7 @@
}
public void testStartMainActivity_logged() throws Exception {
- if (!mHasManagedUserFeature) {
+ if (!mHasManagedUserFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(
@@ -124,7 +125,7 @@
}
public void testGetTargetUserProfiles_logged() throws Exception {
- if (!mHasManagedUserFeature) {
+ if (!mHasManagedUserFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
index ceafda1..32874a9 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
@@ -17,6 +17,7 @@
package com.android.cts.devicepolicy;
import static com.android.cts.devicepolicy.metrics.DevicePolicyEventLogVerifier.assertMetricsLogged;
+import static com.android.cts.devicepolicy.metrics.DevicePolicyEventLogVerifier.isStatsdEnabled;
import android.platform.test.annotations.RequiresDevice;
import android.stats.devicepolicy.EventId;
@@ -212,7 +213,7 @@
}
public void testInstallCaCertLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
@@ -278,13 +279,15 @@
// The DPC should still be able to manage app restrictions normally.
executeDeviceTestClass(".ApplicationRestrictionsTest");
- assertMetricsLogged(getDevice(), () -> {
- executeDeviceTestMethod(".ApplicationRestrictionsTest",
- "testSetApplicationRestrictions");
- }, new DevicePolicyEventWrapper.Builder(EventId.SET_APPLICATION_RESTRICTIONS_VALUE)
- .setAdminPackageName(DEVICE_ADMIN_PKG)
- .setStrings(APP_RESTRICTIONS_TARGET_APP_PKG)
- .build());
+ if (isStatsdEnabled(getDevice())) {
+ assertMetricsLogged(getDevice(), () -> {
+ executeDeviceTestMethod(".ApplicationRestrictionsTest",
+ "testSetApplicationRestrictions");
+ }, new DevicePolicyEventWrapper.Builder(EventId.SET_APPLICATION_RESTRICTIONS_VALUE)
+ .setAdminPackageName(DEVICE_ADMIN_PKG)
+ .setStrings(APP_RESTRICTIONS_TARGET_APP_PKG)
+ .build());
+ }
} finally {
changeApplicationRestrictionsManagingPackage(null);
}
@@ -541,7 +544,7 @@
@RequiresDevice
public void testAlwaysOnVpnPackageLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
// Will be uninstalled in tearDown().
@@ -636,14 +639,16 @@
return;
}
executeDeviceTestClass(".PersistentIntentResolvingTest");
- assertMetricsLogged(getDevice(), () -> {
- executeDeviceTestMethod(".PersistentIntentResolvingTest",
- "testAddPersistentPreferredActivityYieldsReceptionAtTarget");
- }, new DevicePolicyEventWrapper.Builder(EventId.ADD_PERSISTENT_PREFERRED_ACTIVITY_VALUE)
+ if (isStatsdEnabled(getDevice())) {
+ assertMetricsLogged(getDevice(), () -> {
+ executeDeviceTestMethod(".PersistentIntentResolvingTest",
+ "testAddPersistentPreferredActivityYieldsReceptionAtTarget");
+ }, new DevicePolicyEventWrapper.Builder(EventId.ADD_PERSISTENT_PREFERRED_ACTIVITY_VALUE)
.setAdminPackageName(DEVICE_ADMIN_PKG)
.setStrings(DEVICE_ADMIN_PKG,
"com.android.cts.deviceandprofileowner.EXAMPLE_ACTION")
.build());
+ }
}
public void testScreenCaptureDisabled() throws Exception {
@@ -688,17 +693,20 @@
return;
}
executeDeviceTestClass(".SupportMessageTest");
- assertMetricsLogged(getDevice(), () -> {
- executeDeviceTestMethod(
- ".SupportMessageTest", "testShortSupportMessageSetGetAndClear");
- }, new DevicePolicyEventWrapper.Builder(EventId.SET_SHORT_SUPPORT_MESSAGE_VALUE)
+ if (isStatsdEnabled(getDevice())) {
+ assertMetricsLogged(getDevice(), () -> {
+ executeDeviceTestMethod(
+ ".SupportMessageTest", "testShortSupportMessageSetGetAndClear");
+ }, new DevicePolicyEventWrapper.Builder(EventId.SET_SHORT_SUPPORT_MESSAGE_VALUE)
.setAdminPackageName(DEVICE_ADMIN_PKG)
.build());
- assertMetricsLogged(getDevice(), () -> {
- executeDeviceTestMethod(".SupportMessageTest", "testLongSupportMessageSetGetAndClear");
- }, new DevicePolicyEventWrapper.Builder(EventId.SET_LONG_SUPPORT_MESSAGE_VALUE)
+ assertMetricsLogged(getDevice(), () -> {
+ executeDeviceTestMethod(".SupportMessageTest",
+ "testLongSupportMessageSetGetAndClear");
+ }, new DevicePolicyEventWrapper.Builder(EventId.SET_LONG_SUPPORT_MESSAGE_VALUE)
.setAdminPackageName(DEVICE_ADMIN_PKG)
.build());
+ }
}
public void testApplicationHidden() throws Exception {
@@ -707,11 +715,12 @@
}
installAppPermissionAppAsUser();
executeDeviceTestClass(".ApplicationHiddenTest");
- installAppAsUser(PERMISSIONS_APP_APK, mUserId);
- assertMetricsLogged(getDevice(), () -> {
- executeDeviceTestMethod(".ApplicationHiddenTest",
- "testSetApplicationHidden");
- }, new DevicePolicyEventWrapper.Builder(EventId.SET_APPLICATION_HIDDEN_VALUE)
+ if (isStatsdEnabled(getDevice())) {
+ installAppAsUser(PERMISSIONS_APP_APK, mUserId);
+ assertMetricsLogged(getDevice(), () -> {
+ executeDeviceTestMethod(".ApplicationHiddenTest",
+ "testSetApplicationHidden");
+ }, new DevicePolicyEventWrapper.Builder(EventId.SET_APPLICATION_HIDDEN_VALUE)
.setAdminPackageName(DEVICE_ADMIN_PKG)
.setBoolean(false)
.setStrings(PERMISSIONS_APP_PKG, "hidden")
@@ -721,6 +730,7 @@
.setBoolean(false)
.setStrings(PERMISSIONS_APP_PKG, "not_hidden")
.build());
+ }
}
public void testAccountManagement_deviceAndProfileOwnerAlwaysAllowed() throws Exception {
@@ -807,13 +817,15 @@
runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".DelegatedCertInstallerTest", mUserId);
- assertMetricsLogged(getDevice(), () -> {
+ if (isStatsdEnabled(getDevice())) {
+ assertMetricsLogged(getDevice(), () -> {
runDeviceTestsAsUser(DEVICE_ADMIN_PKG, ".DelegatedCertInstallerTest",
"testInstallKeyPair", mUserId);
- }, new DevicePolicyEventWrapper.Builder(EventId.SET_CERT_INSTALLER_PACKAGE_VALUE)
- .setAdminPackageName(DEVICE_ADMIN_PKG)
- .setStrings(CERT_INSTALLER_PKG)
- .build());
+ }, new DevicePolicyEventWrapper.Builder(EventId.SET_CERT_INSTALLER_PACKAGE_VALUE)
+ .setAdminPackageName(DEVICE_ADMIN_PKG)
+ .setStrings(CERT_INSTALLER_PKG)
+ .build());
+ }
}
public interface DelegatedCertInstallerTestAction {
@@ -1042,7 +1054,7 @@
}
public void testDisallowAdjustVolumeMutedLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
@@ -1065,14 +1077,17 @@
try {
installAppAsUser(INTENT_RECEIVER_APK, mUserId);
executeDeviceTestClass(".LockTaskTest");
- assertMetricsLogged(
- getDevice(),
- () -> executeDeviceTestMethod(".LockTaskTest", "testStartLockTask"),
- new DevicePolicyEventWrapper.Builder(EventId.SET_LOCKTASK_MODE_ENABLED_VALUE)
- .setAdminPackageName(DEVICE_ADMIN_PKG)
- .setBoolean(true)
- .setStrings(DEVICE_ADMIN_PKG)
- .build());
+ if (isStatsdEnabled(getDevice())) {
+ assertMetricsLogged(
+ getDevice(),
+ () -> executeDeviceTestMethod(".LockTaskTest", "testStartLockTask"),
+ new DevicePolicyEventWrapper.Builder(
+ EventId.SET_LOCKTASK_MODE_ENABLED_VALUE)
+ .setAdminPackageName(DEVICE_ADMIN_PKG)
+ .setBoolean(true)
+ .setStrings(DEVICE_ADMIN_PKG)
+ .build());
+ }
} catch (AssertionError ex) {
// STOPSHIP(b/32771855), remove this once we fixed the bug.
executeShellCommand("dumpsys activity activities");
@@ -1270,7 +1285,7 @@
}
public void testSetCameraDisabledLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
@@ -1435,7 +1450,7 @@
}
public void testInstallKeyPairLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
@@ -1452,7 +1467,7 @@
}
public void testGenerateKeyPairLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
@@ -1475,7 +1490,7 @@
}
public void testSetKeyPairCertificateLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
@@ -1493,10 +1508,11 @@
}
executeDeviceTestClass(".AccessibilityServicesTest");
- assertMetricsLogged(getDevice(), () -> {
- executeDeviceTestMethod(".AccessibilityServicesTest",
- "testPermittedAccessibilityServices");
- }, new DevicePolicyEventWrapper
+ if (isStatsdEnabled(getDevice())) {
+ assertMetricsLogged(getDevice(), () -> {
+ executeDeviceTestMethod(".AccessibilityServicesTest",
+ "testPermittedAccessibilityServices");
+ }, new DevicePolicyEventWrapper
.Builder(EventId.SET_PERMITTED_ACCESSIBILITY_SERVICES_VALUE)
.setAdminPackageName(DEVICE_ADMIN_PKG)
.setStrings((String[]) null)
@@ -1511,6 +1527,7 @@
.setAdminPackageName(DEVICE_ADMIN_PKG)
.setStrings("com.google.pkg.one", "com.google.pkg.two")
.build());
+ }
}
public void testPermittedInputMethods() throws Exception {
@@ -1519,10 +1536,10 @@
}
executeDeviceTestClass(".InputMethodsTest");
- assertMetricsLogged(getDevice(), () -> {
- executeDeviceTestMethod(".InputMethodsTest",
- "testPermittedInputMethods");
- }, new DevicePolicyEventWrapper.Builder(EventId.SET_PERMITTED_INPUT_METHODS_VALUE)
+ if (isStatsdEnabled(getDevice())) {
+ assertMetricsLogged(getDevice(), () -> {
+ executeDeviceTestMethod(".InputMethodsTest", "testPermittedInputMethods");
+ }, new DevicePolicyEventWrapper.Builder(EventId.SET_PERMITTED_INPUT_METHODS_VALUE)
.setAdminPackageName(DEVICE_ADMIN_PKG)
.setStrings((String[]) null)
.build(),
@@ -1534,6 +1551,7 @@
.setAdminPackageName(DEVICE_ADMIN_PKG)
.setStrings("com.google.pkg.one", "com.google.pkg.two")
.build());
+ }
}
public void testSetStorageEncryption() throws Exception {
@@ -1547,7 +1565,7 @@
}
public void testPasswordMethodsLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
@@ -1589,7 +1607,7 @@
}
public void testLockNowLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
@@ -1601,7 +1619,7 @@
}
public void testSetKeyguardDisabledFeaturesLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
@@ -1630,7 +1648,7 @@
}
public void testSetUserRestrictionLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
@@ -1664,7 +1682,7 @@
}
public void testSetSecureSettingLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
@@ -1690,7 +1708,7 @@
}
public void testSetPermissionPolicyLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
@@ -1714,7 +1732,7 @@
}
public void testSetPermissionGrantStateLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
installAppPermissionAppAsUser();
@@ -1758,7 +1776,7 @@
}
public void testEnableSystemAppLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
final List<String> enabledSystemPackageNames = getEnabledSystemPackageNames();
@@ -1777,7 +1795,7 @@
}
public void testEnableSystemAppWithIntentLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
final String systemPackageToEnable = getLaunchableSystemPackage();
@@ -1797,7 +1815,7 @@
}
public void testSetUninstallBlockedLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
installAppAsUser(PERMISSIONS_APP_APK, mUserId);
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerPlusProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerPlusProfileOwnerTest.java
index 25168ff..a847ae3 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerPlusProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerPlusProfileOwnerTest.java
@@ -17,6 +17,7 @@
package com.android.cts.devicepolicy;
import static com.android.cts.devicepolicy.metrics.DevicePolicyEventLogVerifier.assertMetricsLogged;
+import static com.android.cts.devicepolicy.metrics.DevicePolicyEventLogVerifier.isStatsdEnabled;
import com.android.cts.devicepolicy.metrics.DevicePolicyEventWrapper;
import com.android.cts.devicepolicy.metrics.DevicePolicyEventWrapper.Builder;
@@ -326,7 +327,7 @@
}
public void testWipeData_managedProfileLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
int profileUserId = setupManagedProfile(COMP_DPC_APK, COMP_DPC_PKG, COMP_DPC_ADMIN);
@@ -353,7 +354,7 @@
}
public void testWipeData_secondaryUserLogged() throws Exception {
- if (!mHasFeature || !canCreateAdditionalUsers(1)) {
+ if (!mHasFeature || !canCreateAdditionalUsers(1) || !isStatsdEnabled(getDevice())) {
return;
}
int secondaryUserId = setupManagedSecondaryUser();
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
index 7c335c2..7d64577 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceOwnerTest.java
@@ -17,6 +17,7 @@
package com.android.cts.devicepolicy;
import static com.android.cts.devicepolicy.metrics.DevicePolicyEventLogVerifier.assertMetricsLogged;
+import static com.android.cts.devicepolicy.metrics.DevicePolicyEventLogVerifier.isStatsdEnabled;
import android.stats.devicepolicy.EventId;
@@ -143,11 +144,13 @@
return;
}
executeDeviceOwnerTest("LockScreenInfoTest");
- assertMetricsLogged(getDevice(), () -> {
- executeDeviceTestMethod(".LockScreenInfoTest", "testSetAndGetLockInfo");
- }, new DevicePolicyEventWrapper.Builder(EventId.SET_DEVICE_OWNER_LOCK_SCREEN_INFO_VALUE)
- .setAdminPackageName(DEVICE_OWNER_PKG)
- .build());
+ if (isStatsdEnabled(getDevice())) {
+ assertMetricsLogged(getDevice(), () -> {
+ executeDeviceTestMethod(".LockScreenInfoTest", "testSetAndGetLockInfo");
+ }, new DevicePolicyEventWrapper.Builder(EventId.SET_DEVICE_OWNER_LOCK_SCREEN_INFO_VALUE)
+ .setAdminPackageName(DEVICE_OWNER_PKG)
+ .build());
+ }
}
public void testWifi() throws Exception {
@@ -155,11 +158,13 @@
return;
}
executeDeviceOwnerTest("WifiTest");
- assertMetricsLogged(getDevice(), () -> {
- executeDeviceTestMethod(".WifiTest", "testGetWifiMacAddress");
- }, new DevicePolicyEventWrapper.Builder(EventId.GET_WIFI_MAC_ADDRESS_VALUE)
- .setAdminPackageName(DEVICE_OWNER_PKG)
- .build());
+ if (isStatsdEnabled(getDevice())) {
+ assertMetricsLogged(getDevice(), () -> {
+ executeDeviceTestMethod(".WifiTest", "testGetWifiMacAddress");
+ }, new DevicePolicyEventWrapper.Builder(EventId.GET_WIFI_MAC_ADDRESS_VALUE)
+ .setAdminPackageName(DEVICE_OWNER_PKG)
+ .build());
+ }
}
public void testRemoteBugreportWithTwoUsers() throws Exception {
@@ -491,7 +496,7 @@
}
public void testSecurityLoggingEnabledLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
@@ -581,7 +586,7 @@
}
public void testSetSystemUpdatePolicyLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
@@ -703,19 +708,22 @@
return;
}
executeDeviceOwnerTest("AdminActionBookkeepingTest");
- assertMetricsLogged(getDevice(), () -> {
- executeDeviceTestMethod(".AdminActionBookkeepingTest", "testRetrieveSecurityLogs");
- }, new DevicePolicyEventWrapper.Builder(EventId.RETRIEVE_SECURITY_LOGS_VALUE)
+ if (isStatsdEnabled(getDevice())) {
+ assertMetricsLogged(getDevice(), () -> {
+ executeDeviceTestMethod(".AdminActionBookkeepingTest", "testRetrieveSecurityLogs");
+ }, new DevicePolicyEventWrapper.Builder(EventId.RETRIEVE_SECURITY_LOGS_VALUE)
.setAdminPackageName(DEVICE_OWNER_PKG)
.build(),
- new DevicePolicyEventWrapper.Builder(EventId.RETRIEVE_PRE_REBOOT_SECURITY_LOGS_VALUE)
+ new DevicePolicyEventWrapper.Builder(
+ EventId.RETRIEVE_PRE_REBOOT_SECURITY_LOGS_VALUE)
.setAdminPackageName(DEVICE_OWNER_PKG)
.build());
- assertMetricsLogged(getDevice(), () -> {
- executeDeviceTestMethod(".AdminActionBookkeepingTest", "testRequestBugreport");
- }, new DevicePolicyEventWrapper.Builder(EventId.REQUEST_BUGREPORT_VALUE)
- .setAdminPackageName(DEVICE_OWNER_PKG)
- .build());
+ assertMetricsLogged(getDevice(), () -> {
+ executeDeviceTestMethod(".AdminActionBookkeepingTest", "testRequestBugreport");
+ }, new DevicePolicyEventWrapper.Builder(EventId.REQUEST_BUGREPORT_VALUE)
+ .setAdminPackageName(DEVICE_OWNER_PKG)
+ .build());
+ }
}
public void testBluetoothRestriction() throws Exception {
@@ -927,7 +935,7 @@
}
public void testInstallUpdateLogged() throws Exception {
- if (!mHasFeature || !isDeviceAb()) {
+ if (!mHasFeature || !isDeviceAb() || !isStatsdEnabled(getDevice())) {
return;
}
pushUpdateFileToDevice("wrongHash.zip");
@@ -961,7 +969,7 @@
}
public void testSetKeyguardDisabledLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
@@ -972,7 +980,7 @@
}
public void testSetStatusBarDisabledLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
index 3f7bd9d..f95c5f4 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ManagedProfileTest.java
@@ -17,6 +17,7 @@
package com.android.cts.devicepolicy;
import static com.android.cts.devicepolicy.metrics.DevicePolicyEventLogVerifier.assertMetricsLogged;
+import static com.android.cts.devicepolicy.metrics.DevicePolicyEventLogVerifier.isStatsdEnabled;
import android.stats.devicepolicy.EventId;
@@ -190,7 +191,7 @@
}
public void testWipeDataLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertTrue(listUsers().contains(mProfileUserId));
@@ -426,15 +427,17 @@
runDeviceTestsAsUser(MANAGED_PROFILE_PKG,
MANAGED_PROFILE_PKG + ".ManagedProfileTest", mProfileUserId);
- assertMetricsLogged(getDevice(), () -> {
- runDeviceTestsAsUser(
- MANAGED_PROFILE_PKG, MANAGED_PROFILE_PKG + ".ManagedProfileTest",
- "testAddCrossProfileIntentFilter_all", mProfileUserId);
- }, new DevicePolicyEventWrapper.Builder(EventId.ADD_CROSS_PROFILE_INTENT_FILTER_VALUE)
- .setAdminPackageName(MANAGED_PROFILE_PKG)
- .setInt(1)
- .setStrings("com.android.cts.managedprofile.ACTION_TEST_ALL_ACTIVITY")
- .build());
+ if (isStatsdEnabled(getDevice())) {
+ assertMetricsLogged(getDevice(), () -> {
+ runDeviceTestsAsUser(
+ MANAGED_PROFILE_PKG, MANAGED_PROFILE_PKG + ".ManagedProfileTest",
+ "testAddCrossProfileIntentFilter_all", mProfileUserId);
+ }, new DevicePolicyEventWrapper.Builder(EventId.ADD_CROSS_PROFILE_INTENT_FILTER_VALUE)
+ .setAdminPackageName(MANAGED_PROFILE_PKG)
+ .setInt(1)
+ .setStrings("com.android.cts.managedprofile.ACTION_TEST_ALL_ACTIVITY")
+ .build());
+ }
// Set up filters from primary to managed profile
String command = "am start -W --user " + mProfileUserId + " " + MANAGED_PROFILE_PKG
@@ -845,10 +848,11 @@
contactsTestSet.checkIfCanFilterEnterpriseContacts(false);
contactsTestSet.checkIfCanFilterSelfContacts();
contactsTestSet.checkIfNoEnterpriseDirectoryFound();
- assertMetricsLogged(getDevice(), () -> {
- contactsTestSet.setCallerIdEnabled(true);
- contactsTestSet.setCallerIdEnabled(false);
- }, new DevicePolicyEventWrapper
+ if (isStatsdEnabled(getDevice())) {
+ assertMetricsLogged(getDevice(), () -> {
+ contactsTestSet.setCallerIdEnabled(true);
+ contactsTestSet.setCallerIdEnabled(false);
+ }, new DevicePolicyEventWrapper
.Builder(EventId.SET_CROSS_PROFILE_CALLER_ID_DISABLED_VALUE)
.setAdminPackageName(MANAGED_PROFILE_PKG)
.setBoolean(false)
@@ -858,19 +862,21 @@
.setAdminPackageName(MANAGED_PROFILE_PKG)
.setBoolean(true)
.build());
- assertMetricsLogged(getDevice(), () -> {
- contactsTestSet.setContactsSearchEnabled(true);
- contactsTestSet.setContactsSearchEnabled(false);
- }, new DevicePolicyEventWrapper
+ assertMetricsLogged(getDevice(), () -> {
+ contactsTestSet.setContactsSearchEnabled(true);
+ contactsTestSet.setContactsSearchEnabled(false);
+ }, new DevicePolicyEventWrapper
.Builder(EventId.SET_CROSS_PROFILE_CONTACTS_SEARCH_DISABLED_VALUE)
.setAdminPackageName(MANAGED_PROFILE_PKG)
.setBoolean(false)
.build(),
new DevicePolicyEventWrapper
- .Builder(EventId.SET_CROSS_PROFILE_CONTACTS_SEARCH_DISABLED_VALUE)
+ .Builder(
+ EventId.SET_CROSS_PROFILE_CONTACTS_SEARCH_DISABLED_VALUE)
.setAdminPackageName(MANAGED_PROFILE_PKG)
.setBoolean(true)
.build());
+ }
return null;
} finally {
// reset policies
@@ -891,13 +897,15 @@
"testDefaultOrganizationNameIsNull", mProfileUserId);
runDeviceTestsAsUser(MANAGED_PROFILE_PKG, ".OrganizationInfoTest",
mProfileUserId);
- assertMetricsLogged(getDevice(), () -> {
- runDeviceTestsAsUser(
- MANAGED_PROFILE_PKG, MANAGED_PROFILE_PKG + ".OrganizationInfoTest",
- "testSetOrganizationColor", mProfileUserId);
- }, new DevicePolicyEventWrapper.Builder(EventId.SET_ORGANIZATION_COLOR_VALUE)
- .setAdminPackageName(MANAGED_PROFILE_PKG)
- .build());
+ if (isStatsdEnabled(getDevice())) {
+ assertMetricsLogged(getDevice(), () -> {
+ runDeviceTestsAsUser(
+ MANAGED_PROFILE_PKG, MANAGED_PROFILE_PKG + ".OrganizationInfoTest",
+ "testSetOrganizationColor", mProfileUserId);
+ }, new DevicePolicyEventWrapper.Builder(EventId.SET_ORGANIZATION_COLOR_VALUE)
+ .setAdminPackageName(MANAGED_PROFILE_PKG)
+ .build());
+ }
}
public void testPasswordMinimumRestrictions() throws Exception {
@@ -1032,7 +1040,7 @@
}
public void testCrossProfileWidgetsLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
@@ -1611,7 +1619,7 @@
}
public void testCreateSeparateChallengeChangedLogged() throws Exception {
- if (!mHasFeature || !mHasSecureLockScreen) {
+ if (!mHasFeature || !mHasSecureLockScreen || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
@@ -1623,7 +1631,7 @@
}
public void testSetProfileNameLogged() throws Exception {
- if (!mHasFeature) {
+ if (!mHasFeature || !isStatsdEnabled(getDevice())) {
return;
}
assertMetricsLogged(getDevice(), () -> {
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/metrics/DevicePolicyEventLogVerifier.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/metrics/DevicePolicyEventLogVerifier.java
index 264bd08..16e9e7f 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/metrics/DevicePolicyEventLogVerifier.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/metrics/DevicePolicyEventLogVerifier.java
@@ -19,6 +19,7 @@
import com.android.os.AtomsProto.Atom;
import com.android.os.StatsLog.EventMetricData;
+import com.android.tradefed.device.DeviceNotAvailableException;
import com.android.tradefed.device.ITestDevice;
import java.util.ArrayList;
import java.util.List;
@@ -37,12 +38,14 @@
/**
* Asserts that <code>expectedLogs</code> were logged as a result of executing
- * <code>action</code>, in the same order.
+ * <code>action</code>, in the same order. Note that {@link Action#apply() } is always
+ * invoked on the <code>action</code> parameter, even if statsd logs are disabled.
*/
public static void assertMetricsLogged(ITestDevice device, Action action,
DevicePolicyEventWrapper... expectedLogs) throws Exception {
final AtomMetricTester logVerifier = new AtomMetricTester(device);
if (logVerifier.isStatsdDisabled()) {
+ action.apply();
return;
}
try {
@@ -61,6 +64,11 @@
}
}
+ public static boolean isStatsdEnabled(ITestDevice device) throws DeviceNotAvailableException {
+ final AtomMetricTester logVerifier = new AtomMetricTester(device);
+ return !logVerifier.isStatsdDisabled();
+ }
+
private static void assertExpectedMetricLogged(List<EventMetricData> data,
DevicePolicyEventWrapper expectedLog) {
final List<DevicePolicyEventWrapper> closestMatches = new ArrayList<>();
diff --git a/tests/tests/media/src/android/media/cts/AudioPlaybackCaptureTest.java b/tests/tests/media/src/android/media/cts/AudioPlaybackCaptureTest.java
index 4c234ce..b9885d2 100644
--- a/tests/tests/media/src/android/media/cts/AudioPlaybackCaptureTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioPlaybackCaptureTest.java
@@ -448,6 +448,8 @@
public void testPlaybackCaptureDoS() throws Exception {
final int UPPER_BOUND_TO_CONCURENT_PLAYBACK_CAPTURE = 1000;
final int MIN_NB_OF_CONCURENT_PLAYBACK_CAPTURE = 5;
+ final int UNREGISTER_POLICY_MS = 100;
+ final int UNREGISTER_POLICY_RETRY = 10;
mAPCTestConfig.matchingUsages = new int[]{ AudioAttributes.USAGE_MEDIA };
@@ -488,7 +490,18 @@
// Stopping one AR must allow creating a new one
audioRecords.peek().stop();
audioRecords.pop().release();
- audioRecords.push(createDefaultPlaybackCaptureRecord());
+ int retry = 0;
+ while (true) {
+ try {
+ audioRecords.push(createDefaultPlaybackCaptureRecord());
+ break;
+ } catch (UnsupportedOperationException e) {
+ if (retry++ == UNREGISTER_POLICY_RETRY) {
+ throw e;
+ }
+ Thread.sleep(UNREGISTER_POLICY_MS);
+ }
+ }
// That new one must still be able to capture
audioRecords.peek().startRecording();
diff --git a/tests/tests/security/src/android/security/cts/PackageSignatureTest.java b/tests/tests/security/src/android/security/cts/PackageSignatureTest.java
index 6280ce8..283910bf 100644
--- a/tests/tests/security/src/android/security/cts/PackageSignatureTest.java
+++ b/tests/tests/security/src/android/security/cts/PackageSignatureTest.java
@@ -134,7 +134,7 @@
"com.android.cts.priv.ctsshim",
"com.android.cts.ctsshim",
// Test APEX used in CTS tests.
- "com.android.apex.cts.shim,",
+ "com.android.apex.cts.shim",
// Oom Catcher package to prevent tests from ooming device.
"com.android.cts.oomcatcher"