Propagate hiddenapi cmdline flags in OatFileAssistant::Dex2Oat
ART can invoke dex2oat on an out-of-date or non-existent oat file.
This code path will ignore any runtime hidden API enforcement policy
settings. Change the code to set the correct flag and add a gtest
for it.
Bug: 79680013
Test: make test-art-host-gtest-oat_file_assistant_test
Change-Id: Id6aa5e45d11626facb590621d43e2c52b9269b12
diff --git a/runtime/oat_file_assistant.cc b/runtime/oat_file_assistant.cc
index 7d69927..4880d83 100644
--- a/runtime/oat_file_assistant.cc
+++ b/runtime/oat_file_assistant.cc
@@ -36,6 +36,7 @@
#include "exec_utils.h"
#include "gc/heap.h"
#include "gc/space/image_space.h"
+#include "hidden_api.h"
#include "image.h"
#include "oat.h"
#include "runtime.h"
@@ -823,6 +824,11 @@
argv.push_back("--compiler-filter=verify-none");
}
+ if (runtime->GetHiddenApiEnforcementPolicy() != hiddenapi::EnforcementPolicy::kNoChecks) {
+ argv.push_back("--runtime-arg");
+ argv.push_back("-Xhidden-api-checks");
+ }
+
if (runtime->MustRelocateIfPossible()) {
argv.push_back("--runtime-arg");
argv.push_back("-Xrelocate");