summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorNikita Ioffe <ioffe@google.com>2021-07-10 02:27:51 +0100
committerNikita Ioffe <ioffe@google.com>2021-07-12 13:51:11 +0000
commit3e62b8f748d39fd383eef0ef23a7d82303c4601e (patch)
tree8dc303e5598be533c2b217fa32ff09c0c54bd23d /tests
parent24e3ed6e783d1444ac815b7174840aaedd4730bb (diff)
Fix PackageManager query API's related to rebootless APEX updates
There were two bugs: 1. In case of the first update, ApexManager removed information about pre-installed version of the APEX. 2. After an update, getPackageInfo cache wasn't invalidated, which resulted in getPackageInfo returning stale information. Bug: 193085724 Test: atest ApexManagerTest Test: atest StagedInstallInternalTest Change-Id: I6df7b296cd5d83c93524178f1546855747ea6b07
Diffstat (limited to 'tests')
-rw-r--r--tests/StagedInstallTest/app/src/com/android/tests/stagedinstallinternal/StagedInstallInternalTest.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/StagedInstallTest/app/src/com/android/tests/stagedinstallinternal/StagedInstallInternalTest.java b/tests/StagedInstallTest/app/src/com/android/tests/stagedinstallinternal/StagedInstallInternalTest.java
index d6b3c27b4b09..9cdaef75c491 100644
--- a/tests/StagedInstallTest/app/src/com/android/tests/stagedinstallinternal/StagedInstallInternalTest.java
+++ b/tests/StagedInstallTest/app/src/com/android/tests/stagedinstallinternal/StagedInstallInternalTest.java
@@ -212,6 +212,28 @@ public class StagedInstallInternalTest {
assertThat(apex.applicationInfo.sourceDir).startsWith("/system/apex");
}
+ TestApp apex1 = new TestApp("TestRebootlessApexV1", "test.apex.rebootless", 1,
+ /* isApex= */ true, "test.rebootless_apex_v1.apex");
+ Install.single(apex1).commit();
+
+ {
+ PackageInfo apex = pm.getPackageInfo("test.apex.rebootless", PackageManager.MATCH_APEX);
+ assertThat(apex.getLongVersionCode()).isEqualTo(1);
+ assertThat(apex.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM).isEqualTo(0);
+ assertThat(apex.applicationInfo.flags & ApplicationInfo.FLAG_INSTALLED)
+ .isEqualTo(ApplicationInfo.FLAG_INSTALLED);
+ assertThat(apex.applicationInfo.sourceDir).startsWith("/data/apex/active");
+ }
+ {
+ PackageInfo apex = pm.getPackageInfo("test.apex.rebootless",
+ PackageManager.MATCH_APEX | PackageManager.MATCH_FACTORY_ONLY);
+ assertThat(apex.getLongVersionCode()).isEqualTo(1);
+ assertThat(apex.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
+ .isEqualTo(ApplicationInfo.FLAG_SYSTEM);
+ assertThat(apex.applicationInfo.flags & ApplicationInfo.FLAG_INSTALLED).isEqualTo(0);
+ assertThat(apex.applicationInfo.sourceDir).startsWith("/system/apex");
+ }
+
TestApp apex2 = new TestApp("TestRebootlessApexV1", "test.apex.rebootless", 2,
/* isApex= */ true, "test.rebootless_apex_v2.apex");
Install.single(apex2).commit();
@@ -224,6 +246,15 @@ public class StagedInstallInternalTest {
.isEqualTo(ApplicationInfo.FLAG_INSTALLED);
assertThat(apex.applicationInfo.sourceDir).startsWith("/data/apex/active");
}
+ {
+ PackageInfo apex = pm.getPackageInfo("test.apex.rebootless",
+ PackageManager.MATCH_APEX | PackageManager.MATCH_FACTORY_ONLY);
+ assertThat(apex.getLongVersionCode()).isEqualTo(1);
+ assertThat(apex.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM)
+ .isEqualTo(ApplicationInfo.FLAG_SYSTEM);
+ assertThat(apex.applicationInfo.flags & ApplicationInfo.FLAG_INSTALLED).isEqualTo(0);
+ assertThat(apex.applicationInfo.sourceDir).startsWith("/system/apex");
+ }
}
private static void assertSessionFailedWithMessage(int sessionId, String msg) {