installd: move check of jitzygote out of RunDex2oat

This makes it easier to extract RunDex2oat to individual file for unit
test.

Bug: 161470356
Test: atest frameworks/native/cmds/installd/
Change-Id: Iec2b4cafc7c1fc8e82b6283ab396cfb084c0584d
diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp
index 82be007..6bd4156 100644
--- a/cmds/installd/dexopt.cpp
+++ b/cmds/installd/dexopt.cpp
@@ -351,6 +351,7 @@
                bool enable_hidden_api_checks,
                bool generate_compact_dex,
                int dex_metadata_fd,
+               bool use_jitzygote_image,
                const char* compilation_reason) {
         // Get the relative path to the input file.
         const char* relative_input_file_name = get_location_from_path(input_file_name);
@@ -455,12 +456,7 @@
                 GetBoolProperty(kMinidebugInfoSystemProperty, kMinidebugInfoSystemPropertyDefault);
 
         std::string boot_image;
-        std::string use_jitzygote_image =
-            server_configurable_flags::GetServerConfigurableFlag(RUNTIME_NATIVE_BOOT_NAMESPACE,
-                                                                 ENABLE_JITZYGOTE_IMAGE,
-                                                                 /*default_value=*/ "");
-
-        if (use_jitzygote_image == "true" || IsBootClassPathProfilingEnable()) {
+        if (use_jitzygote_image) {
           boot_image = StringPrintf("--boot-image=%s", kJitZygoteImage);
         } else {
           boot_image = MapPropertyToArg("dalvik.vm.boot-image", "--boot-image=%s");
@@ -2220,6 +2216,12 @@
         }
     }
 
+    std::string jitzygote_flag = server_configurable_flags::GetServerConfigurableFlag(
+        RUNTIME_NATIVE_BOOT_NAMESPACE,
+        ENABLE_JITZYGOTE_IMAGE,
+        /*default_value=*/ "");
+    bool use_jitzygote_image = jitzygote_flag == "true" || IsBootClassPathProfilingEnable();
+
     LOG(VERBOSE) << "DexInv: --- BEGIN '" << dex_path << "' ---";
 
     RunDex2Oat runner(input_fd.get(),
@@ -2243,6 +2245,7 @@
                       enable_hidden_api_checks,
                       generate_compact_dex,
                       dex_metadata_fd.get(),
+                      use_jitzygote_image,
                       compilation_reason);
 
     pid_t pid = fork();