summaryrefslogtreecommitdiff
path: root/core/java/android/os/Process.java
diff options
context:
space:
mode:
authorTim Murray <timmurray@google.com>2016-07-16 11:28:40 -0700
committerTim Murray <timmurray@google.com>2016-07-16 11:48:01 -0700
commit9bc12a83b6768c15807c009441d486f82135d383 (patch)
tree5c9a8e7b20a6c77c59f5ba9b6ca8aabf751e2fa9 /core/java/android/os/Process.java
parentd5b43852dcce39d260bce2562542b3dce4c8b588 (diff)
Make sure StrictMode allows disk reads when calling isThreadInProcess.
If an application thread disables disk reads on the main thread, isThreadInProcess will trigger a strict mode violation. This is bad if the RenderThread is created after disk reads have been disallowed. bug 30170339 Change-Id: I6918605d11f0c586c156f3168051376c3209b3f1
Diffstat (limited to 'core/java/android/os/Process.java')
-rw-r--r--core/java/android/os/Process.java4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/java/android/os/Process.java b/core/java/android/os/Process.java
index 84d2c98ba93d..57b40e559ccd 100644
--- a/core/java/android/os/Process.java
+++ b/core/java/android/os/Process.java
@@ -1263,6 +1263,7 @@ public class Process {
* @hide
*/
public static final boolean isThreadInProcess(int tid, int pid) {
+ StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
try {
if (Os.access("/proc/" + tid + "/task/" + pid, OsConstants.F_OK)) {
return true;
@@ -1271,6 +1272,9 @@ public class Process {
}
} catch (Exception e) {
return false;
+ } finally {
+ StrictMode.setThreadPolicy(oldPolicy);
}
+
}
}