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

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

Merge "Add option to compile all packages with \'cmd package compile\'" into nyc-dev

am: 9edd36a8

* commit '9edd36a8':
  Add option to compile all packages with 'cmd package compile'
parents 224e0812 9edd36a8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -120,6 +120,8 @@ interface IPackageManager {

    int checkUidSignatures(int uid1, int uid2);

    List<String> getAllPackages();

    String[] getPackagesForUid(int uid);

    String getNameForUid(int uid);
+0 −1
Original line number Diff line number Diff line
@@ -191,7 +191,6 @@ class PackageDexOptimizer {
                        throw new IllegalStateException("Invalid dexopt:" + dexoptNeeded);
                }


                Log.i(TAG, "Running dexopt (" + dexoptType + ") on: " + path + " pkg="
                        + pkg.applicationInfo.packageName + " isa=" + dexCodeInstructionSet
                        + " vmSafeMode=" + vmSafeMode + " debuggable=" + debuggable
+7 −0
Original line number Diff line number Diff line
@@ -4442,6 +4442,13 @@ public class PackageManagerService extends IPackageManager.Stub {
        return PackageManager.SIGNATURE_NO_MATCH;
    }
    @Override
    public List<String> getAllPackages() {
        synchronized (mPackages) {
            return new ArrayList<String>(mPackages.keySet());
        }
    }
    @Override
    public String[] getPackagesForUid(int uid) {
        uid = UserHandle.getAppId(uid);
+42 −10
Original line number Diff line number Diff line
@@ -233,11 +233,15 @@ class PackageManagerShellCommand extends ShellCommand {
        boolean useJitProfiles = false;
        boolean extractOnly = false;
        boolean forceCompilation = false;
        boolean allPackages = false;
        String compilationMode = "default";

        String opt;
        while ((opt = getNextOption()) != null) {
            switch (opt) {
                case "-a":
                    allPackages = true;
                    break;
                case "-m":
                    compilationMode = getNextArgRequired();
                    break;
@@ -272,19 +276,46 @@ class PackageManagerShellCommand extends ShellCommand {
                return 1;
        }

        List<String> packageNames = null;
        if (allPackages) {
            packageNames = mInterface.getAllPackages();
        } else {
            String packageName = getNextArg();
            if (packageName == null) {
                pw.println("Error: package name not specified");
                return 1;
            }
            packageNames = Collections.singletonList(packageName);
        }

        boolean success = mInterface.performDexOpt(packageName, null /* instructionSet */,
        List<String> failedPackages = new ArrayList<>();
        for (String packageName : packageNames) {
            pw.println(packageName);
            boolean result = mInterface.performDexOpt(packageName, null /* instructionSet */,
                        useJitProfiles, extractOnly, forceCompilation);
        if (success) {
            if (!result) {
                failedPackages.add(packageName);
            }
        }

        if (failedPackages.isEmpty()) {
            pw.println("Success");
            return 0;
        } else if (failedPackages.size() == 1) {
            pw.println("Failure: package " + failedPackages.get(0) + " could not be compiled");
            return 1;
        } else {
            pw.print("Failure: the following packages could not be compiled: ");
            boolean is_first = true;
            for (String packageName : failedPackages) {
                if (is_first) {
                    is_first = false;
                } else {
            pw.println("Failure: package " + packageName + " could not be compiled");
                    pw.print(", ");
                }
                pw.print(packageName);
            }
            pw.println();
            return 1;
        }
    }
@@ -1135,9 +1166,10 @@ class PackageManagerShellCommand extends ShellCommand {
        pw.println("  help");
        pw.println("    Print this help text.");
        pw.println("");
        pw.println("  compile [-m MODE] [-f] TARGET-PACKAGE");
        pw.println("    Trigger compilation of TARGET-PACKAGE.");
        pw.println("  compile [-m MODE] [-f] (-a | TARGET-PACKAGE)");
        pw.println("    Trigger compilation of TARGET-PACKAGE or all packages if \"-a\".");
        pw.println("    Options:");
        pw.println("      -a: compile all packages");
        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");