import android.util.Slog;
import com.android.internal.os.InstallerConnection.InstallerException;
+import com.android.internal.util.IndentingPrintWriter;
import java.io.File;
import java.io.IOException;
return dexoptFlags;
}
+ /**
+ * Dumps the dexopt state of the given package {@code pkg} to the given {@code PrintWriter}.
+ */
+ void dumpDexoptState(IndentingPrintWriter pw, PackageParser.Package pkg) {
+ 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) {
+ String status = null;
+ try {
+ status = DexFile.getDexFileStatus(path, instructionSet);
+ } catch (IOException ioe) {
+ status = "[Exception]: " + ioe.getMessage();
+ }
+ pw.println("path: " + path);
+ pw.println("status: " + status);
+ }
+ pw.decreaseIndent();
+ }
+ }
+
private int performDexOptLI(PackageParser.Package pkg, String[] sharedLibraries,
String[] targetInstructionSets, boolean checkProfiles, String targetCompilerFilter) {
final String[] instructionSets = targetInstructionSets != null ?
public static final int DUMP_INTENT_FILTER_VERIFIERS = 1 << 17;
public static final int DUMP_DOMAIN_PREFERRED = 1 << 18;
public static final int DUMP_FROZEN = 1 << 19;
+ public static final int DUMP_DEXOPT = 1 << 20;
public static final int OPTION_SHOW_FILTERS = 1 << 0;
pw.println(" write: write current settings now");
pw.println(" installs: details about install sessions");
pw.println(" check-permission <permission> <package> [<user>]: does pkg hold perm?");
+ pw.println(" dexopt: dump dexopt state");
pw.println(" <package.name>: info about given package");
return;
} else if ("--checkin".equals(opt)) {
dumpState.setDump(DumpState.DUMP_INSTALLS);
} else if ("frozen".equals(cmd)) {
dumpState.setDump(DumpState.DUMP_FROZEN);
+ } else if ("dexopt".equals(cmd)) {
+ dumpState.setDump(DumpState.DUMP_DEXOPT);
} else if ("write".equals(cmd)) {
synchronized (mPackages) {
mSettings.writeLPr();
ipw.decreaseIndent();
}
+ if (!checkin && dumpState.isDumping(DumpState.DUMP_DEXOPT)) {
+ if (dumpState.onTitlePrinted()) pw.println();
+ dumpDexoptStateLPr(pw, packageName);
+ }
+
if (!checkin && dumpState.isDumping(DumpState.DUMP_MESSAGES) && packageName == null) {
if (dumpState.onTitlePrinted()) pw.println();
mSettings.dumpReadMessagesLPr(pw, dumpState);
}
}
+ private void dumpDexoptStateLPr(PrintWriter pw, String packageName) {
+ final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ", 120);
+ ipw.println();
+ ipw.println("Dexopt state:");
+ ipw.increaseIndent();
+ Collection<PackageParser.Package> packages = null;
+ if (packageName != null) {
+ PackageParser.Package targetPackage = mPackages.get(packageName);
+ if (targetPackage != null) {
+ packages = Collections.singletonList(targetPackage);
+ } else {
+ ipw.println("Unable to find package: " + packageName);
+ return;
+ }
+ } else {
+ packages = mPackages.values();
+ }
+
+ for (PackageParser.Package pkg : packages) {
+ ipw.println("[" + pkg.packageName + "]");
+ ipw.increaseIndent();
+ mPackageDexOptimizer.dumpDexoptState(ipw, pkg);
+ ipw.decreaseIndent();
+ }
+ }
+
private String dumpDomainString(String packageName) {
List<IntentFilterVerificationInfo> iviList = getIntentFilterVerifications(packageName)
.getList();