changeset 126:9198ee3eefbe

Fix public method signatures and add inner class exception.
author Mario Torre <neugens.limasoftware@gmail.com>
date Tue, 12 Apr 2011 22:55:38 +0200
parents 0355dd717a24
children 48dd23cd3827
files src/main/java/dalvik/system/BlockGuard.java
diffstat 1 files changed, 29 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/dalvik/system/BlockGuard.java	Mon Apr 11 11:05:15 2011 +0200
+++ b/src/main/java/dalvik/system/BlockGuard.java	Tue Apr 12 22:55:38 2011 +0200
@@ -79,7 +79,7 @@
      * Gets the block guard policy for the current thread.
      * @return The block guard policy.
      */
-    public static Policy getPolicy() {
+    public static Policy getThreadPolicy() {
         return threadPolicy.get();
     }
 
@@ -87,7 +87,7 @@
      * Sets the block guard policy for the current thread.
      * @param policy The block guard policy.
      */
-    public static void setPolicy(Policy policy) {
+    public static void setThreadPolicy(Policy policy) {
         threadPolicy.set(policy);
     }
 
@@ -104,4 +104,31 @@
     private BlockGuard() {
         // No instances of this class.
     }
+
+    /**
+     * The exception used to indicate violations of block guard policies.
+     */
+    public static class BlockGuardPolicyException extends RuntimeException {
+
+        private int policyState;
+        private int policyViolated;
+
+        public BlockGuardPolicyException(int policyState, int policyViolated) {
+            this.policyState = policyState;
+            this.policyViolated = policyViolated;
+        }
+
+        @Override
+        public String getMessage() {
+            return super.getMessage();
+        }
+
+        public int getPolicy() {
+            return policyState;
+        }
+
+        public int getPolicyViolation() {
+            return policyViolated;
+        }
+    }
 }