Pass app image format property to dex2oat

Enables using lz4 for app images.

Bug: 22858531

Change-Id: Ife2bca8883c2868d30b45e0eec210f96d589068e
diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp
index f71284c..a4018d7 100644
--- a/cmds/installd/commands.cpp
+++ b/cmds/installd/commands.cpp
@@ -666,6 +666,14 @@
 
     bool generate_debug_info = check_boolean_property("debug.generate-debug-info");
 
+    char app_image_format[kPropertyValueMax];
+    char image_format_arg[strlen("--image-format=") + kPropertyValueMax];
+    bool have_app_image_format =
+        get_property("dalvik.vm.appimageformat", app_image_format, NULL) > 0;
+    if (have_app_image_format) {
+        sprintf(image_format_arg, "--image-format=%s", app_image_format);
+    }
+
     static const char* DEX2OAT_BIN = "/system/bin/dex2oat";
 
     static const char* RUNTIME_ARG = "--runtime-arg";
@@ -756,6 +764,7 @@
                      + (have_dex2oat_relocation_skip_flag ? 2 : 0)
                      + (generate_debug_info ? 1 : 0)
                      + (debuggable ? 1 : 0)
+                     + (have_app_image_format ? 1 : 0)
                      + dex2oat_flags_count
                      + profile_files_fd.size()
                      + reference_profile_files_fd.size()];
@@ -798,6 +807,9 @@
     if (debuggable) {
         argv[i++] = "--debuggable";
     }
+    if (have_app_image_format) {
+        argv[i++] = image_format_arg;
+    }
     if (dex2oat_flags_count) {
         i += split(dex2oat_flags, argv + i);
     }