Otapreopt: Fix after shared-library work
Commit b63d91fd2737680351876406277b6c759f4db33c broke the installd
to otapreopt connection. Fix this. Also refactor a bit to make an
inadvertant break harder.
Bug: 25612095
Change-Id: I8e7b944ecbd5457e4ac4d6ffffdb0468618cf65f
(cherry picked from commit aef445d1c659698612c0e5a8f3d5f2b9f8a2b778)
diff --git a/cmds/installd/otapreopt_chroot.cpp b/cmds/installd/otapreopt_chroot.cpp
index f7f69a9..be0ff2e 100644
--- a/cmds/installd/otapreopt_chroot.cpp
+++ b/cmds/installd/otapreopt_chroot.cpp
@@ -22,6 +22,8 @@
#include <android-base/macros.h>
#include <android-base/stringprintf.h>
+#include <installd_constants.h>
+
#ifndef LOG_TAG
#define LOG_TAG "otapreopt"
#endif
@@ -78,13 +80,13 @@
// Now go on and run otapreopt.
- const char* argv[1 + 9 + 1];
- CHECK_EQ(argc, 10);
+ const char* argv[1 + DEXOPT_PARAM_COUNT + 1];
+ CHECK_EQ(static_cast<size_t>(argc), DEXOPT_PARAM_COUNT + 1);
argv[0] = "/system/bin/otapreopt";
- for (size_t i = 1; i <= 9; ++i) {
+ for (size_t i = 1; i <= DEXOPT_PARAM_COUNT; ++i) {
argv[i] = arg[i];
}
- argv[10] = nullptr;
+ argv[DEXOPT_PARAM_COUNT + 1] = nullptr;
execv(argv[0], (char * const *)argv);
PLOG(ERROR) << "execv(OTAPREOPT) failed.";