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

Commit 7360d432 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

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

Merge "installd: Skip profile preparation if primary.prof does not exist" am: 54481db5 am: 801bb02b am: 53a92090 am: dd350df3

Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1873890

Change-Id: I6f3628d738ee4ab5e011499c01583d108ffc03b7
parents 7faf212d dd350df3
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",
    ],