public final class BlockGuard extends Object
This is meant for applications to prevent certain blocking operations from running on their main event loop (or "UI") threads.
Note that this is all best-effort to catch most accidental mistakes and isn't intended to be a perfect mechanism, nor provide any sort of security.
| Modifier and Type | Class and Description |
|---|---|
static class |
BlockGuard.BlockGuardPolicyException |
static interface |
BlockGuard.Policy |
| Modifier and Type | Field and Description |
|---|---|
static int |
DISALLOW_DISK_READ |
static int |
DISALLOW_DISK_WRITE |
static int |
DISALLOW_NETWORK |
static BlockGuard.Policy |
LAX_POLICY
The default, permissive policy that doesn't prevent any operations.
|
static int |
PASS_RESTRICTIONS_VIA_RPC |
static int |
PENALTY_DEATH |
static int |
PENALTY_DIALOG |
static int |
PENALTY_LOG |
| Modifier and Type | Method and Description |
|---|---|
static BlockGuard.Policy |
getThreadPolicy()
Get the current thread's policy.
|
static void |
setThreadPolicy(BlockGuard.Policy policy)
Sets the current thread's block guard policy.
|
public static final int DISALLOW_DISK_WRITE
public static final int DISALLOW_DISK_READ
public static final int DISALLOW_NETWORK
public static final int PASS_RESTRICTIONS_VIA_RPC
public static final int PENALTY_LOG
public static final int PENALTY_DIALOG
public static final int PENALTY_DEATH
public static final BlockGuard.Policy LAX_POLICY
public static BlockGuard.Policy getThreadPolicy()
public static void setThreadPolicy(BlockGuard.Policy policy)
policy - policy to set. May not be null. Use the public LAX_POLICY
if you want to unset the active policy.