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

Commit a0af34de authored by Nicolas Geoffray's avatar Nicolas Geoffray
Browse files

Handle safe mode in PackageManager.

installd side of the change.

bug:37929796
Test: manual OTA with a safemode app.

(cherry picked from commit be6ecd6f)

Change-Id: I43dcdd3fea3f62398f16f89348c1a2f1b4b1bb6d
parent 584bc3ce
Loading
Loading
Loading
Loading
+15 −13
Original line number Diff line number Diff line
@@ -190,7 +190,7 @@ static const char* get_location_from_path(const char* path) {

static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vdex_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,
        const char* instruction_set, const char* compiler_filter,
        bool debuggable, bool post_bootcomplete, int profile_fd, const char* shared_libraries) {
    static const unsigned int MAX_INSTRUCTION_SET_LEN = 7;

@@ -240,7 +240,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd
                                 dex2oat_flags, NULL) <= 0 ? 0 : split_count(dex2oat_flags);
    ALOGV("dalvik.vm.dex2oat-flags=%s\n", dex2oat_flags);

    // If we booting without the real /data, don't spend time compiling.
    // If we are booting without the real /data, don't spend time compiling.
    char vold_decrypt[kPropertyValueMax];
    bool have_vold_decrypt = get_property("vold.decrypt", vold_decrypt, "") > 0;
    bool skip_compilation = (have_vold_decrypt &&
@@ -319,20 +319,24 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd

    // Compute compiler filter.

    bool have_dex2oat_compiler_filter_flag;
    bool have_dex2oat_compiler_filter_flag = false;
    if (skip_compilation) {
        strcpy(dex2oat_compiler_filter_arg, "--compiler-filter=extract");
        have_dex2oat_compiler_filter_flag = true;
        have_dex2oat_relocation_skip_flag = true;
    } else if (vm_safe_mode) {
        strcpy(dex2oat_compiler_filter_arg, "--compiler-filter=quicken");
        have_dex2oat_compiler_filter_flag = true;
    } else if (compiler_filter != nullptr &&
            strlen(compiler_filter) + strlen("--compiler-filter=") <
    } else if (compiler_filter != nullptr) {
        if (strlen(compiler_filter) + strlen("--compiler-filter=") <
                    arraysize(dex2oat_compiler_filter_arg)) {
            sprintf(dex2oat_compiler_filter_arg, "--compiler-filter=%s", compiler_filter);
            have_dex2oat_compiler_filter_flag = true;
        } else {
            ALOGW("Compiler filter name '%s' is too large (max characters is %zu)",
                  compiler_filter,
                  kPropertyValueMax);
        }
    }

    if (!have_dex2oat_compiler_filter_flag) {
        char dex2oat_compiler_filter_flag[kPropertyValueMax];
        have_dex2oat_compiler_filter_flag = get_property("dalvik.vm.dex2oat-filter",
                                                         dex2oat_compiler_filter_flag, NULL) > 0;
@@ -1475,7 +1479,6 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins
    }

    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;
    bool profile_guided = (dexopt_flags & DEXOPT_PROFILE_GUIDED) != 0;
@@ -1573,7 +1576,6 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins
                    swap_fd.get(),
                    instruction_set,
                    compiler_filter,
                    vm_safe_mode,
                    debuggable,
                    boot_complete,
                    reference_profile_fd.get(),