Remove deprecated methods

Simplify logic
This commit is contained in:
topjohnwu 2024-06-11 18:50:21 -07:00
parent 2eae61d7ac
commit d7f288a187
3 changed files with 8 additions and 56 deletions

View File

@ -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>

View File

@ -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);
}
}

View File

@ -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);
});