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/1/head
Fox2Code 3 years ago
parent 390ddb76d6
commit bd9f427f75

3
app/.gitignore vendored

@ -1,2 +1,3 @@
/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.topjohnwu.superuser.CallbackList;
import com.topjohnwu.superuser.Shell;
import com.topjohnwu.superuser.internal.UiThreadHandler;
import com.topjohnwu.superuser.io.SuFile;
import java.io.File;
@ -127,17 +128,24 @@ public class InstallerActivity extends CompatActivity {
return;
}
InstallerController installerController = new InstallerController(
this.progressIndicator, this.installerTerminal);
this.progressIndicator, this.installerTerminal, file.getAbsoluteFile());
InstallerMonitor installerMonitor = new InstallerMonitor(installScript);
boolean success = Shell.su("export MMM_EXT_SUPPORT=1",
"cd \"" + this.moduleCache.getAbsolutePath() + "\"",
"sh \"" + installScript.getAbsolutePath() + "\"" +
" /dev/null 1 \"" + file.getAbsolutePath() + "\"")
.to(installerController, installerMonitor).exec().isSuccess();
// Wait one UI cycle before disabling controller or processing results
UiThreadHandler.runAndWait(() -> {}); // to avoid race conditions
installerController.disable();
String message = "- Install successful";
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,
installerController.getSupportLink());
@ -146,12 +154,15 @@ public class InstallerActivity extends CompatActivity {
public static class InstallerController extends CallbackList<String> {
private final LinearProgressIndicator progressIndicator;
private final InstallerTerminal terminal;
private final File moduleFile;
private boolean enabled, useExt;
private String supportLink = "";
private InstallerController(LinearProgressIndicator progressIndicator, InstallerTerminal terminal) {
private InstallerController(LinearProgressIndicator progressIndicator,
InstallerTerminal terminal,File moduleFile) {
this.progressIndicator = progressIndicator;
this.terminal = terminal;
this.moduleFile = moduleFile;
this.enabled = true;
this.useExt = false;
}
@ -167,7 +178,9 @@ public class InstallerActivity extends CompatActivity {
if (this.useExt && s.startsWith("#!")) {
this.processCommand(s);
} 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() {
synchronized (lock) {
int size = this.terminal.size();

Loading…
Cancel
Save