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

This commit is contained in:
Jiakai Zhang
2023-01-19 03:55:19 +00:00
committed by Android (Google) Code Review
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.
*/