RootShell: Make shell command configurable
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
f0ac53e29b
commit
4b401a368f
@ -24,10 +24,16 @@ class RootShell {
|
|||||||
private static final String TAG = "RootShell";
|
private static final String TAG = "RootShell";
|
||||||
|
|
||||||
private final byte setupCommands[];
|
private final byte setupCommands[];
|
||||||
|
private final String shell;
|
||||||
|
|
||||||
RootShell(Context context) {
|
RootShell(Context context) {
|
||||||
|
this(context, "su");
|
||||||
|
}
|
||||||
|
|
||||||
|
RootShell(Context context, String shell) {
|
||||||
final String tmpdir = context.getCacheDir().getPath();
|
final String tmpdir = context.getCacheDir().getPath();
|
||||||
setupCommands = String.format(SETUP_TEMPLATE, tmpdir).getBytes(StandardCharsets.UTF_8);
|
setupCommands = String.format(SETUP_TEMPLATE, tmpdir).getBytes(StandardCharsets.UTF_8);
|
||||||
|
this.shell = shell;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +51,7 @@ class RootShell {
|
|||||||
int exitValue = -1;
|
int exitValue = -1;
|
||||||
try {
|
try {
|
||||||
final ProcessBuilder builder = new ProcessBuilder().redirectErrorStream(true);
|
final ProcessBuilder builder = new ProcessBuilder().redirectErrorStream(true);
|
||||||
final Process process = builder.command("su").start();
|
final Process process = builder.command(shell).start();
|
||||||
final OutputStream stdin = process.getOutputStream();
|
final OutputStream stdin = process.getOutputStream();
|
||||||
stdin.write(setupCommands);
|
stdin.write(setupCommands);
|
||||||
for (String command : commands)
|
for (String command : commands)
|
||||||
|
Loading…
Reference in New Issue
Block a user