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

Commit e1cf49e0 authored by Calin Juravle's avatar Calin Juravle Committed by Android (Google) Code Review
Browse files

Merge "Delete app profiles only during updates and uninstalls" into nyc-dev

parents ebf39762 d6d27e3a
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -169,8 +169,12 @@ public final class Installer extends SystemService {
        mInstaller.execute("rmpackagedir", packageDir);
    }

    public void rmProfiles(String pkgName) throws InstallerException {
        mInstaller.execute("rmprofiles", pkgName);
    public void clearAppProfiles(String pkgName) throws InstallerException {
        mInstaller.execute("clear_app_profiles", pkgName);
    }

    public void destroyAppProfiles(String pkgName) throws InstallerException {
        mInstaller.execute("destroy_app_profiles", pkgName);
    }

    public void createUserConfig(int userid) throws InstallerException {
+28 −1
Original line number Diff line number Diff line
@@ -7203,6 +7203,30 @@ public class PackageManagerService extends IPackageManager.Stub {
        }
    }
    private void deleteProfilesLI(String packageName, boolean destroy) {
        final PackageParser.Package pkg;
        synchronized (mPackages) {
            pkg = mPackages.get(packageName);
        }
        if (pkg == null) {
            Slog.w(TAG, "Failed to delete profiles. No package: " + packageName);
            return;
        }
        deleteProfilesLI(pkg, destroy);
    }
    private void deleteProfilesLI(PackageParser.Package pkg, boolean destroy) {
        try {
            if (destroy) {
                mInstaller.clearAppProfiles(pkg.packageName);
            } else {
                mInstaller.destroyAppProfiles(pkg.packageName);
            }
        } catch (InstallerException ex) {
            Log.e(TAG, "Could not delete profiles for package " + pkg.packageName);
        }
    }
    private void deleteCodeCacheDirsLI(String volumeUuid, String packageName) {
        final PackageParser.Package pkg;
        synchronized (mPackages) {
@@ -13235,6 +13259,7 @@ public class PackageManagerService extends IPackageManager.Stub {
            }
            deleteCodeCacheDirsLI(pkg);
            deleteProfilesLI(pkg, /*destroy*/ false);
            try {
                final PackageParser.Package newPackage = scanPackageTracedLI(pkg, parseFlags,
@@ -13369,6 +13394,7 @@ public class PackageManagerService extends IPackageManager.Stub {
        // Successfully disabled the old package. Now proceed with re-installation
        deleteCodeCacheDirsLI(pkg);
        deleteProfilesLI(pkg, /*destroy*/ false);
        res.setReturnCode(PackageManager.INSTALL_SUCCEEDED);
        pkg.setApplicationInfoFlags(ApplicationInfo.FLAG_UPDATED_SYSTEM_APP,
@@ -14441,6 +14467,7 @@ public class PackageManagerService extends IPackageManager.Stub {
            if (DEBUG_REMOVE) Slog.d(TAG, "deletePackageX: pkg=" + packageName + " user=" + userId);
            res = deletePackageLI(packageName, removeForUser, true, allUsers,
                    flags | REMOVE_CHATTY, info, true, null);
            deleteProfilesLI(packageName, /*destroy*/ true);
            synchronized (mPackages) {
                if (res) {
                    mEphemeralApplicationRegistry.onPackageUninstalledLPw(uninstalledPs.pkg);
@@ -15208,7 +15235,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    public void clearApplicationProfileData(String packageName) {
        enforceSystemOrRoot("Only the system can clear all profile data");
        try {
            mInstaller.rmProfiles(packageName);
            mInstaller.clearAppProfiles(packageName);
        } catch (InstallerException ex) {
            Log.e(TAG, "Could not clear profile data of package " + packageName);
        }