summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jesse Wilson <jessewilson@google.com> 2011-01-23 11:41:15 -0800
committer Jesse Wilson <jessewilson@google.com> 2011-01-23 11:43:45 -0800
commitdb35269ae4e6a6572156e39557a993d5b730c167 (patch)
treed8a1e23cb845fbc708351932e30a9d2956017af3
parent3a27acef4e72d80bbbe0618b50785a2945ef4910 (diff)
Don't call broken+deprecated SamplingProfiler.writeHprofData
http://b/3381260 Change-Id: I5cf5ef8fbac2ada3669a0f7eff42f834db6573d7
-rw-r--r--core/java/com/android/internal/os/SamplingProfilerIntegration.java30
1 files changed, 13 insertions, 17 deletions
diff --git a/core/java/com/android/internal/os/SamplingProfilerIntegration.java b/core/java/com/android/internal/os/SamplingProfilerIntegration.java
index bfef27571df8..8c256e0c44d6 100644
--- a/core/java/com/android/internal/os/SamplingProfilerIntegration.java
+++ b/core/java/com/android/internal/os/SamplingProfilerIntegration.java
@@ -16,22 +16,21 @@
package com.android.internal.os;
+import android.content.pm.PackageInfo;
+import android.os.Build;
+import android.os.SystemProperties;
+import android.util.Log;
import dalvik.system.SamplingProfiler;
-
import java.io.BufferedOutputStream;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
-import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.ThreadFactory;
-
-import android.content.pm.PackageInfo;
-import android.util.Log;
-import android.os.*;
+import java.util.concurrent.atomic.AtomicBoolean;
+import libcore.io.IoUtils;
/**
* Integrates the framework with Dalvik's sampling profiler.
@@ -162,19 +161,16 @@ public class SamplingProfilerIntegration {
PrintStream out = null;
try {
out = new PrintStream(new BufferedOutputStream(new FileOutputStream(path)));
+ generateSnapshotHeader(name, packageInfo, out);
+ new SamplingProfiler.AsciiHprofWriter(INSTANCE.getHprofData(), out).write();
+ if (out.checkError()) {
+ throw new IOException();
+ }
} catch (IOException e) {
- Log.e(TAG, "Could not open " + path + ":" + e);
+ Log.e(TAG, "Error writing snapshot to " + path, e);
return;
- }
- try {
- generateSnapshotHeader(name, packageInfo, out);
- INSTANCE.writeHprofData(out);
} finally {
- out.close();
- }
- if (out.checkError()) {
- Log.e(TAG, "Error writing snapshot.");
- return;
+ IoUtils.closeQuietly(out);
}
// set file readable to the world so that SamplingProfilerService
// can put it to dropbox