Fix OverlayHostTest to work on secondary users.
This is critical for automotive CTS approval.
bug: 140734485
Test: cts-tradefed run cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.OverlayHostTest
Change-Id: I1b0b7dd708526fe1d0102d6b8862d45b83c45fdd
diff --git a/hostsidetests/appsecurity/src/android/appsecurity/cts/OverlayHostTest.java b/hostsidetests/appsecurity/src/android/appsecurity/cts/OverlayHostTest.java
index 20978c6..a1ec91e 100644
--- a/hostsidetests/appsecurity/src/android/appsecurity/cts/OverlayHostTest.java
+++ b/hostsidetests/appsecurity/src/android/appsecurity/cts/OverlayHostTest.java
@@ -79,7 +79,10 @@
private String getStateForOverlay(String overlayPackage) throws Exception {
String result = getDevice().executeShellCommand("cmd overlay dump");
- int startIndex = result.indexOf(overlayPackage + ":");
+
+ String overlayPackageForCurrentUser = overlayPackage + ":" + getDevice().getCurrentUser();
+
+ int startIndex = result.indexOf(overlayPackageForCurrentUser);
if (startIndex < 0) {
return null;
}
@@ -122,7 +125,7 @@
new InstallMultiple().addApk(overlayApk).run();
waitForOverlayState(overlayPackage, STATE_NO_IDMAP);
- getDevice().executeShellCommand("cmd overlay enable " + overlayPackage);
+ getDevice().executeShellCommand("cmd overlay enable --user current " + overlayPackage);
waitForOverlayState(overlayPackage, STATE_NO_IDMAP);
} finally {
getDevice().uninstallPackage(TARGET_PACKAGE);
@@ -143,7 +146,7 @@
new InstallMultiple().addApk(targetApk).run();
waitForOverlayState(overlayPackage, STATE_DISABLED);
- getDevice().executeShellCommand("cmd overlay enable " + overlayPackage);
+ getDevice().executeShellCommand("cmd overlay enable --user current " + overlayPackage);
waitForOverlayState(overlayPackage, STATE_ENABLED);
runDeviceTests(TEST_APP_PACKAGE, TEST_APP_CLASS, testMethod);
@@ -170,7 +173,7 @@
assertFalse(getDevice().getInstalledPackageNames().contains(OVERLAY_ANDROID_PACKAGE));
// The package of the installed overlay should not appear in the overlay manager list.
- assertFalse(getDevice().executeShellCommand("cmd overlay list")
+ assertFalse(getDevice().executeShellCommand("cmd overlay list --user current ")
.contains(" " + OVERLAY_ANDROID_PACKAGE + "\n"));
} finally {
getDevice().uninstallPackage(OVERLAY_ANDROID_PACKAGE);
@@ -222,7 +225,7 @@
assertFalse(getDevice().getInstalledPackageNames().contains(OVERLAY_ALL_PACKAGE));
// The package of the installed overlay should not appear in the overlay manager list.
- assertFalse(getDevice().executeShellCommand("cmd overlay list")
+ assertFalse(getDevice().executeShellCommand("cmd overlay list --user current")
.contains(" " + OVERLAY_ALL_PACKAGE + "\n"));
} finally {
getDevice().uninstallPackage(OVERLAY_ALL_PACKAGE);