Module install UI fixes (See description)

- Fix "Busybox for android NDK" install recognized as failed when successful
- Fix sometimes last message of a module sometimes not appearing in the console
- Replace absolute path of the module.zip file in the console by only it's name
pull/27/head
Fox2Code 4 years ago
parent 390ddb76d6
commit bd9f427f75

3
app/.gitignore vendored

@ -1,2 +1,3 @@
/build /build
/release /release
/mapping.txt

File diff suppressed because it is too large Load Diff

@ -20,6 +20,7 @@ import com.fox2code.mmm.utils.IntentHelper;
import com.google.android.material.progressindicator.LinearProgressIndicator; import com.google.android.material.progressindicator.LinearProgressIndicator;
import com.topjohnwu.superuser.CallbackList; import com.topjohnwu.superuser.CallbackList;
import com.topjohnwu.superuser.Shell; import com.topjohnwu.superuser.Shell;
import com.topjohnwu.superuser.internal.UiThreadHandler;
import com.topjohnwu.superuser.io.SuFile; import com.topjohnwu.superuser.io.SuFile;
import java.io.File; import java.io.File;
@ -127,17 +128,24 @@ public class InstallerActivity extends CompatActivity {
return; return;
} }
InstallerController installerController = new InstallerController( InstallerController installerController = new InstallerController(
this.progressIndicator, this.installerTerminal); this.progressIndicator, this.installerTerminal, file.getAbsoluteFile());
InstallerMonitor installerMonitor = new InstallerMonitor(installScript); InstallerMonitor installerMonitor = new InstallerMonitor(installScript);
boolean success = Shell.su("export MMM_EXT_SUPPORT=1", boolean success = Shell.su("export MMM_EXT_SUPPORT=1",
"cd \"" + this.moduleCache.getAbsolutePath() + "\"", "cd \"" + this.moduleCache.getAbsolutePath() + "\"",
"sh \"" + installScript.getAbsolutePath() + "\"" + "sh \"" + installScript.getAbsolutePath() + "\"" +
" /dev/null 1 \"" + file.getAbsolutePath() + "\"") " /dev/null 1 \"" + file.getAbsolutePath() + "\"")
.to(installerController, installerMonitor).exec().isSuccess(); .to(installerController, installerMonitor).exec().isSuccess();
// Wait one UI cycle before disabling controller or processing results
UiThreadHandler.runAndWait(() -> {}); // to avoid race conditions
installerController.disable(); installerController.disable();
String message = "- Install successful"; String message = "- Install successful";
if (!success) { if (!success) {
message = installerMonitor.doCleanUp(); // Workaround busybox-ndk install recognized as failed when successful
if (this.installerTerminal.getLastLine().trim().equals("Done!")) {
success = true;
} else {
message = installerMonitor.doCleanUp();
}
} }
this.setInstallStateFinished(success, message, this.setInstallStateFinished(success, message,
installerController.getSupportLink()); installerController.getSupportLink());
@ -146,12 +154,15 @@ public class InstallerActivity extends CompatActivity {
public static class InstallerController extends CallbackList<String> { public static class InstallerController extends CallbackList<String> {
private final LinearProgressIndicator progressIndicator; private final LinearProgressIndicator progressIndicator;
private final InstallerTerminal terminal; private final InstallerTerminal terminal;
private final File moduleFile;
private boolean enabled, useExt; private boolean enabled, useExt;
private String supportLink = ""; private String supportLink = "";
private InstallerController(LinearProgressIndicator progressIndicator, InstallerTerminal terminal) { private InstallerController(LinearProgressIndicator progressIndicator,
InstallerTerminal terminal,File moduleFile) {
this.progressIndicator = progressIndicator; this.progressIndicator = progressIndicator;
this.terminal = terminal; this.terminal = terminal;
this.moduleFile = moduleFile;
this.enabled = true; this.enabled = true;
this.useExt = false; this.useExt = false;
} }
@ -167,7 +178,9 @@ public class InstallerActivity extends CompatActivity {
if (this.useExt && s.startsWith("#!")) { if (this.useExt && s.startsWith("#!")) {
this.processCommand(s); this.processCommand(s);
} else { } else {
this.terminal.addLine(s); this.terminal.addLine(s.replace(
this.moduleFile.getAbsolutePath(),
this.moduleFile.getName()));
} }
} }

@ -73,6 +73,14 @@ public class InstallerTerminal extends RecyclerView.Adapter<InstallerTerminal.Te
} }
} }
public String getLastLine() {
synchronized (lock) {
int size = this.terminal.size();
return size == 0 ? "" :
this.terminal.get(size - 1);
}
}
public void removeLastLine() { public void removeLastLine() {
synchronized (lock) { synchronized (lock) {
int size = this.terminal.size(); int size = this.terminal.size();

Loading…
Cancel
Save