Avoid useless recompile
In certain cases where CompOS was present we were setting
odrefresh_status unconditionally to kCompilationRequired, meaning we
will run "odrefresh --compile", when we should set it whatever
"odrefresh --check-artifacts" returns (which might be kOkay, in which
case we can skip the compilation.
This makes little difference in practice, but it does mean a needless
divergence between the CompOS and non-CompOS cases.
Bug: 217365237
Test: Manual (see bug)
Ignore-AOSP-First: Internal has diverged due to a security fix
Change-Id: Idbd48594bb16065b9d9ffa7ecd40193aa61c19c6
Merged-In: Idbd48594bb16065b9d9ffa7ecd40193aa61c19c6
(cherry picked from commit 33cc23e238d0b40811ba901e8bf2b29ec654a997)
diff --git a/ondevice-signing/odsign_main.cpp b/ondevice-signing/odsign_main.cpp
index 99653fa..c6ebfc4 100644
--- a/ondevice-signing/odsign_main.cpp
+++ b/ondevice-signing/odsign_main.cpp
@@ -376,7 +376,8 @@
const SigningKey& signing_key,
bool* digests_verified) {
if (!directoryHasContent(kCompOsPendingArtifactsDir)) {
- return art::odrefresh::ExitCode::kCompilationRequired;
+ // No pending CompOS artifacts, all that matters is the current ones.
+ return checkArtifacts();
}
// CompOS has generated some artifacts that may, or may not, match the
@@ -527,8 +528,8 @@
if (useCompOs) {
auto compos_key = addCompOsCertToFsVerityKeyring(*key);
if (!compos_key.ok()) {
- odrefresh_status = art::odrefresh::ExitCode::kCompilationRequired;
LOG(WARNING) << compos_key.error();
+ odrefresh_status = checkArtifacts();
} else {
odrefresh_status =
checkCompOsPendingArtifacts(compos_key.value(), *key, &digests_verified);