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

Commit 199f93d9 authored by Mathieu Chartier's avatar Mathieu Chartier Committed by android-build-merger
Browse files

Merge "[view compilation] Add viewcompiler support to installd" am: e03e0690

am: 62509448

Change-Id: Id474f48e33a154219bc3f01daaab051e2976e2fc
parents bff2096b 62509448
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ cc_defaults {
        "dexopt.cpp",
        "globals.cpp",
        "utils.cpp",
        "view_compiler.cpp",
        ":installd_aidl",
    ],
    header_libs: [
@@ -190,6 +191,7 @@ cc_binary {
        "globals.cpp",
        "otapreopt.cpp",
        "utils.cpp",
        "view_compiler.cpp",
    ],

    header_libs: ["dex2oat_headers"],
+12 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@
#include "installd_deps.h"
#include "otapreopt_utils.h"
#include "utils.h"
#include "view_compiler.h"

#include "CacheTracker.h"
#include "MatchExtensionGen.h"
@@ -1831,6 +1832,17 @@ binder::Status InstalldNativeService::dexopt(const std::string& apkPath, int32_t
    return res ? error(res, error_msg) : ok();
}

binder::Status InstalldNativeService::compileLayouts(const std::string& apkPath,
                                                     const std::string& packageName,
                                                     const std ::string& outDexFile, int uid,
                                                     bool* _aidl_return) {
    const char* apk_path = apkPath.c_str();
    const char* package_name = packageName.c_str();
    const char* out_dex_file = outDexFile.c_str();
    *_aidl_return = android::installd::view_compiler(apk_path, package_name, out_dex_file, uid);
    return *_aidl_return ? ok() : error("viewcompiler failed");
}

binder::Status InstalldNativeService::markBootComplete(const std::string& instructionSet) {
    ENFORCE_UID(AID_SYSTEM);
    std::lock_guard<std::recursive_mutex> lock(mLock);
+3 −0
Original line number Diff line number Diff line
@@ -89,6 +89,9 @@ public:
            const std::unique_ptr<std::string>& dexMetadataPath,
            const std::unique_ptr<std::string>& compilationReason);

    binder::Status compileLayouts(const std::string& apkPath, const std::string& packageName,
                                  const std::string& outDexFile, int uid, bool* _aidl_return);

    binder::Status rmdex(const std::string& codePath, const std::string& instructionSet);

    binder::Status mergeProfiles(int32_t uid, const std::string& packageName,
+2 −0
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ interface IInstalld {
            @nullable @utf8InCpp String profileName,
            @nullable @utf8InCpp String dexMetadataPath,
            @nullable @utf8InCpp String compilationReason);
    boolean compileLayouts(@utf8InCpp String apkPath, @utf8InCpp String packageName,
            @utf8InCpp String outDexFile, int uid);

    void rmdex(@utf8InCpp String codePath, @utf8InCpp String instructionSet);

+0 −21
Original line number Diff line number Diff line
@@ -628,27 +628,6 @@ static void open_profile_files(uid_t uid, const std::string& package_name,
    }
}

static void drop_capabilities(uid_t uid) {
    if (setgid(uid) != 0) {
        PLOG(ERROR) << "setgid(" << uid << ") failed in installd during dexopt";
        exit(DexoptReturnCodes::kSetGid);
    }
    if (setuid(uid) != 0) {
        PLOG(ERROR) << "setuid(" << uid << ") failed in installd during dexopt";
        exit(DexoptReturnCodes::kSetUid);
    }
    // drop capabilities
    struct __user_cap_header_struct capheader;
    struct __user_cap_data_struct capdata[2];
    memset(&capheader, 0, sizeof(capheader));
    memset(&capdata, 0, sizeof(capdata));
    capheader.version = _LINUX_CAPABILITY_VERSION_3;
    if (capset(&capheader, &capdata[0]) < 0) {
        PLOG(ERROR) << "capset failed";
        exit(DexoptReturnCodes::kCapSet);
    }
}

static constexpr int PROFMAN_BIN_RETURN_CODE_COMPILE = 0;
static constexpr int PROFMAN_BIN_RETURN_CODE_SKIP_COMPILATION = 1;
static constexpr int PROFMAN_BIN_RETURN_CODE_BAD_PROFILES = 2;
Loading