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

Commit 49ee078b authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8323531 from 9ca4184c to tm-release

Change-Id: I89ce8694316f5ebf59403eea3ca6e385dbbdbaa4
parents c6045bce 9ca4184c
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -3576,5 +3576,23 @@ binder::Status InstalldNativeService::cleanupInvalidPackageDirs(
    return ok();
}

binder::Status InstalldNativeService::getOdexVisibility(
        const std::string& packageName, const std::string& apkPath,
        const std::string& instructionSet, const std::optional<std::string>& outputPath,
        int32_t* _aidl_return) {
    ENFORCE_UID(AID_SYSTEM);
    CHECK_ARGUMENT_PACKAGE_NAME(packageName);
    CHECK_ARGUMENT_PATH(apkPath);
    CHECK_ARGUMENT_PATH(outputPath);
    LOCK_PACKAGE();

    const char* apk_path = apkPath.c_str();
    const char* instruction_set = instructionSet.c_str();
    const char* oat_dir = outputPath ? outputPath->c_str() : nullptr;

    *_aidl_return = get_odex_visibility(apk_path, instruction_set, oat_dir);
    return *_aidl_return == -1 ? error() : ok();
}

}  // namespace installd
}  // namespace android
+5 −0
Original line number Diff line number Diff line
@@ -183,6 +183,11 @@ public:
    binder::Status cleanupInvalidPackageDirs(const std::optional<std::string>& uuid, int32_t userId,
                                             int32_t flags);

    binder::Status getOdexVisibility(const std::string& packageName, const std::string& apkPath,
                                     const std::string& instructionSet,
                                     const std::optional<std::string>& outputPath,
                                     int32_t* _aidl_return);

private:
    std::recursive_mutex mLock;
    std::unordered_map<userid_t, std::weak_ptr<std::shared_mutex>> mUserIdLock;
+3 −0
Original line number Diff line number Diff line
@@ -130,6 +130,9 @@ interface IInstalld {

    void cleanupInvalidPackageDirs(@nullable @utf8InCpp String uuid, int userId, int flags);

    int getOdexVisibility(@utf8InCpp String packageName, @utf8InCpp String apkPath,
            @utf8InCpp String instructionSet, @nullable @utf8InCpp String outputPath);

    const int FLAG_STORAGE_DE = 0x1;
    const int FLAG_STORAGE_CE = 0x2;
    const int FLAG_STORAGE_EXTERNAL = 0x4;
+37 −9
Original line number Diff line number Diff line
@@ -2773,6 +2773,12 @@ bool prepare_app_profile(const std::string& package_name,
                         const std::string& profile_name,
                         const std::string& code_path,
                         const std::optional<std::string>& dex_metadata) {
    if (user_id != USER_NULL) {
        if (user_id < 0) {
            LOG(ERROR) << "Unexpected user ID " << user_id;
            return false;
        }

        // Prepare the current profile.
        std::string cur_profile = create_current_profile_path(user_id, package_name, profile_name,
                                                              /*is_secondary_dex*/ false);
@@ -2781,6 +2787,10 @@ bool prepare_app_profile(const std::string& package_name,
            PLOG(ERROR) << "Failed to prepare " << cur_profile;
            return false;
        }
    } else {
        // Prepare the reference profile as the system user.
        user_id = USER_SYSTEM;
    }

    // Check if we need to install the profile from the dex metadata.
    if (!dex_metadata || !check_profile_exists_in_dexmetadata(dex_metadata->c_str())) {
@@ -2788,7 +2798,8 @@ bool prepare_app_profile(const std::string& package_name,
    }

    // We have a dex metdata. Merge the profile into the reference profile.
    unique_fd ref_profile_fd = open_reference_profile(uid, package_name, profile_name,
    unique_fd ref_profile_fd =
            open_reference_profile(multiuser_get_uid(user_id, app_id), package_name, profile_name,
                                   /*read_write*/ true, /*is_secondary_dex*/ false);
    unique_fd dex_metadata_fd(TEMP_FAILURE_RETRY(
            open(dex_metadata->c_str(), O_RDONLY | O_NOFOLLOW)));
@@ -2823,5 +2834,22 @@ bool prepare_app_profile(const std::string& package_name,
    return true;
}

int get_odex_visibility(const char* apk_path, const char* instruction_set, const char* oat_dir) {
    char oat_path[PKG_PATH_MAX];
    if (!create_oat_out_path(apk_path, instruction_set, oat_dir, /*is_secondary_dex=*/false,
                             oat_path)) {
        return -1;
    }
    struct stat st;
    if (stat(oat_path, &st) == -1) {
        if (errno == ENOENT) {
            return ODEX_NOT_FOUND;
        }
        PLOG(ERROR) << "Could not stat " << oat_path;
        return -1;
    }
    return (st.st_mode & S_IROTH) ? ODEX_IS_PUBLIC : ODEX_IS_PRIVATE;
}

}  // namespace installd
}  // namespace android
+9 −4
Original line number Diff line number Diff line
@@ -98,10 +98,9 @@ bool copy_system_profile(const std::string& system_profile,
                         const std::string& pkgname,
                         const std::string& profile_name);

// Prepare the app profile for the given code path:
//  - create the current profile using profile_name
//  - merge the profile from the dex metadata file (if present) into
//    the reference profile.
// Prepares the app profile for the package at the given path:
// - Creates the current profile for the given user ID, unless the user ID is `USER_NULL`.
// - Merges the profile from the dex metadata file (if present) into the reference profile.
bool prepare_app_profile(const std::string& package_name,
                         userid_t user_id,
                         appid_t app_id,
@@ -153,6 +152,12 @@ const char* select_execution_binary(
        bool is_release,
        bool is_debuggable_build);

// Returns `ODEX_NOT_FOUND` if the optimized artifacts are not found, or `ODEX_IS_PUBLIC` if the
// optimized artifacts are accessible by all apps, or `ODEX_IS_PRIVATE` if the optimized artifacts
// are only accessible by this app, or -1 if failed to get the visibility of the optimized
// artifacts.
int get_odex_visibility(const char* apk_path, const char* instruction_set, const char* oat_dir);

}  // namespace installd
}  // namespace android

Loading