mirror of
https://github.com/topjohnwu/libsu.git
synced 2024-10-07 01:03:22 +00:00
Remove deprecated methods
Simplify logic
This commit is contained in:
parent
2eae61d7ac
commit
d7f288a187
@ -237,7 +237,7 @@ public abstract class Shell implements Closeable {
|
||||
*/
|
||||
@NonNull
|
||||
public static Job cmd(@NonNull String... commands) {
|
||||
return MainShell.newJob(false, commands);
|
||||
return MainShell.newJob(commands);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -256,7 +256,7 @@ public abstract class Shell implements Closeable {
|
||||
*/
|
||||
@NonNull
|
||||
public static Job cmd(@NonNull InputStream in) {
|
||||
return MainShell.newJob(false, in);
|
||||
return MainShell.newJob(in);
|
||||
}
|
||||
|
||||
/* ***************
|
||||
@ -699,42 +699,6 @@ public abstract class Shell implements Closeable {
|
||||
@Deprecated
|
||||
public static final int ROOT_MOUNT_MASTER = 2;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #cmd(String...)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
public static Job su(@NonNull String... commands) {
|
||||
return MainShell.newJob(true, commands);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #cmd(String...)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
public static Job sh(@NonNull String... commands) {
|
||||
return MainShell.newJob(false, commands);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #cmd(InputStream)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
public static Job su(@NonNull InputStream in) {
|
||||
return MainShell.newJob(true, in);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #cmd(InputStream)}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
public static Job sh(@NonNull InputStream in) {
|
||||
return MainShell.newJob(false, in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the application has access to root.
|
||||
* <p>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023 John "topjohnwu" Wu
|
||||
* Copyright 2024 John "topjohnwu" Wu
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -102,11 +102,11 @@ public final class MainShell {
|
||||
mainBuilder = (BuilderImpl) builder;
|
||||
}
|
||||
|
||||
public static Shell.Job newJob(boolean su, InputStream in) {
|
||||
return new PendingJob(su).add(in);
|
||||
public static Shell.Job newJob(InputStream in) {
|
||||
return new PendingJob().add(in);
|
||||
}
|
||||
|
||||
public static Shell.Job newJob(boolean su, String... cmds) {
|
||||
return new PendingJob(su).add(cmds);
|
||||
public static Shell.Job newJob(String... cmds) {
|
||||
return new PendingJob().add(cmds);
|
||||
}
|
||||
}
|
||||
|
@ -29,10 +29,7 @@ import java.util.concurrent.Future;
|
||||
|
||||
class PendingJob extends JobTask {
|
||||
|
||||
private final boolean isSU;
|
||||
|
||||
PendingJob(boolean su) {
|
||||
isSU = su;
|
||||
PendingJob() {
|
||||
to(NOPList.getInstance());
|
||||
}
|
||||
|
||||
@ -44,10 +41,6 @@ class PendingJob extends JobTask {
|
||||
close();
|
||||
return ResultImpl.INSTANCE;
|
||||
}
|
||||
if (isSU && !shell.isRoot()) {
|
||||
close();
|
||||
return ResultImpl.INSTANCE;
|
||||
}
|
||||
try {
|
||||
shell.execTask(this);
|
||||
} catch (IOException ignored) { /* JobTask does not throw */ }
|
||||
@ -94,11 +87,6 @@ class PendingJob extends JobTask {
|
||||
|
||||
private void submit0() {
|
||||
MainShell.get(null, s -> {
|
||||
if (isSU && !s.isRoot()) {
|
||||
close();
|
||||
ResultImpl.INSTANCE.callback(callbackExecutor, callback);
|
||||
return;
|
||||
}
|
||||
ShellImpl shell = (ShellImpl) s;
|
||||
shell.submitTask(this);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user