summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@android.com>2010-10-18 14:32:59 -0700
committerBrad Fitzpatrick <bradfitz@android.com>2010-10-18 16:36:39 -0700
commit62a1eb58bfafe8744d7a65f651e11b88fdb0938d (patch)
tree37b1a0042cb480e802a5be113c694953d9a29fbd
parent2b51fcb9ac80c7c42be8f53763773414ba9ca4fa (diff)
downloadframeworks_base-62a1eb58bfafe8744d7a65f651e11b88fdb0938d.zip
frameworks_base-62a1eb58bfafe8744d7a65f651e11b88fdb0938d.tar.gz
frameworks_base-62a1eb58bfafe8744d7a65f651e11b88fdb0938d.tar.bz2
StrictMode: fix docs to actually compile and add a utility method.
Yes, this is a last minute public API change, but I'm already getting a lot of inquiries about how to use StrictMode on a GB device but targetting Eclair or Froyo. I'd like a simple answer involving reflection, but the current API is too painful to use via reflection. I imagine this will be a common request, and it's much easier for us to write a little blog post about trying it out if there's an easy way to use it with reflection. Change-Id: I1f21aaac7e61e5e90d1e4facc0c787d8daf089b1
-rw-r--r--api/current.xml11
-rw-r--r--core/java/android/os/StrictMode.java20
2 files changed, 30 insertions, 1 deletions
diff --git a/api/current.xml b/api/current.xml
index 70f2bff..1c8e5ae 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -131667,6 +131667,17 @@
visibility="public"
>
</method>
+<method name="enableDefaults"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="getThreadPolicy"
return="android.os.StrictMode.ThreadPolicy"
abstract="false"
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index de5b7b9..e912089 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -66,7 +66,7 @@ import java.util.HashMap;
* .penaltyLog()
* .build());
* StrictMode.setVmPolicy(new {@link VmPolicy.Builder StrictMode.VmPolicy.Builder}()
- * .detectLeakedSqlLiteCursors()
+ * .detectLeakedSqlLiteObjects()
* .penaltyLog()
* .penaltyDeath()
* .build());
@@ -962,6 +962,24 @@ public final class StrictMode {
}
/**
+ * Enable the recommended StrictMode defaults, with violations just being logged.
+ *
+ * <p>This catches disk and network access on the main thread, as
+ * well as leaked SQLite cursors. This is simply a wrapper around
+ * {@link #setVmPolicy} and {@link #setThreadPolicy}.
+ */
+ public static void enableDefaults() {
+ StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
+ .detectAll()
+ .penaltyLog()
+ .build());
+ StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
+ .detectLeakedSqlLiteObjects()
+ .penaltyLog()
+ .build());
+ }
+
+ /**
* @hide
*/
public static boolean vmSqliteObjectLeaksEnabled() {