Otapreopt: Move binary to Soong
Add a helper library using ART defaults to expose the image relocation
constants. Then move the otapreopt module to Android.bp.
Bug: 115993344
Test: mmma frameworks/native/cmds/installd
Change-Id: Ia5e114783150273c7806c1f1292ee7d3eff53e7c
diff --git a/cmds/installd/otapreopt.cpp b/cmds/installd/otapreopt.cpp
index 7291ef3..73098f8 100644
--- a/cmds/installd/otapreopt.cpp
+++ b/cmds/installd/otapreopt.cpp
@@ -32,6 +32,7 @@
#include <android-base/macros.h>
#include <android-base/stringprintf.h>
#include <android-base/strings.h>
+#include <art_image_values.h>
#include <cutils/fs.h>
#include <cutils/properties.h>
#include <dex2oat_return_codes.h>
@@ -441,8 +442,8 @@
cmd.push_back(StringPrintf("--instruction-set=%s", isa));
- int32_t base_offset = ChooseRelocationOffsetDelta(ART_BASE_ADDRESS_MIN_DELTA,
- ART_BASE_ADDRESS_MAX_DELTA);
+ int32_t base_offset = ChooseRelocationOffsetDelta(art::GetImageMinBaseAddressDelta(),
+ art::GetImageMaxBaseAddressDelta());
cmd.push_back(StringPrintf("--base-offset-delta=%d", base_offset));
std::string error_msg;
@@ -466,9 +467,9 @@
}
cmd.push_back(StringPrintf("--oat-file=%s", oat_path.c_str()));
- int32_t base_offset = ChooseRelocationOffsetDelta(ART_BASE_ADDRESS_MIN_DELTA,
- ART_BASE_ADDRESS_MAX_DELTA);
- cmd.push_back(StringPrintf("--base=0x%x", ART_BASE_ADDRESS + base_offset));
+ int32_t base_offset = ChooseRelocationOffsetDelta(art::GetImageMinBaseAddressDelta(),
+ art::GetImageMaxBaseAddressDelta());
+ cmd.push_back(StringPrintf("--base=0x%x", art::GetImageBaseAddress() + base_offset));
cmd.push_back(StringPrintf("--instruction-set=%s", isa));
@@ -610,7 +611,7 @@
// If the dexopt failed, we may have a stale boot image from a previous OTA run.
// Then regenerate and retry.
if (WEXITSTATUS(dexopt_result) ==
- static_cast<int>(art::dex2oat::ReturnCode::kCreateRuntime)) {
+ static_cast<int>(::art::dex2oat::ReturnCode::kCreateRuntime)) {
if (!PrepareBootImage(/* force */ true)) {
LOG(ERROR) << "Forced boot image creating failed. Original error return was "
<< dexopt_result;