|
|
|
@ -29,6 +29,8 @@ import com.fox2code.mmm.utils.Hashes;
|
|
|
|
|
import com.fox2code.mmm.utils.Http;
|
|
|
|
|
import com.fox2code.mmm.utils.IntentHelper;
|
|
|
|
|
import com.fox2code.mmm.utils.PropUtils;
|
|
|
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
|
|
|
|
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton;
|
|
|
|
|
import com.google.android.material.progressindicator.LinearProgressIndicator;
|
|
|
|
|
import com.topjohnwu.superuser.CallbackList;
|
|
|
|
|
import com.topjohnwu.superuser.Shell;
|
|
|
|
@ -50,6 +52,7 @@ import java.util.zip.ZipInputStream;
|
|
|
|
|
public class InstallerActivity extends CompatActivity {
|
|
|
|
|
private static final String TAG = "InstallerActivity";
|
|
|
|
|
public LinearProgressIndicator progressIndicator;
|
|
|
|
|
public ExtendedFloatingActionButton rebootFloatingButton;
|
|
|
|
|
public InstallerTerminal installerTerminal;
|
|
|
|
|
private File moduleCache;
|
|
|
|
|
private File toDelete;
|
|
|
|
@ -113,6 +116,7 @@ public class InstallerActivity extends CompatActivity {
|
|
|
|
|
View horizontalScroller = findViewById(R.id.install_horizontal_scroller);
|
|
|
|
|
RecyclerView installTerminal;
|
|
|
|
|
this.progressIndicator = findViewById(R.id.progress_bar);
|
|
|
|
|
this.rebootFloatingButton = findViewById(R.id.install_terminal_reboot_fab);
|
|
|
|
|
this.installerTerminal = new InstallerTerminal(
|
|
|
|
|
installTerminal = findViewById(R.id.install_terminal), foreground);
|
|
|
|
|
(horizontalScroller != null ? horizontalScroller : installTerminal)
|
|
|
|
@ -225,7 +229,7 @@ public class InstallerActivity extends CompatActivity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void doInstall(File file,boolean noExtensions,boolean rootless) {
|
|
|
|
|
private void doInstall(File file, boolean noExtensions, boolean rootless) {
|
|
|
|
|
if (this.canceled) return;
|
|
|
|
|
UiThreadHandler.runAndWait(() -> {
|
|
|
|
|
this.setOnBackPressedCallback(DISABLE_BACK_BUTTON);
|
|
|
|
@ -310,8 +314,9 @@ public class InstallerActivity extends CompatActivity {
|
|
|
|
|
ZipEntry moduleProp = zipFile.getEntry("module.prop");
|
|
|
|
|
magiskModule = moduleProp != null;
|
|
|
|
|
moduleId = PropUtils.readModuleId(zipFile
|
|
|
|
|
.getInputStream(moduleProp));
|
|
|
|
|
} catch (IOException ignored) {}
|
|
|
|
|
.getInputStream(zipFile.getEntry("module.prop")));
|
|
|
|
|
} catch (IOException ignored) {
|
|
|
|
|
}
|
|
|
|
|
int compatFlags = AppUpdateManager.getFlagsForModule(moduleId);
|
|
|
|
|
if ((compatFlags & AppUpdateManager.FLAG_COMPAT_NEED_32BIT) != 0)
|
|
|
|
|
needs32bit = true;
|
|
|
|
@ -396,7 +401,8 @@ public class InstallerActivity extends CompatActivity {
|
|
|
|
|
}
|
|
|
|
|
boolean success = installJob.exec().isSuccess();
|
|
|
|
|
// Wait one UI cycle before disabling controller or processing results
|
|
|
|
|
UiThreadHandler.runAndWait(() -> {}); // to avoid race conditions
|
|
|
|
|
UiThreadHandler.runAndWait(() -> {
|
|
|
|
|
}); // to avoid race conditions
|
|
|
|
|
installerController.disable();
|
|
|
|
|
String message = "- Install successful";
|
|
|
|
|
if (!success) {
|
|
|
|
@ -420,7 +426,7 @@ public class InstallerActivity extends CompatActivity {
|
|
|
|
|
private String supportLink = "";
|
|
|
|
|
|
|
|
|
|
private InstallerController(LinearProgressIndicator progressIndicator,
|
|
|
|
|
InstallerTerminal terminal,File moduleFile,
|
|
|
|
|
InstallerTerminal terminal, File moduleFile,
|
|
|
|
|
boolean noExtension) {
|
|
|
|
|
this.progressIndicator = progressIndicator;
|
|
|
|
|
this.terminal = terminal;
|
|
|
|
@ -503,7 +509,8 @@ public class InstallerActivity extends CompatActivity {
|
|
|
|
|
try {
|
|
|
|
|
this.progressIndicator.setProgressCompat(
|
|
|
|
|
Short.parseShort(arg), true);
|
|
|
|
|
} catch (Exception ignored) {}
|
|
|
|
|
} catch (Exception ignored) {
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "hideLoading":
|
|
|
|
|
this.progressIndicator.setVisibility(View.GONE);
|
|
|
|
@ -596,7 +603,7 @@ public class InstallerActivity extends CompatActivity {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("SameParameterValue")
|
|
|
|
|
private void setInstallStateFinished(boolean success, String message,String optionalLink) {
|
|
|
|
|
private void setInstallStateFinished(boolean success, String message, String optionalLink) {
|
|
|
|
|
if (success && toDelete != null && !toDelete.delete()) {
|
|
|
|
|
SuFile suFile = new SuFile(toDelete.getAbsolutePath());
|
|
|
|
|
if (suFile.exists() && !suFile.delete())
|
|
|
|
@ -608,6 +615,29 @@ public class InstallerActivity extends CompatActivity {
|
|
|
|
|
this.setOnBackPressedCallback(null);
|
|
|
|
|
this.setDisplayHomeAsUpEnabled(true);
|
|
|
|
|
this.progressIndicator.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
// This should be improved ?
|
|
|
|
|
String reboot_cmd = "/system/bin/svc power reboot || /system/bin/reboot";
|
|
|
|
|
rebootFloatingButton.setOnClickListener(_view -> {
|
|
|
|
|
if (MainApplication.shouldPreventReboot()) {
|
|
|
|
|
MaterialAlertDialogBuilder builder =
|
|
|
|
|
new MaterialAlertDialogBuilder(this);
|
|
|
|
|
|
|
|
|
|
builder
|
|
|
|
|
.setTitle(R.string.install_terminal_reboot_now)
|
|
|
|
|
.setCancelable(false)
|
|
|
|
|
.setIcon(R.drawable.ic_reboot_24)
|
|
|
|
|
.setPositiveButton(R.string.yes, (x, y) -> {
|
|
|
|
|
Shell.cmd(reboot_cmd).submit();
|
|
|
|
|
})
|
|
|
|
|
.setNegativeButton(R.string.no, (x, y) -> {
|
|
|
|
|
x.dismiss();
|
|
|
|
|
}).show();
|
|
|
|
|
} else {
|
|
|
|
|
Shell.cmd(reboot_cmd).submit();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (message != null && !message.isEmpty())
|
|
|
|
|
this.installerTerminal.addLine(message);
|
|
|
|
|
if (!optionalLink.isEmpty()) {
|
|
|
|
@ -628,6 +658,7 @@ public class InstallerActivity extends CompatActivity {
|
|
|
|
|
IntentHelper.openConfig(this, config);
|
|
|
|
|
return true;
|
|
|
|
|
});
|
|
|
|
|
this.rebootFloatingButton.setVisibility(View.VISIBLE);
|
|
|
|
|
} catch (PackageManager.NameNotFoundException e) {
|
|
|
|
|
Log.w(TAG, "Config package \"" +
|
|
|
|
|
configPkg + "\" missing for installer view");
|
|
|
|
|