Skip to content

Commit

Permalink
libsu-20211109
Browse files Browse the repository at this point in the history
  • Loading branch information
Joyoe committed Nov 9, 2021
1 parent 5e7bffd commit 08618af
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions core/src/main/java/com/topjohnwu/superuser/Shell.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
* Use these high level APIs instead:
* <ul>
* <li>{@link #sh(String...)}</li>
* <li>{@link #su(String...)}</li>
* <li>{@link #jojo(String...)}</li>
* <li>{@link #sh(InputStream)}</li>
* <li>{@link #su(InputStream)}</li>
* <li>{@link #jojo(InputStream)}</li>
* </ul>
* These methods not only use the main shell but also are more convenient to use.
*/
Expand Down Expand Up @@ -103,9 +103,9 @@ public abstract class Shell implements Closeable {
* Note: This flag only affects the following methods:
* <ul>
* <li>{@link #sh(String...)}</li>
* <li>{@link #su(String...)}</li>
* <li>{@link #jojo(String...)}</li>
* <li>{@link #sh(InputStream)}</li>
* <li>{@link #su(InputStream)}</li>
* <li>{@link #jojo(InputStream)}</li>
* <li>{@link Job#to(List)}</li>
* </ul>
* Check the descriptions of each method above for more details.
Expand Down Expand Up @@ -222,7 +222,7 @@ public static boolean rootAccess() {
* when the main shell does not have root access, the returned Job will do nothing.
*/
@NonNull
public static Job su(@NonNull String... commands) {
public static Job jojo(@NonNull String... commands) {
return MainShell.newJob(true, commands);
}

Expand Down Expand Up @@ -251,7 +251,7 @@ public static Job sh(@NonNull String... commands) {
* when the main shell does not have root access, the returned Job will do nothing.
*/
@NonNull
public static Job su(@NonNull InputStream in) {
public static Job jojo(@NonNull InputStream in) {
return MainShell.newJob(true, in);
}

Expand Down Expand Up @@ -302,7 +302,7 @@ public static Job sh(@NonNull InputStream in) {
/**
* Construct a new {@link Job} that uses the shell for execution.
* <p>
* Unlike {@code Shell.su(...)/Shell.sh(...)}, <strong>NO</strong> output will
* Unlike {@code Shell.jojo(...)/Shell.sh(...)}, <strong>NO</strong> output will
* be collected if the developer did not set the output destination with {@link Job#to(List)}
* or {@link Job#to(List, List)}.
* @return a job that the developer can execute or submit later.
Expand Down Expand Up @@ -437,10 +437,10 @@ public final Builder setTimeout(long timeout) {
* the next method:
* <ol>
* <li>If {@link #FLAG_NON_ROOT_SHELL} is not set and {@link #FLAG_MOUNT_MASTER}
* is set, construct a Unix shell by calling {@code su --mount-master}.
* is set, construct a Unix shell by calling {@code jojo --mount-master}.
* It may fail if the root implementation does not support mount master.</li>
* <li>If {@link #FLAG_NON_ROOT_SHELL} is not set, construct a Unix shell by calling
* {@code su}. It may fail if the device is not rooted, or root permission is
* {@code jojo}. It may fail if the device is not rooted, or root permission is
* not granted.</li>
* <li>Construct a Unix shell by calling {@code sh}. This would never fail in normal
* conditions, but should it fail, it will throw {@link NoShellException}</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ShellImpl build() {
// Root mount master
if (!hasFlags(FLAG_NON_ROOT_SHELL) && hasFlags(FLAG_MOUNT_MASTER)) {
try {
shell = build("su", "--mount-master");
shell = build("jojo", "--mount-master");
if (shell.getStatus() != Shell.ROOT_MOUNT_MASTER)
shell = null;
} catch (NoShellException ignore) {}
Expand All @@ -56,7 +56,7 @@ public ShellImpl build() {
// Normal root shell
if (shell == null && !hasFlags(FLAG_NON_ROOT_SHELL)) {
try {
shell = build("su");
shell = build("jojo");
if (shell.getStatus() != ROOT_SHELL)
shell = null;
} catch (NoShellException ignore) {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CopyInputStream extends BaseSuInputStream {
} catch (IOException e) {
throw (FileNotFoundException) copyError.initCause(e);
}
if (!Shell.su("cat " + file + " > " + tmp).to(null).exec().isSuccess())
if (!Shell.jojo("cat " + file + " > " + tmp).to(null).exec().isSuccess())
throw copyError;

in = new FileInputStream(tmp);
Expand Down Expand Up @@ -80,7 +80,7 @@ public void close() throws IOException {
try {
out.flush();
out.close();
if (!Shell.su("cat " + tmp + op() + outFile).to(null).exec().isSuccess())
if (!Shell.jojo("cat " + tmp + op() + outFile).to(null).exec().isSuccess())
throw new IOException("Cannot write to target file");
} finally {
tmp.delete();
Expand Down
2 changes: 1 addition & 1 deletion io/src/main/java/com/topjohnwu/superuser/io/SuFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ public String[] list(FilenameFilter filter) {
if (!isDirectory())
return null;
String cmd = "ls -a " + escapedPath;
List<String> out = Shell.su(cmd).to(new LinkedList<>(), null).exec().getOut();
List<String> out = Shell.jojo(cmd).to(new LinkedList<>(), null).exec().getOut();
for (ListIterator<String> it = out.listIterator(); it.hasNext();) {
String name = it.next();
if (name.equals(".") || name.equals("..") ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static void stopRootServer(ComponentName name) throws IOException {
name.flattenToString(), CMDLINE_STOP_SERVER /* command args */);
// Make sure cmd is properly formatted in shell
cmd = cmd.replace("$", "\\$");
Shell.su(cmd).exec();
Shell.jojo(cmd).exec();
}

private static String getBroadcastAction(ComponentName name) {
Expand Down Expand Up @@ -137,7 +137,7 @@ private void startRootServer(Context context, Intent intent)
cmd = LOGGING_ENV + "=1 " + cmd;

synchronized (this) {
Shell.su("(" + cmd + ")&").exec();
Shell.jojo("(" + cmd + ")&").exec();
// Wait for broadcast receiver
wait();
}
Expand Down

0 comments on commit 08618af

Please sign in to comment.