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

Commit 5868ea7e authored by David Brazdil's avatar David Brazdil Committed by Android (Google) Code Review
Browse files

Merge "Add option to clear profile data to 'cmd package compile'" into nyc-dev

parents 9edd36a8 9aa6db03
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -382,6 +382,13 @@ interface IPackageManager {
     */
    void clearApplicationUserData(in String packageName, IPackageDataObserver observer, int userId);

    /**
     * Clear the profile data of an application.
     * @param packageName The package name of the application whose profile data
     * need to be deleted
     */
    void clearApplicationProfileData(in String packageName);

   /**
     * Get package statistics including the code, data and cache size for
     * an already installed package
+4 −0
Original line number Diff line number Diff line
@@ -166,6 +166,10 @@ public final class Installer extends SystemService {
        mInstaller.execute("rmpackagedir", packageDir);
    }

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

    public void createUserConfig(int userid) throws InstallerException {
        mInstaller.execute("mkuserconfig", userid);
    }
+10 −0
Original line number Diff line number Diff line
@@ -15153,6 +15153,16 @@ public class PackageManagerService extends IPackageManager.Stub {
        }
    }
    @Override
    public void clearApplicationProfileData(String packageName) {
        enforceSystemOrRoot("Only the system can clear all profile data");
        try {
            mInstaller.rmProfiles(packageName);
        } catch (InstallerException ex) {
            Log.e(TAG, "Could not clear profile data of package " + packageName);
        }
    }
    @Override
    public void clearApplicationUserData(final String packageName,
            final IPackageDataObserver observer, final int userId) {
+18 −3
Original line number Diff line number Diff line
@@ -234,6 +234,7 @@ class PackageManagerShellCommand extends ShellCommand {
        boolean extractOnly = false;
        boolean forceCompilation = false;
        boolean allPackages = false;
        boolean clearProfileData = false;
        String compilationMode = "default";

        String opt;
@@ -242,11 +243,19 @@ class PackageManagerShellCommand extends ShellCommand {
                case "-a":
                    allPackages = true;
                    break;
                case "-c":
                    clearProfileData = true;
                    break;
                case "-f":
                    forceCompilation = true;
                    break;
                case "-m":
                    compilationMode = getNextArgRequired();
                    break;
                case "-f":
                case "--reset":
                    forceCompilation = true;
                    clearProfileData = true;
                    compilationMode = "extract";
                    break;
                default:
                    pw.println("Error: Unknown option: " + opt);
@@ -290,7 +299,10 @@ class PackageManagerShellCommand extends ShellCommand {

        List<String> failedPackages = new ArrayList<>();
        for (String packageName : packageNames) {
            pw.println(packageName);
            if (clearProfileData) {
                mInterface.clearApplicationProfileData(packageName);
            }

            boolean result = mInterface.performDexOpt(packageName, null /* instructionSet */,
                        useJitProfiles, extractOnly, forceCompilation);
            if (!result) {
@@ -1170,9 +1182,12 @@ class PackageManagerShellCommand extends ShellCommand {
        pw.println("    Trigger compilation of TARGET-PACKAGE or all packages if \"-a\".");
        pw.println("    Options:");
        pw.println("      -a: compile all packages");
        pw.println("      -c: clear profile data before compiling");
        pw.println("      -f: force compilation even if not needed");
        pw.println("      -m: select compilation mode");
        pw.println("          MODE can be one of \"default\", \"all\", \"profile\", and \"extract\"");
        pw.println("      -f: force compilation even if not needed");
        pw.println("      --reset: restore the package to post-install state");
        pw.println("          shorthand for \"-c -f -m extract\"");
        pw.println("  list features");
        pw.println("    Prints all features of the system.");
        pw.println("  list instrumentation [-f] [TARGET-PACKAGE]");