summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2012-03-02 18:07:35 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-03-02 18:07:35 -0800
commiteb00769e8983a02397db26a5413147a975b47c1f (patch)
tree92f5dd6a4c9929e8d2fb0f67c0479f8b4cbc7f84
parent1359adbc1d2c2f1a1ff84cb82b40b6d1556df23a (diff)
parente861b423790e5bf2d5a55b096065c6ad0541d5bb (diff)
downloadframeworks_base-eb00769e8983a02397db26a5413147a975b47c1f.zip
frameworks_base-eb00769e8983a02397db26a5413147a975b47c1f.tar.gz
frameworks_base-eb00769e8983a02397db26a5413147a975b47c1f.tar.bz2
Merge "Allow disk I/O while performing dump()."
-rw-r--r--api/current.txt2
-rw-r--r--core/java/android/app/ActivityThread.java56
-rw-r--r--core/java/android/os/ParcelFileDescriptor.java3
3 files changed, 35 insertions, 26 deletions
diff --git a/api/current.txt b/api/current.txt
index b11f30d..3fa7ad9 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -15092,7 +15092,7 @@ package android.os {
field public static final android.os.Parcelable.Creator STRING_CREATOR;
}
- public class ParcelFileDescriptor implements android.os.Parcelable {
+ public class ParcelFileDescriptor implements java.io.Closeable android.os.Parcelable {
ctor public ParcelFileDescriptor(android.os.ParcelFileDescriptor);
method public static android.os.ParcelFileDescriptor adoptFd(int);
method public void close() throws java.io.IOException;
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index f10bf03..aa15f39 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -102,6 +102,8 @@ import java.util.Map;
import java.util.TimeZone;
import java.util.regex.Pattern;
+import libcore.io.IoUtils;
+
import dalvik.system.CloseGuard;
final class SuperNotCalledException extends AndroidRuntimeException {
@@ -2357,41 +2359,47 @@ public final class ActivityThread {
}
private void handleDumpService(DumpComponentInfo info) {
- Service s = mServices.get(info.token);
- if (s != null) {
- PrintWriter pw = new PrintWriter(new FileOutputStream(info.fd.getFileDescriptor()));
- s.dump(info.fd.getFileDescriptor(), pw, info.args);
- pw.flush();
- try {
- info.fd.close();
- } catch (IOException e) {
+ final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
+ try {
+ Service s = mServices.get(info.token);
+ if (s != null) {
+ PrintWriter pw = new PrintWriter(new FileOutputStream(info.fd.getFileDescriptor()));
+ s.dump(info.fd.getFileDescriptor(), pw, info.args);
+ pw.flush();
}
+ } finally {
+ IoUtils.closeQuietly(info.fd);
+ StrictMode.setThreadPolicy(oldPolicy);
}
}
private void handleDumpActivity(DumpComponentInfo info) {
- ActivityClientRecord r = mActivities.get(info.token);
- if (r != null && r.activity != null) {
- PrintWriter pw = new PrintWriter(new FileOutputStream(info.fd.getFileDescriptor()));
- r.activity.dump(info.prefix, info.fd.getFileDescriptor(), pw, info.args);
- pw.flush();
- try {
- info.fd.close();
- } catch (IOException e) {
+ final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
+ try {
+ ActivityClientRecord r = mActivities.get(info.token);
+ if (r != null && r.activity != null) {
+ PrintWriter pw = new PrintWriter(new FileOutputStream(info.fd.getFileDescriptor()));
+ r.activity.dump(info.prefix, info.fd.getFileDescriptor(), pw, info.args);
+ pw.flush();
}
+ } finally {
+ IoUtils.closeQuietly(info.fd);
+ StrictMode.setThreadPolicy(oldPolicy);
}
}
private void handleDumpProvider(DumpComponentInfo info) {
- ProviderClientRecord r = mLocalProviders.get(info.token);
- if (r != null && r.mLocalProvider != null) {
- PrintWriter pw = new PrintWriter(new FileOutputStream(info.fd.getFileDescriptor()));
- r.mLocalProvider.dump(info.fd.getFileDescriptor(), pw, info.args);
- pw.flush();
- try {
- info.fd.close();
- } catch (IOException e) {
+ final StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites();
+ try {
+ ProviderClientRecord r = mLocalProviders.get(info.token);
+ if (r != null && r.mLocalProvider != null) {
+ PrintWriter pw = new PrintWriter(new FileOutputStream(info.fd.getFileDescriptor()));
+ r.mLocalProvider.dump(info.fd.getFileDescriptor(), pw, info.args);
+ pw.flush();
}
+ } finally {
+ IoUtils.closeQuietly(info.fd);
+ StrictMode.setThreadPolicy(oldPolicy);
}
}
diff --git a/core/java/android/os/ParcelFileDescriptor.java b/core/java/android/os/ParcelFileDescriptor.java
index ac15d9c..3e90dfc 100644
--- a/core/java/android/os/ParcelFileDescriptor.java
+++ b/core/java/android/os/ParcelFileDescriptor.java
@@ -15,6 +15,7 @@
*/
package android.os;
+import java.io.Closeable;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
@@ -28,7 +29,7 @@ import java.net.Socket;
* The FileDescriptor returned by {@link Parcel#readFileDescriptor}, allowing
* you to close it when done with it.
*/
-public class ParcelFileDescriptor implements Parcelable {
+public class ParcelFileDescriptor implements Parcelable, Closeable {
private final FileDescriptor mFileDescriptor;
private boolean mClosed;
//this field is to create wrapper for ParcelFileDescriptor using another