From c5ee51b87354b5f741eb956528ef9367917e9030 Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Wed, 31 Jan 2024 10:26:02 +0800 Subject: Add service dexopt_chroot_setup and artd_pre_reboot. Boilerplate changes. Bug: 311377497 Test: manual - Call getDexoptChrootSetupServiceRegisterer().waitForService() Test: manual - Set up a chroot environment and call getArtdPreRebootServiceRegisterer().waitForService() Test: manual - Test the fuzzers on host and on device following the instructions at https://source.android.com/docs/security/test/libfuzzer. Change-Id: Ic576d741ae0fe058833d3bbad6ebb5188ccf200a --- artd/artd_main.cc | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'artd/artd_main.cc') diff --git a/artd/artd_main.cc b/artd/artd_main.cc index 9fe5bd81b4..212e9c4046 100644 --- a/artd/artd_main.cc +++ b/artd/artd_main.cc @@ -22,10 +22,39 @@ #include "android/binder_process.h" #include "artd.h" +namespace art { +namespace artd { +namespace { + +constexpr int kErrorUsage = 100; + +[[noreturn]] void ParseError(const std::string& error_msg) { + LOG(ERROR) << error_msg; + std::cerr << error_msg << "\n"; + exit(kErrorUsage); +} + +Options ParseOptions(int argc, char** argv) { + Options options; + for (int i = 1; i < argc; i++) { + std::string_view arg = argv[i]; + if (arg == "--pre-reboot") { + options.is_pre_reboot = true; + } else { + ParseError("Unknown option " + std::string(arg)); + } + } + return options; +} + +} // namespace +} // namespace artd +} // namespace art + int main([[maybe_unused]] int argc, char* argv[]) { android::base::InitLogging(argv); - auto artd = ndk::SharedRefBase::make(); + auto artd = ndk::SharedRefBase::make(art::artd::ParseOptions(argc, argv)); LOG(INFO) << "Starting artd"; -- cgit v1.2.3-59-g8ed1b