Don't do force-compile in CompOS mode
This was originally done to ensure that CompOS didn't reuse old
untrusted artifacts. But that won't happen - CompOS always runs with
the output directory initially empty; authfs doesn't provide a
mechanism to have a writable directory with untrusted files in it
(b/203630168).
And it is harmful - e.g. if ART has not been updated the force-compile
will generate a boot.art, which will then be deleted on reboot, and as
a consequence the other artifacts won't be loaded into system server
etc.
Bug: 211458160
Test: atest OdrefreshHostTest#verifyCompilationOsMode
Test: manual
Change-Id: I888e4b13dd29e298f6635569d5f06d36bc672fc8
diff --git a/odrefresh/odrefresh.cc b/odrefresh/odrefresh.cc
index 315f589..f0d3f19 100644
--- a/odrefresh/odrefresh.cc
+++ b/odrefresh/odrefresh.cc
@@ -1216,13 +1216,6 @@
return RemoveArtifactsDirectory() ? ExitCode::kCompilationRequired : ExitCode::kCleanupFailed;
};
- // Compilation OS cannot reuse the artifacts generated before because it cannot securely verify
- // them (b/203630168). Therefore, we always compile everything in Compilation OS. This is fine
- // because Compilation OS runs when the device is idling and it does not affact boot time.
- if (config_.GetCompilationOsMode()) {
- return cleanup_and_compile_all();
- }
-
std::optional<std::vector<apex::ApexInfo>> apex_info_list = GetApexInfoList();
if (!apex_info_list.has_value()) {
// This should never happen, further up-to-date checks are not possible if it does.
diff --git a/test/odsign/test-src/com/android/tests/odsign/OdrefreshHostTest.java b/test/odsign/test-src/com/android/tests/odsign/OdrefreshHostTest.java
index c6fc37a..7cd6e37 100644
--- a/test/odsign/test-src/com/android/tests/odsign/OdrefreshHostTest.java
+++ b/test/odsign/test-src/com/android/tests/odsign/OdrefreshHostTest.java
@@ -36,8 +36,8 @@
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-import java.util.regex.Pattern;
import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
* Test to check end-to-end odrefresh invocations, but without odsign, fs-verity, and ART runtime
@@ -181,10 +181,12 @@
@Test
public void verifyCompilationOsMode() throws Exception {
mTestUtils.removeCompilationLogToAvoidBackoff();
+ simulateApexUpgrade();
long timeMs = getCurrentTimeMs();
- getDevice().executeShellV2Command(ODREFRESH_BIN + " --compilation-os-mode --compile");
+ getDevice().executeShellV2Command(
+ ODREFRESH_BIN + " --no-refresh --partial-compilation"
+ + " --compilation-os-mode --compile");
- // odrefresh should unconditionally compile everything in Compilation OS.
assertArtifactsModifiedAfter(getZygoteArtifacts(), timeMs);
assertArtifactsModifiedAfter(getSystemServerArtifacts(), timeMs);