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

Commit 8f2a40ef authored by Yang Tianping's avatar Yang Tianping
Browse files

installd: Skip profile preparation if primary.prof does not exist



If the primary.prof does not exist in .dm file, the profman here will
create an empty reference profile, which will slow down the dex2oat.

And, the profman process is expensive (about hundreds of
milliseconds), we should avoid it if the primary.prof does not exist.

Bug: 204415663

Change-Id: I8ed16b2090659b2541c71b748f7e1a1552fa1a5e
Signed-off-by: default avatarYang Tianping <yangtianping@oppo.com>
parent 0c872e3a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ cc_defaults {
        "libprocessgroup",
        "libselinux",
        "libutils",
        "libziparchive",
        "server_configurable_flags",
    ],
    static_libs: [
@@ -267,6 +268,7 @@ cc_binary {
        "libprocessgroup",
        "libselinux",
        "libutils",
        "libziparchive",
        "server_configurable_flags",
    ],
}
+16 −1
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@
#include <server_configurable_flags/get_flags.h>
#include <system/thread_defs.h>
#include <utils/Mutex.h>
#include <ziparchive/zip_archive.h>

#include "dexopt.h"
#include "dexopt_return_codes.h"
@@ -2738,6 +2739,20 @@ bool create_profile_snapshot(int32_t app_id, const std::string& package_name,
    }
}

static bool check_profile_exists_in_dexmetadata(const std::string& dex_metadata) {
    ZipArchiveHandle zip = nullptr;
    if (OpenArchive(dex_metadata.c_str(), &zip) != 0) {
        PLOG(ERROR) << "Failed to open dm '" << dex_metadata << "'";
        return false;
    }

    ZipEntry64 entry;
    int result = FindEntry(zip, "primary.prof", &entry);
    CloseArchive(zip);

    return result != 0 ? false : true;
}

bool prepare_app_profile(const std::string& package_name,
                         userid_t user_id,
                         appid_t app_id,
@@ -2754,7 +2769,7 @@ bool prepare_app_profile(const std::string& package_name,
    }

    // Check if we need to install the profile from the dex metadata.
    if (!dex_metadata) {
    if (!dex_metadata || !check_profile_exists_in_dexmetadata(dex_metadata->c_str())) {
        return true;
    }

+2 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ cc_test {
        "libasync_safe",
        "libdiskusage",
        "libinstalld",
        "libziparchive",
        "liblog",
        "liblogwrap",
    ],
@@ -89,6 +90,7 @@ cc_test {
        "libasync_safe",
        "libdiskusage",
        "libinstalld",
        "libziparchive",
        "liblog",
        "liblogwrap",
    ],