Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90907aca authored by Todd Kennedy's avatar Todd Kennedy Committed by Rom Lemarchand
Browse files

Pass dexopt flags as integer

Instead of using a series of booleans, create a single flags integer
that contains all of the dexopt options.

(cherry picked from commit 76e767ca)

Change-Id: I35542aa73ca57b0e765d19b1339b1429849c1ae8
parent 4e5a5add
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -1081,9 +1081,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;
@@ -1092,6 +1091,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
+4 −5
Original line number Diff line number Diff line
@@ -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)
@@ -194,7 +193,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 },
+12 −3
Original line number Diff line number Diff line
@@ -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 */
@@ -241,9 +251,8 @@ int get_size(const char *uuid, const char *pkgname, int userid,
        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);