# HG changeset patch # User Mario Torre # Date 1302641738 -7200 # Node ID 9198ee3eefbe48d652c5f17761520b7eddac9617 # Parent 0355dd717a24ad1af4c699473cda8c0565b1b84a Fix public method signatures and add inner class exception. diff -r 0355dd717a24 -r 9198ee3eefbe src/main/java/dalvik/system/BlockGuard.java --- 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; + } + } }