From aa6e21281a740675804b03ce47915f143ca67ab5 Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Tue, 27 Mar 2018 17:56:54 +0000 Subject: Revert "Close print writers" This reverts commit 390b242367cc17276d74d3a4af2f2bce2f4f7b57. The reverted change closed the output PrintWriter too early and led to truncated dumps. Bug: 74423421 Change-Id: I62902f2aa20be460b6dec42e811b21bf953fcfe3 Test: manual (cherry picked from commit 1af397c9f7b7d90d6235b72dcfe65a1f5441a09f) --- .../android/server/pm/PackageManagerService.java | 132 ++++++++++----------- 1 file changed, 64 insertions(+), 68 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 5a63f2963ccf..9b67bbd9eb29 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -18890,7 +18890,7 @@ public class PackageManagerService extends IPackageManager.Stub return true; } - private static final class ClearStorageConnection implements ServiceConnection { + private final class ClearStorageConnection implements ServiceConnection { IMediaContainerService mContainerService; @Override @@ -21611,37 +21611,35 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); // the given package is involved with. if (dumpState.onTitlePrinted()) pw.println(); - try (final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ", 120)) { - ipw.println(); - ipw.println("Frozen packages:"); - ipw.increaseIndent(); - if (mFrozenPackages.size() == 0) { - ipw.println("(none)"); - } else { - for (int i = 0; i < mFrozenPackages.size(); i++) { - ipw.println(mFrozenPackages.valueAt(i)); - } + final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ", 120); + ipw.println(); + ipw.println("Frozen packages:"); + ipw.increaseIndent(); + if (mFrozenPackages.size() == 0) { + ipw.println("(none)"); + } else { + for (int i = 0; i < mFrozenPackages.size(); i++) { + ipw.println(mFrozenPackages.valueAt(i)); } - ipw.decreaseIndent(); } + ipw.decreaseIndent(); } if (!checkin && dumpState.isDumping(DumpState.DUMP_VOLUMES) && packageName == null) { if (dumpState.onTitlePrinted()) pw.println(); - try (final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ", 120)) { - ipw.println(); - ipw.println("Loaded volumes:"); - ipw.increaseIndent(); - if (mLoadedVolumes.size() == 0) { - ipw.println("(none)"); - } else { - for (int i = 0; i < mLoadedVolumes.size(); i++) { - ipw.println(mLoadedVolumes.valueAt(i)); - } + final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ", 120); + ipw.println(); + ipw.println("Loaded volumes:"); + ipw.increaseIndent(); + if (mLoadedVolumes.size() == 0) { + ipw.println("(none)"); + } else { + for (int i = 0; i < mLoadedVolumes.size(); i++) { + ipw.println(mLoadedVolumes.valueAt(i)); } - ipw.decreaseIndent(); } + ipw.decreaseIndent(); } if (!checkin && dumpState.isDumping(DumpState.DUMP_SERVICE_PERMISSIONS) @@ -21770,63 +21768,61 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName()); } private void dumpDexoptStateLPr(PrintWriter pw, String packageName) { - try (final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ")) { - ipw.println(); - ipw.println("Dexopt state:"); - ipw.increaseIndent(); - Collection 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; - } + final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " "); + ipw.println(); + ipw.println("Dexopt state:"); + ipw.increaseIndent(); + Collection packages = null; + if (packageName != null) { + PackageParser.Package targetPackage = mPackages.get(packageName); + if (targetPackage != null) { + packages = Collections.singletonList(targetPackage); } else { - packages = mPackages.values(); + 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, - mDexManager.getPackageUseInfoOrDefault(pkg.packageName)); - ipw.decreaseIndent(); - } + for (PackageParser.Package pkg : packages) { + ipw.println("[" + pkg.packageName + "]"); + ipw.increaseIndent(); + mPackageDexOptimizer.dumpDexoptState(ipw, pkg, + mDexManager.getPackageUseInfoOrDefault(pkg.packageName)); + ipw.decreaseIndent(); } } private void dumpCompilerStatsLPr(PrintWriter pw, String packageName) { - try (final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ")) { - ipw.println(); - ipw.println("Compiler stats:"); - ipw.increaseIndent(); - Collection 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; - } + final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " "); + ipw.println(); + ipw.println("Compiler stats:"); + ipw.increaseIndent(); + Collection packages = null; + if (packageName != null) { + PackageParser.Package targetPackage = mPackages.get(packageName); + if (targetPackage != null) { + packages = Collections.singletonList(targetPackage); } else { - packages = mPackages.values(); + ipw.println("Unable to find package: " + packageName); + return; } + } else { + packages = mPackages.values(); + } - for (PackageParser.Package pkg : packages) { - ipw.println("[" + pkg.packageName + "]"); - ipw.increaseIndent(); + for (PackageParser.Package pkg : packages) { + ipw.println("[" + pkg.packageName + "]"); + ipw.increaseIndent(); - CompilerStats.PackageStats stats = getCompilerPackageStats(pkg.packageName); - if (stats == null) { - ipw.println("(No recorded stats)"); - } else { - stats.dump(ipw); - } - ipw.decreaseIndent(); + CompilerStats.PackageStats stats = getCompilerPackageStats(pkg.packageName); + if (stats == null) { + ipw.println("(No recorded stats)"); + } else { + stats.dump(ipw); } + ipw.decreaseIndent(); } } -- cgit v1.2.3-59-g8ed1b