Call into ART Service for dexopt dumpsys when it is enabled.

Test: adb shell dumpsys package
      adb shell dumpsys package dexopt
      adb shell dumpsys package com.android.egg
      adb shell dumpsys package something.else
  with and without dalvik.vm.useartservice=true
Bug: 251903639
Change-Id: Ib3e4c27e784a5bf4147772ed2056a28f478c16e5
This commit is contained in:
Martin Stjernholm
2023-01-14 10:55:00 +00:00
parent f31c78c2ef
commit a2849296ef
2 changed files with 50 additions and 24 deletions

View File

@@ -2998,35 +2998,40 @@ public class ComputerEngine implements Computer {
}
ipw.println("Dexopt state:");
ipw.increaseIndent();
Collection<? extends PackageStateInternal> pkgSettings;
if (setting != null) {
pkgSettings = Collections.singletonList(setting);
if (DexOptHelper.useArtService()) {
DexOptHelper.dumpDexoptState(ipw, packageName);
} else {
pkgSettings = mSettings.getPackages().values();
}
for (PackageStateInternal pkgSetting : pkgSettings) {
final AndroidPackage pkg = pkgSetting.getPkg();
if (pkg == null || pkg.isApex()) {
// Skip APEX which is not dex-optimized
continue;
Collection<? extends PackageStateInternal> pkgSettings;
if (setting != null) {
pkgSettings = Collections.singletonList(setting);
} else {
pkgSettings = mSettings.getPackages().values();
}
final String pkgName = pkg.getPackageName();
ipw.println("[" + pkgName + "]");
for (PackageStateInternal pkgSetting : pkgSettings) {
final AndroidPackage pkg = pkgSetting.getPkg();
if (pkg == null || pkg.isApex()) {
// Skip APEX which is not dex-optimized
continue;
}
final String pkgName = pkg.getPackageName();
ipw.println("[" + pkgName + "]");
ipw.increaseIndent();
// TODO(b/251903639): Call into ART Service.
try {
mPackageDexOptimizer.dumpDexoptState(ipw, pkg, pkgSetting,
mDexManager.getPackageUseInfoOrDefault(pkgName));
} catch (LegacyDexoptDisabledException e) {
throw new RuntimeException(e);
}
ipw.decreaseIndent();
}
ipw.println("BgDexopt state:");
ipw.increaseIndent();
// TODO(b/251903639): Call into ART Service.
try {
mPackageDexOptimizer.dumpDexoptState(ipw, pkg, pkgSetting,
mDexManager.getPackageUseInfoOrDefault(pkgName));
} catch (LegacyDexoptDisabledException e) {
throw new RuntimeException(e);
}
mBackgroundDexOptService.dump(ipw);
ipw.decreaseIndent();
}
ipw.println("BgDexopt state:");
ipw.increaseIndent();
mBackgroundDexOptService.dump(ipw);
ipw.decreaseIndent();
break;
}

View File

@@ -57,6 +57,7 @@ import android.util.Log;
import android.util.Slog;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.LocalManagerRegistry;
import com.android.server.art.ArtManagerLocal;
import com.android.server.art.DexUseManagerLocal;
@@ -843,6 +844,26 @@ public final class DexOptHelper {
mPm.mPackageDexOptimizer.controlDexOptBlocking(block);
}
/**
* Dumps the dexopt state for the given package, or all packages if it is null.
*/
public static void dumpDexoptState(
@NonNull IndentingPrintWriter ipw, @Nullable String packageName) {
try (PackageManagerLocal.FilteredSnapshot snapshot =
getPackageManagerLocal().withFilteredSnapshot()) {
if (packageName != null) {
try {
DexOptHelper.getArtManagerLocal().dumpPackage(ipw, snapshot, packageName);
} catch (IllegalArgumentException e) {
// Package isn't found, but that should only happen due to race.
ipw.println(e);
}
} else {
DexOptHelper.getArtManagerLocal().dump(ipw, snapshot);
}
}
}
/**
* Returns the module names of the APEXes that contribute to bootclasspath.
*/