summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJooyung Han <jooyung@google.com>2024-04-18 10:49:05 +0900
committerJooyung Han <jooyung@google.com>2024-04-18 10:49:05 +0900
commite81e95b6758f83e43cb6ca6edff958ff606d37dc (patch)
tree8a2a92a862efe4d09774248c5b32a32d8bebc52b
parentcd8f9ea746c95ce65b7e7acd3d86d81ae76bd9e0 (diff)
downloadapex-e81e95b6758f83e43cb6ca6edff958ff606d37dc.tar.gz
Need INSTALL_TEST_ONLY_PACKAGE permission to install test apex
Otherwise apexes marked as "test-only" are rejected by PackageInstaller. Bug: 335491075 Test: atest VendorApexHostTestCases Change-Id: I2dc41e69fba059bb2eb650c8d603e51bd174adf5
-rw-r--r--tests/app/src/com/android/tests/apex/app/VendorApexTests.java24
1 files changed, 9 insertions, 15 deletions
diff --git a/tests/app/src/com/android/tests/apex/app/VendorApexTests.java b/tests/app/src/com/android/tests/apex/app/VendorApexTests.java
index 5e8519ab..1739bad4 100644
--- a/tests/app/src/com/android/tests/apex/app/VendorApexTests.java
+++ b/tests/app/src/com/android/tests/apex/app/VendorApexTests.java
@@ -32,6 +32,7 @@ import com.android.cts.install.lib.Install;
import com.android.cts.install.lib.InstallUtils;
import com.android.cts.install.lib.TestApp;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -63,11 +64,16 @@ public class VendorApexTests {
"com.android.apex.vendor.foo.v2_with_wrong_vndk_version", APEX_PACKAGE_NAME, 2,
/*isApex*/true, "com.android.apex.vendor.foo.v2_with_wrong_vndk_version.apex");
- @Test
- public void testRebootlessUpdate() throws Exception {
+ @Before
+ public void setUp() {
InstallUtils.dropShellPermissionIdentity();
- InstallUtils.adoptShellPermissionIdentity(Manifest.permission.INSTALL_PACKAGE_UPDATES);
+ InstallUtils.adoptShellPermissionIdentity(
+ Manifest.permission.INSTALL_PACKAGE_UPDATES,
+ Manifest.permission.INSTALL_TEST_ONLY_PACKAGE);
+ }
+ @Test
+ public void testRebootlessUpdate() throws Exception {
final PackageManager pm =
InstrumentationRegistry.getInstrumentation().getContext().getPackageManager();
{
@@ -87,9 +93,6 @@ public class VendorApexTests {
@Test
public void testGenerateLinkerConfigurationOnUpdate() throws Exception {
- InstallUtils.dropShellPermissionIdentity();
- InstallUtils.adoptShellPermissionIdentity(Manifest.permission.INSTALL_PACKAGE_UPDATES);
-
// There's no ld.config.txt for v1 (preinstalled, empty)
final Path ldConfigTxt = Paths.get("/linkerconfig", APEX_PACKAGE_NAME, "ld.config.txt");
assertTrue(Files.notExists(ldConfigTxt));
@@ -114,9 +117,6 @@ public class VendorApexTests {
@Test
public void testRestartServiceAfterRebootlessUpdate() throws Exception {
- InstallUtils.dropShellPermissionIdentity();
- InstallUtils.adoptShellPermissionIdentity(Manifest.permission.INSTALL_PACKAGE_UPDATES);
-
assertThat(SystemProperties.get("init.svc.apex_vendor_foo_v1", ""))
.isEqualTo("running");
assertThat(SystemProperties.get("init.svc.apex_vendor_foo_v2", ""))
@@ -136,9 +136,6 @@ public class VendorApexTests {
@Test
public void testInstallAbortsWhenVndkVersionMismatches() throws Exception {
- InstallUtils.dropShellPermissionIdentity();
- InstallUtils.adoptShellPermissionIdentity(Manifest.permission.INSTALL_PACKAGE_UPDATES);
-
InstallUtils.commitExpectingFailure(
AssertionError.class,
"vndkVersion\\(WrongVndkVersion\\) doesn't match with device VNDK version",
@@ -147,9 +144,6 @@ public class VendorApexTests {
@Test
public void testInstallAbortsWhenVndkVersionMismatches_Staged() throws Exception {
- InstallUtils.dropShellPermissionIdentity();
- InstallUtils.adoptShellPermissionIdentity(Manifest.permission.INSTALL_PACKAGE_UPDATES);
-
InstallUtils.commitExpectingFailure(
AssertionError.class,
"vndkVersion\\(WrongVndkVersion\\) doesn't match with device VNDK version",