Implement a tear-down phase in otapreopt_chroot.
Collect the list of APEX packages activated by `otapreopt_chroot` and
deactivate them after executing `otapreopt` (in its own process).
Also share android::installd::Exec between `otapreopt` and
`otapreopt_chroot`.
This tear-down phase ensures loop devices associated during by
`otapreopt_chroot` are detached before `otapreopt_chroot` exits.
Test: m otapreopt_chroot
Test: A/B OTA update test (asit/dexoptota/self_full).
Bug: 113373927
Bug: 120796514
Change-Id: I236ac49bb698fb672e7a4f9de9903229e535e9c6
diff --git a/cmds/installd/otapreopt_utils.h b/cmds/installd/otapreopt_utils.h
index 436e554..03a6d87 100644
--- a/cmds/installd/otapreopt_utils.h
+++ b/cmds/installd/otapreopt_utils.h
@@ -18,6 +18,8 @@
#define OTAPREOPT_UTILS_H_
#include <regex>
+#include <string>
+#include <vector>
namespace android {
namespace installd {
@@ -28,6 +30,9 @@
return std::regex_match(input, slot_suffix_match, slot_suffix_regex);
}
+// Wrapper on fork/execv to run a command in a subprocess.
+bool Exec(const std::vector<std::string>& arg_vector, std::string* error_msg);
+
} // namespace installd
} // namespace android