OSDN Git Service

Support to pass <uses-library> option through to dex2oat.
authorJeff Hao <jeffhao@google.com>
Wed, 16 Mar 2016 22:59:25 +0000 (15:59 -0700)
committerJeff Hao <jeffhao@google.com>
Wed, 27 Apr 2016 18:13:10 +0000 (11:13 -0700)
This change takes an app's shared libraries specified by <uses-library>
and passes it through to dex2oat to be used during compilation.

Part of a multi-project change.

Includes fix from c09662d9bbd35840b24cae8d336a0d11c0cbdb7b

Bug: 26880306

(cherry-picked from commmit de7f0cf8a699f6f7a7d29b4a14d800bea9abbef4)

Change-Id: Ideb2aba46f4cf52acb9dd480993513a60dbfd6ce

cmds/installd/commands.cpp
cmds/installd/commands.h
cmds/installd/installd.cpp
cmds/installd/otapreopt.cpp

index f4d894b..60118a8 100644 (file)
@@ -725,7 +725,7 @@ static void run_patchoat(int input_fd, int oat_fd, const char* input_file_name,
 static void run_dex2oat(int zip_fd, int oat_fd, int image_fd, const char* input_file_name,
         const char* output_file_name, int swap_fd, const char *instruction_set,
         const char* compiler_filter, bool vm_safe_mode, bool debuggable, bool post_bootcomplete,
-        int profile_fd) {
+        int profile_fd, const char* shared_libraries) {
     static const unsigned int MAX_INSTRUCTION_SET_LEN = 7;
 
     if (strlen(instruction_set) >= MAX_INSTRUCTION_SET_LEN) {
@@ -887,7 +887,8 @@ static void run_dex2oat(int zip_fd, int oat_fd, int image_fd, const char* input_
                      + (debuggable ? 1 : 0)
                      + (have_app_image_format ? 1 : 0)
                      + dex2oat_flags_count
-                     + (profile_fd == -1 ? 0 : 1)];
+                     + (profile_fd == -1 ? 0 : 1)
+                     + (shared_libraries != nullptr ? 4 : 0)];
     int i = 0;
     argv[i++] = DEX2OAT_BIN;
     argv[i++] = zip_fd_arg;
@@ -940,6 +941,12 @@ static void run_dex2oat(int zip_fd, int oat_fd, int image_fd, const char* input_
     if (profile_fd != -1) {
         argv[i++] = profile_arg;
     }
+    if (shared_libraries != nullptr) {
+        argv[i++] = RUNTIME_ARG;
+        argv[i++] = "-classpath";
+        argv[i++] = RUNTIME_ARG;
+        argv[i++] = shared_libraries;
+    }
     // Do not add after dex2oat_flags, they should override others for debugging.
     argv[i] = NULL;
 
@@ -1311,7 +1318,7 @@ bool merge_profiles(uid_t uid, const char *pkgname) {
 
 int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* instruction_set,
            int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter,
-           const char* volume_uuid ATTRIBUTE_UNUSED)
+           const char* volume_uuid ATTRIBUTE_UNUSED, const char* shared_libraries)
 {
     struct utimbuf ut;
     struct stat input_stat;
@@ -1463,7 +1470,7 @@ int dexopt(const char* apk_path, uid_t uid, const char* pkgname, const char* ins
             }
             run_dex2oat(input_fd, out_fd, image_fd, input_file_name, out_path, swap_fd,
                         instruction_set, compiler_filter, vm_safe_mode, debuggable, boot_complete,
-                        reference_profile_fd);
+                        reference_profile_fd, shared_libraries);
         } else {
             ALOGE("Invalid dexopt needed: %d\n", dexopt_needed);
             exit(73);
index 81c13b4..41cc209 100644 (file)
@@ -56,7 +56,7 @@ bool merge_profiles(uid_t uid, const char *pkgname);
 
 int dexopt(const char *apk_path, uid_t uid, const char *pkgName, const char *instruction_set,
            int dexopt_needed, const char* oat_dir, int dexopt_flags, const char* compiler_filter,
-           const char* volume_uuid);
+           const char* volume_uuid, const char* shared_libraries);
 int mark_boot_complete(const char *instruction_set);
 int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId);
 int idmap(const char *target_path, const char *overlay_path, uid_t uid);
index eb51e70..e8fce91 100644 (file)
@@ -266,7 +266,8 @@ static int do_dexopt(char **arg, char reply[REPLY_MAX])
                   arg[5],                      // oat_dir
                   dexopt_flags,
                   arg[7],                      // compiler_filter
-                  parse_null(arg[8]));         // volume_uuid
+                  parse_null(arg[8]),          // volume_uuid
+                  parse_null(arg[9]));         // shared_libraries
 }
 
 static int do_merge_profiles(char **arg, char reply[REPLY_MAX])
@@ -414,7 +415,7 @@ struct cmdinfo cmds[] = {
     { "create_user_data",     4, do_create_user_data },
     { "destroy_user_data",    3, do_destroy_user_data },
 
-    { "dexopt",               9, do_dexopt },
+    { "dexopt",              10, do_dexopt },
     { "markbootcomplete",     1, do_mark_boot_complete },
     { "rmdex",                2, do_rm_dex },
     { "freecache",            2, do_free_cache },
index 245694a..ac511ec 100644 (file)
@@ -365,7 +365,8 @@ private:
                 package_parameters_[5],                   // oat_dir
                 atoi(package_parameters_[6]),             // dexopt_flags
                 package_parameters_[7],                   // compiler_filter
-                ParseNull(package_parameters_[8]));       // volume_uuid
+                ParseNull(package_parameters_[8]),        // volume_uuid
+                ParseNull(package_parameters_[9]));       // shared_libraries
         return ret;
     }
 
@@ -483,7 +484,7 @@ private:
     // to compile, instead of the A properties we could get from init/get_property.
     SystemProperties system_properties_;
 
-    const char* package_parameters_[9];
+    const char* package_parameters_[10];
 
     // Store environment values we need to set.
     std::vector<std::string> environ_;