diff options
author | Todd Kennedy <toddke@google.com> | 2015-09-25 07:47:47 -0700 |
---|---|---|
committer | Todd Kennedy <toddke@google.com> | 2015-09-25 10:43:56 -0700 |
commit | 76e767ca14bcbb4bc809cd1279ece82a3aabe8a4 (patch) | |
tree | b2b0ff35c3813d2e526a22fa021882aa736ea24b | |
parent | 7f413889a3f0bff0c159141abb498650305f2089 (diff) | |
download | native-76e767ca14bcbb4bc809cd1279ece82a3aabe8a4.tar.gz |
Pass dexopt flags as integer
Instead of using a series of booleans, create a single flags integer
that contains all of the dexopt options.
Change-Id: I35542aa73ca57b0e765d19b1339b1429849c1ae8
-rw-r--r-- | cmds/installd/commands.cpp | 13 | ||||
-rw-r--r-- | cmds/installd/installd.cpp | 9 | ||||
-rw-r--r-- | cmds/installd/installd.h | 15 |
3 files changed, 26 insertions, 11 deletions
diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp index fbe42f4952..906a09bafd 100644 --- a/cmds/installd/commands.cpp +++ b/cmds/installd/commands.cpp @@ -1043,9 +1043,8 @@ static void SetDex2OatAndPatchOatScheduling(bool set_to_bg) { } } -int dexopt(const char *apk_path, uid_t uid, bool is_public, - const char *pkgname, const char *instruction_set, int dexopt_needed, - bool vm_safe_mode, bool debuggable, const char* oat_dir, bool boot_complete) +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) { struct utimbuf ut; struct stat input_stat; @@ -1054,6 +1053,14 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *input_file; char in_odex_path[PKG_PATH_MAX]; int res, input_fd=-1, out_fd=-1, swap_fd=-1; + bool is_public = (dexopt_flags & DEXOPT_PUBLIC) != 0; + bool vm_safe_mode = (dexopt_flags & DEXOPT_SAFEMODE) != 0; + bool debuggable = (dexopt_flags & DEXOPT_DEBUGGABLE) != 0; + bool boot_complete = (dexopt_flags & DEXOPT_BOOTCOMPLETE) != 0; + + if ((dexopt_flags & DEXOPT_MASK) != 0) { + LOG_FATAL("dexopt flags contains unknown fields\n"); + } // Early best-effort check whether we can fit the the path into our buffers. // Note: the cache path will require an additional 5 bytes for ".swap", but we'll try to run diff --git a/cmds/installd/installd.cpp b/cmds/installd/installd.cpp index 3d82663bf0..3a9b54f5b2 100644 --- a/cmds/installd/installd.cpp +++ b/cmds/installd/installd.cpp @@ -47,10 +47,9 @@ static int do_install(char **arg, char reply[REPLY_MAX] __unused) static int do_dexopt(char **arg, char reply[REPLY_MAX] __unused) { - /* apk_path, uid, is_public, pkgname, instruction_set, - * dexopt_needed, vm_safe_mode, debuggable, oat_dir, boot_complete */ - return dexopt(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3], arg[4], atoi(arg[5]), - atoi(arg[6]), atoi(arg[7]), arg[8], atoi(arg[9])); + /* apk_path, uid, pkgname, instruction_set, dexopt_needed, oat_dir, dexopt_flags */ + return dexopt(arg[0], atoi(arg[1]), arg[2], arg[3], atoi(arg[4]), + arg[5], atoi(arg[6])); } static int do_mark_boot_complete(char **arg, char reply[REPLY_MAX] __unused) @@ -188,7 +187,7 @@ struct cmdinfo { struct cmdinfo cmds[] = { { "ping", 0, do_ping }, { "install", 5, do_install }, - { "dexopt", 10, do_dexopt }, + { "dexopt", 7, do_dexopt }, { "markbootcomplete", 1, do_mark_boot_complete }, { "movedex", 3, do_move_dex }, { "rmdex", 2, do_rm_dex }, diff --git a/cmds/installd/installd.h b/cmds/installd/installd.h index 535e80ce96..461b08a752 100644 --- a/cmds/installd/installd.h +++ b/cmds/installd/installd.h @@ -90,6 +90,16 @@ #define DEXOPT_PATCHOAT_NEEDED 2 #define DEXOPT_SELF_PATCHOAT_NEEDED 3 +/**************************************************************************** + * IMPORTANT: These values are passed from Java code. Keep them in sync with + * frameworks/base/services/core/java/com/android/server/pm/Installer.java + ***************************************************************************/ +#define DEXOPT_PUBLIC (1 << 1) +#define DEXOPT_SAFEMODE (1 << 2) +#define DEXOPT_DEBUGGABLE (1 << 3) +#define DEXOPT_BOOTCOMPLETE (1 << 4) +#define DEXOPT_MASK (DEXOPT_PUBLIC | DEXOPT_SAFEMODE | DEXOPT_DEBUGGABLE | DEXOPT_BOOTCOMPLETE) + #define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) /* data structures */ @@ -234,9 +244,8 @@ int get_size(const char *uuid, const char *pkgname, userid_t userid, const char const char *fwdlock_apkpath, const char *asecpath, const char *instruction_set, int64_t *codesize, int64_t *datasize, int64_t *cachesize, int64_t *asecsize); int free_cache(const char *uuid, int64_t free_size); -int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *pkgName, - const char *instruction_set, int dexopt_needed, bool vm_safe_mode, - bool debuggable, const char* oat_dir, bool boot_complete); +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); int mark_boot_complete(const char *instruction_set); int movefiles(); int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int userId); |