summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Brad Fitzpatrick <bradfitz@android.com> 2010-08-24 14:18:26 -0700
committer Android Git Automerger <android-git-automerger@android.com> 2010-08-24 14:18:26 -0700
commit6cf1a8bfb04aead9cee5f59df4529a79c0a92dca (patch)
tree46f745809d54d5377072d0459a0d130dd2f1530f
parentff547a59494206a1555eafa296b68961b677ba90 (diff)
parentb1bbe99aaa01f321ae94f0d5ba4505e528664cc7 (diff)
am b1bbe99a: Merge "Some StrictMode API changes." into gingerbread
Merge commit 'b1bbe99aaa01f321ae94f0d5ba4505e528664cc7' into gingerbread-plus-aosp * commit 'b1bbe99aaa01f321ae94f0d5ba4505e528664cc7': Some StrictMode API changes.
-rw-r--r--api/current.xml62
-rw-r--r--core/java/android/app/ActivityThread.java2
-rw-r--r--core/java/android/os/StrictMode.java44
3 files changed, 81 insertions, 27 deletions
diff --git a/api/current.xml b/api/current.xml
index 7e5d007e0747..fefaaeabf6d7 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -129318,7 +129318,7 @@
deprecated="not deprecated"
visibility="public"
>
-<method name="getThreadBlockingPolicy"
+<method name="allowThreadDiskReads"
return="int"
abstract="false"
native="false"
@@ -129329,7 +129329,29 @@
visibility="public"
>
</method>
-<method name="setThreadBlockingPolicy"
+<method name="allowThreadDiskWrites"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="getThreadPolicy"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
+<method name="setThreadPolicy"
return="void"
abstract="false"
native="false"
@@ -258097,7 +258119,7 @@
>
<parameter name="numBits" type="int">
</parameter>
-<parameter name="rnd" type="java.util.Random">
+<parameter name="random" type="java.util.Random">
</parameter>
</constructor>
<constructor name="BigInteger"
@@ -258111,7 +258133,7 @@
</parameter>
<parameter name="certainty" type="int">
</parameter>
-<parameter name="rnd" type="java.util.Random">
+<parameter name="unused" type="java.util.Random">
</parameter>
</constructor>
<constructor name="BigInteger"
@@ -258121,7 +258143,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="java.lang.String">
+<parameter name="value" type="java.lang.String">
</parameter>
</constructor>
<constructor name="BigInteger"
@@ -258131,7 +258153,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="java.lang.String">
+<parameter name="value" type="java.lang.String">
</parameter>
<parameter name="radix" type="int">
</parameter>
@@ -258155,7 +258177,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="byte[]">
+<parameter name="value" type="byte[]">
</parameter>
</constructor>
<method name="abs"
@@ -258179,7 +258201,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="java.math.BigInteger">
+<parameter name="value" type="java.math.BigInteger">
</parameter>
</method>
<method name="and"
@@ -258192,7 +258214,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="java.math.BigInteger">
+<parameter name="value" type="java.math.BigInteger">
</parameter>
</method>
<method name="andNot"
@@ -258205,7 +258227,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="java.math.BigInteger">
+<parameter name="value" type="java.math.BigInteger">
</parameter>
</method>
<method name="bitCount"
@@ -258253,7 +258275,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="java.math.BigInteger">
+<parameter name="value" type="java.math.BigInteger">
</parameter>
</method>
<method name="divide"
@@ -258327,7 +258349,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="java.math.BigInteger">
+<parameter name="value" type="java.math.BigInteger">
</parameter>
</method>
<method name="getLowestSetBit"
@@ -258386,7 +258408,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="java.math.BigInteger">
+<parameter name="value" type="java.math.BigInteger">
</parameter>
</method>
<method name="min"
@@ -258399,7 +258421,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="java.math.BigInteger">
+<parameter name="value" type="java.math.BigInteger">
</parameter>
</method>
<method name="mod"
@@ -258453,7 +258475,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="java.math.BigInteger">
+<parameter name="value" type="java.math.BigInteger">
</parameter>
</method>
<method name="negate"
@@ -258499,7 +258521,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="java.math.BigInteger">
+<parameter name="value" type="java.math.BigInteger">
</parameter>
</method>
<method name="pow"
@@ -258527,7 +258549,7 @@
>
<parameter name="bitLength" type="int">
</parameter>
-<parameter name="rnd" type="java.util.Random">
+<parameter name="unused" type="java.util.Random">
</parameter>
</method>
<method name="remainder"
@@ -258603,7 +258625,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="java.math.BigInteger">
+<parameter name="value" type="java.math.BigInteger">
</parameter>
</method>
<method name="testBit"
@@ -258653,7 +258675,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="long">
+<parameter name="value" type="long">
</parameter>
</method>
<method name="xor"
@@ -258666,7 +258688,7 @@
deprecated="not deprecated"
visibility="public"
>
-<parameter name="val" type="java.math.BigInteger">
+<parameter name="value" type="java.math.BigInteger">
</parameter>
</method>
<field name="ONE"
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index c96d562ba6aa..c07e3d3ed847 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -3106,7 +3106,7 @@ public final class ActivityThread {
(ApplicationInfo.FLAG_SYSTEM |
ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0 &&
!"user".equals(Build.TYPE)) {
- StrictMode.setThreadBlockingPolicy(
+ StrictMode.setThreadPolicy(
StrictMode.DISALLOW_DISK_WRITE |
StrictMode.DISALLOW_DISK_READ |
StrictMode.DISALLOW_NETWORK |
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index ac12e1083227..7f7b02b5f1bd 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -114,7 +114,7 @@ public final class StrictMode {
*
* @param policyMask a bitmask of DISALLOW_* and PENALTY_* values.
*/
- public static void setThreadBlockingPolicy(final int policyMask) {
+ public static void setThreadPolicy(final int policyMask) {
// In addition to the Java-level thread-local in Dalvik's
// BlockGuard, we also need to keep a native thread-local in
// Binder in order to propagate the value across Binder calls,
@@ -164,11 +164,43 @@ public final class StrictMode {
*
* @return the bitmask of all the DISALLOW_* and PENALTY_* bits currently enabled
*/
- public static int getThreadBlockingPolicy() {
+ public static int getThreadPolicy() {
return BlockGuard.getThreadPolicy().getPolicyMask();
}
/**
+ * Updates the current thread's policy mask to allow reading &amp;
+ * writing to disk.
+ *
+ * @return the old policy mask, to be passed to setThreadPolicy to
+ * restore the policy.
+ */
+ public static int allowThreadDiskWrites() {
+ int oldPolicy = getThreadPolicy();
+ int newPolicy = oldPolicy & ~(DISALLOW_DISK_WRITE | DISALLOW_DISK_READ);
+ if (newPolicy != oldPolicy) {
+ setThreadPolicy(newPolicy);
+ }
+ return oldPolicy;
+ }
+
+ /**
+ * Updates the current thread's policy mask to allow reading from
+ * disk.
+ *
+ * @return the old policy mask, to be passed to setThreadPolicy to
+ * restore the policy.
+ */
+ public static int allowThreadDiskReads() {
+ int oldPolicy = getThreadPolicy();
+ int newPolicy = oldPolicy & ~(DISALLOW_DISK_READ);
+ if (newPolicy != oldPolicy) {
+ setThreadPolicy(newPolicy);
+ }
+ return oldPolicy;
+ }
+
+ /**
* Parses the BlockGuard policy mask out from the Exception's
* getMessage() String value. Kinda gross, but least
* invasive. :/
@@ -413,13 +445,13 @@ public final class StrictMode {
if (violationMaskSubset != 0) {
int violationBit = parseViolationFromMessage(info.crashInfo.exceptionMessage);
violationMaskSubset |= violationBit;
- final int savedPolicy = getThreadBlockingPolicy();
+ final int savedPolicy = getThreadPolicy();
try {
// First, remove any policy before we call into the Activity Manager,
// otherwise we'll infinite recurse as we try to log policy violations
// to disk, thus violating policy, thus requiring logging, etc...
// We restore the current policy below, in the finally block.
- setThreadBlockingPolicy(0);
+ setThreadPolicy(0);
ActivityManagerNative.getDefault().handleApplicationStrictModeViolation(
RuntimeInit.getApplicationObject(),
@@ -429,7 +461,7 @@ public final class StrictMode {
Log.e(TAG, "RemoteException trying to handle StrictMode violation", e);
} finally {
// Restore the policy.
- setThreadBlockingPolicy(savedPolicy);
+ setThreadPolicy(savedPolicy);
}
}
@@ -487,7 +519,7 @@ public final class StrictMode {
new LogStackTrace().printStackTrace(new PrintWriter(sw));
String ourStack = sw.toString();
- int policyMask = getThreadBlockingPolicy();
+ int policyMask = getThreadPolicy();
boolean currentlyGathering = (policyMask & PENALTY_GATHER) != 0;
int numViolations = p.readInt();