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

Commit 6991f1cd authored by David Brazdil's avatar David Brazdil Committed by android-build-merger
Browse files

Add \'rmprofiles\' command to installd am: d828d683

am: e6aebea2

* commit 'e6aebea2':
  Add 'rmprofiles' command to installd
parents 3c02e66e e6aebea2
Loading
Loading
Loading
Loading
+17 −5
Original line number Diff line number Diff line
@@ -161,17 +161,20 @@ static std::string create_primary_profile(const std::string& profile_dir) {
    return StringPrintf("%s/%s", profile_dir.c_str(), PRIMARY_PROFILE_NAME);
}

static void unlink_reference_profile(const char* pkgname) {
static bool unlink_reference_profile(const char* pkgname) {
    std::string reference_profile_dir = create_data_ref_profile_package_path(pkgname);
    std::string reference_profile = create_primary_profile(reference_profile_dir);
    if (unlink(reference_profile.c_str()) != 0) {
        if (errno != ENOENT) {
            PLOG(WARNING) << "Could not unlink " << reference_profile;
            return false;
        }
    }
    return true;
}

static void unlink_current_profiles(const char* pkgname) {
static bool unlink_current_profiles(const char* pkgname) {
    bool success = true;
    std::vector<userid_t> users = get_known_users(/*volume_uuid*/ nullptr);
    for (auto user : users) {
        std::string profile_dir = create_data_user_profile_package_path(user, pkgname);
@@ -179,14 +182,18 @@ static void unlink_current_profiles(const char* pkgname) {
        if (unlink(profile.c_str()) != 0) {
            if (errno != ENOENT) {
                PLOG(WARNING) << "Could not unlink " << profile;
                success = false;
            }
        }
    }
    return success;
}

static void unlink_all_profiles(const char* pkgname) {
    unlink_reference_profile(pkgname);
    unlink_current_profiles(pkgname);
static bool unlink_all_profiles(const char* pkgname) {
    bool success = true;
    success &= unlink_reference_profile(pkgname);
    success &= unlink_current_profiles(pkgname);
    return success;
}

int clear_app_data(const char *uuid, const char *pkgname, userid_t userid, int flags) {
@@ -1761,6 +1768,11 @@ int rm_package_dir(const char* apk_path)
    return delete_dir_contents(apk_path, 1 /* also_delete_dir */ , NULL /* exclusion_predicate */);
}

int rm_profiles(const char* pkgname)
{
    return unlink_all_profiles(pkgname) ? 0 : -1;
}

int link_file(const char* relative_path, const char* from_base, const char* to_base) {
    char from_path[PKG_PATH_MAX];
    char to_path[PKG_PATH_MAX];
+1 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int u
int idmap(const char *target_path, const char *overlay_path, uid_t uid);
int create_oat_dir(const char* oat_dir, const char *instruction_set);
int rm_package_dir(const char* apk_path);
int rm_profiles(const char* apk_path);
int link_file(const char *relative_path, const char *from_base, const char *to_base);

// Move a B version over to the A location. Only works for oat_dir != nullptr.
+7 −0
Original line number Diff line number Diff line
@@ -330,6 +330,12 @@ static int do_rm_package_dir(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
    return rm_package_dir(arg[0]);
}

static int do_rm_profiles(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
{
    /* package_name */
    return rm_profiles(arg[0]);
}

static int do_link_file(char **arg, char reply[REPLY_MAX] ATTRIBUTE_UNUSED)
{
    /* relative_path, from_base, to_base */
@@ -368,6 +374,7 @@ struct cmdinfo cmds[] = {
    { "idmap",                3, do_idmap },
    { "createoatdir",         2, do_create_oat_dir },
    { "rmpackagedir",         1, do_rm_package_dir },
    { "rmprofiles",           1, do_rm_profiles },
    { "linkfile",             3, do_link_file },
    { "move_ab",              3, do_move_ab },
};