8000 Remote toolbox prefix from commands, Fix from RootTools: fix nullpoin… · githublucas420/RootCommands@c3cc47d · GitHub
[go: up one dir, main page]

Skip to content

Commit c3cc47d

Browse files
author
Dominik Schürmann
committed
Remote toolbox prefix from commands, Fix from RootTools: fix nullpointer in remounter
1 parent 4e0a2b4 commit c3cc47d

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

libraries/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Remounter.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,18 @@ protected boolean remount(String file, String mountType) {
115115
mountPoint = findMountPointRecursive(file);
116116
}
117117

118-
Log.d(RootCommands.TAG, mountPoint.getFlags() + " AND " + mountType.toLowerCase(Locale.US));
119-
if (mountPoint.getFlags().contains(mountType.toLowerCase(Locale.US))) {
120-
Log.d(RootCommands.TAG, mountPoint.getFlags().toString());
121-
return true;
118+
if (mountPoint != null) {
119+
Log.d(RootCommands.TAG, mountPoint.getFlags() + " AND " + mountType.toLowerCase(Locale.US));
120+
if (mountPoint.getFlags().contains(mountType.toLowerCase(Locale.US))) {
121+
Log.d(RootCommands.TAG, mountPoint.getFlags().toString());
122+
return true;
123+
} else {
124+
Log.d(RootCommands.TAG, mountPoint.getFlags().toString());
125+
}
122126
} else {
123-
Log.d(RootCommands.TAG, mountPoint.getFlags().toString());
124-
return false;
127+
Log.d(RootCommands.TAG, "mountPoint is null");
125128
}
129+
return false;
126130
}
127131

128132
private Mount findMountPointRecursive(String file) {

libraries/RootCommands/src/main/java/org/sufficientlysecure/rootcommands/Toolbox.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public Toolbox(Shell shell) {
6969
* @throws BrokenBusyboxException
7070
*/
7171
public boolean isRootAccessGiven() throws BrokenBusyboxException, TimeoutException, IOException {
72-
SimpleCommand idCommand = new SimpleCommand("toolbox id");
72+
SimpleCommand idCommand = new SimpleCommand("id");
7373
shell.add(idCommand).waitForFinish();
7474

7575
if (idCommand.getOutput().contains("uid=0")) {
@@ -89,7 +89,7 @@ private class PsCommand extends Command {
8989
private Pattern psPattern;
9090

9191
public PsCommand(String processName) {
92-
super("toolbox ps");
92+
super("ps");
9393
this.processName = processName;
9494
pids = new ArrayList<String>();
9595

@@ -169,7 +169,7 @@ public boolean killAll(String processName) throws BrokenBusyboxException, Timeou
169169
// kill processes
170170
if (!psCommand.getPids().isEmpty()) {
171171
// example: kill -9 1234 1222 5343
172-
SimpleCommand killCommand = new SimpleCommand("toolbox kill -9 "
172+
SimpleCommand killCommand = new SimpleCommand("kill -9 "
173173
+ psCommand.getPidsString());
174174
shell.add(killCommand).waitForFinish();
175175

@@ -261,7 +261,7 @@ public String getPermissions() {
261261
}
262262

263263
public LsCommand(String file) {
264-
super("toolbox ls -l " + file);
264+
super("ls -l " + file);
265265

266266
// get only filename:
267267
this.fileName = (new File(file)).getName();
@@ -417,7 +417,7 @@ public boolean setFilePermissions(String file, String permissions)
417417
throws BrokenBusyboxException, TimeoutException, IOException {
418418
Log.d(RootCommands.TAG, "Set permissions of " + file + " to " + permissions);
419419

420-
SimpleCommand chmodCommand = new SimpleCommand("toolbox chmod " + permissions + " " + file);
420+
SimpleCommand chmodCommand = new SimpleCommand("chmod " + permissions + " " + file);
421421
shell.add(chmodCommand).waitForFinish();
422422

423423
if (chmodCommand.getExitCode() == 0) {
@@ -500,15 +500,15 @@ public boolean copyFile(String source, String destination, boolean remountAsRw,
500500

501501
boolean commandSuccess = false;
502502

503-
SimpleCommand ddCommand = new SimpleCommand("toolbox dd if=" + source + " of="
503+
SimpleCommand ddCommand = new SimpleCommand("dd if=" + source + " of="
504504
+ destination);
505505
shell.add(ddCommand).waitForFinish();
506506

507507
if (ddCommand.getExitCode() == 0) {
508508
commandSuccess = true;
509509
} else {
510510
// try cat if dd fails
511-
SimpleCommand catCommand = new SimpleCommand("toolbox cat " + source + " > "
511+
SimpleCommand catCommand = new SimpleCommand("cat " + source + " > "
512512
+ destination);
513513
shell.add(catCommand).waitForFinish();
514514

@@ -585,7 +585,7 @@ private class FileExistsCommand extends Command {
585585
private boolean fileExists = false;
586586

587587
public FileExistsCommand(String file) {
588-
super("toolbox ls " + file);
588+
super("ls " + file);
589589
this.file = file;
590590
}
591591

0 commit comments

Comments
 (0)
0