public abstract class Policy
extends java.lang.Object
private class Policy extends eu.chainfire.libsuperuser.Policy {
@Override protected String[] getPolicies() {
return new String[] {
"allow sdcardd unlabeled dir { append create execute write relabelfrom link unlink ioctl getattr setattr read rename lock mounton quotaon swapon rmdir audit_access remove_name add_name reparent execmod search open }",
"allow sdcardd unlabeled file { append create write relabelfrom link unlink ioctl getattr setattr read rename lock mounton quotaon swapon audit_access open }",
"allow unlabeled unlabeled filesystem associate"
};
}
};
private Policy policy = new Policy();
public void someFunctionNotCalledOnMainThread() {
policy.inject();
}
| Constructor and Description |
|---|
Policy() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
canInject()
Detects availability of the supolicy tool.
|
protected java.util.List<java.lang.String> |
getInjectCommands()
Transform the policies defined by getPolicies() into a set of shell commands
|
protected java.util.List<java.lang.String> |
getInjectCommands(boolean allowBlocking)
Transform the policies defined by getPolicies() into a set of shell commands
|
protected abstract java.lang.String[] |
getPolicies()
Override this method to return a array of strings containing the policies you want to inject.
|
static boolean |
haveInjected() |
void |
inject()
Inject the policies defined by getPolicies().
|
void |
inject(Shell.Interactive shell,
boolean waitForIdle)
Inject the policies defined by getPolicies().
|
static void |
resetCanInject()
Reset cached can-inject state and force redetection on nect canInject() call
|
static void |
resetInjected()
Reset policies-have-been-injected state, if you really need to inject them again.
|
public static boolean haveInjected()
public static void resetInjected()
protected abstract java.lang.String[] getPolicies()
public static boolean canInject()
public static void resetCanInject()
protected java.util.List<java.lang.String> getInjectCommands()
protected java.util.List<java.lang.String> getInjectCommands(boolean allowBlocking)
allowBlocking - allow method to perform blocking I/O for extra checkspublic void inject()
public void inject(Shell.Interactive shell, boolean waitForIdle)
shell - Interactive shell to execute commands onwaitForIdle - wait for the command to complete before returning ?