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

Commit b130d470 authored by Calin Juravle's avatar Calin Juravle Committed by Andreas Gampe
Browse files

Add package use info to dexopt dump

(cherry picked from commit 41a57a65)

Bug: 64153885
Test: adb shell dumpsys package dexopt
Merged-In: I57768076de821980b1de84d5fe44ab642ceebeba
Change-Id: I57768076de821980b1de84d5fe44ab642ceebeba
parent 943d1e76
Loading
Loading
Loading
Loading
+50 −15
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import dalvik.system.DexFile;

@@ -392,24 +393,58 @@ public class PackageDexOptimizer {
    /**
     * Dumps the dexopt state of the given package {@code pkg} to the given {@code PrintWriter}.
     */
    void dumpDexoptState(IndentingPrintWriter pw, PackageParser.Package pkg) {
    void dumpDexoptState(IndentingPrintWriter pw, PackageParser.Package pkg,
            PackageDexUsage.PackageUseInfo useInfo) {
        final String[] instructionSets = getAppDexInstructionSets(pkg.applicationInfo);
        final String[] dexCodeInstructionSets = getDexCodeInstructionSets(instructionSets);

        final List<String> paths = pkg.getAllCodePathsExcludingResourceOnly();

        for (String instructionSet : dexCodeInstructionSets) {
             pw.println("Instruction Set: " + instructionSet);
             pw.increaseIndent();
        for (String path : paths) {
            pw.println("path: " + path);
            pw.increaseIndent();

            for (String isa : dexCodeInstructionSets) {
                String status = null;
                try {
                      status = DexFile.getDexFileStatus(path, instructionSet);
                    status = DexFile.getDexFileStatus(path, isa);
                } catch (IOException ioe) {
                     status = "[Exception]: " + ioe.getMessage();
                }
                  pw.println("path: " + path);
                  pw.println("status: " + status);
                pw.println(isa + ": " + status);
            }

            if (useInfo.isUsedByOtherApps(path)) {
                pw.println("used be other apps: " + useInfo.getLoadingPackages(path));
            }

            Map<String, PackageDexUsage.DexUseInfo> dexUseInfoMap = useInfo.getDexUseInfoMap();

            if (!dexUseInfoMap.isEmpty()) {
                pw.println("known secondary dex files:");
                pw.increaseIndent();
                for (Map.Entry<String, PackageDexUsage.DexUseInfo> e : dexUseInfoMap.entrySet()) {
                    String dex = e.getKey();
                    PackageDexUsage.DexUseInfo dexUseInfo = e.getValue();
                    pw.println(dex);
                    pw.increaseIndent();
                    for (String isa : dexUseInfo.getLoaderIsas()) {
                        String status = null;
                        try {
                            status = DexFile.getDexFileStatus(path, isa);
                        } catch (IOException ioe) {
                             status = "[Exception]: " + ioe.getMessage();
                        }
                        pw.println(isa + ": " + status);
                    }

                    pw.println("class loader context: " + dexUseInfo.getClassLoaderContext());
                    if (dexUseInfo.isUsedByOtherApps()) {
                        pw.println("used be other apps: " + dexUseInfo.getLoadingPackages());
                    }
                    pw.decreaseIndent();
                }
                pw.decreaseIndent();
            }
            pw.decreaseIndent();
        }
+2 −1
Original line number Diff line number Diff line
@@ -22555,7 +22555,8 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
        for (PackageParser.Package pkg : packages) {
            ipw.println("[" + pkg.packageName + "]");
            ipw.increaseIndent();
            mPackageDexOptimizer.dumpDexoptState(ipw, pkg);
            mPackageDexOptimizer.dumpDexoptState(ipw, pkg,
                    mDexManager.getPackageUseInfoOrDefault(pkg.packageName));
            ipw.decreaseIndent();
        }
    }