Start moving things outside of top Application class

This commit is contained in:
topjohnwu
2018-07-31 03:51:11 +08:00
parent e39f83edbf
commit 914b7ee056
32 changed files with 237 additions and 214 deletions
@@ -9,6 +9,7 @@ import android.text.TextUtils;
import android.view.View;
import android.widget.Toast;
import com.topjohnwu.magisk.Global;
import com.topjohnwu.magisk.FlashActivity;
import com.topjohnwu.magisk.MagiskManager;
import com.topjohnwu.magisk.R;
@@ -59,7 +60,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
public InstallMagisk(Activity context) {
super(context);
mm = MagiskManager.get();
mm = Global.MM();
mode = FIX_ENV_MODE;
}
@@ -129,8 +130,8 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
private void extractFiles(String arch) throws IOException {
console.add("- Downloading zip");
String filename = Utils.fmt("Magisk-v%s(%d).zip",
mm.remoteMagiskVersionString, mm.remoteMagiskVersionCode);
HttpURLConnection conn = WebService.mustRequest(mm.magiskLink, null);
Global.remoteMagiskVersionString, Global.remoteMagiskVersionCode);
HttpURLConnection conn = WebService.mustRequest(Global.magiskLink, null);
BufferedInputStream buf = new BufferedInputStream(new ProgressStream(conn));
buf.mark(Integer.MAX_VALUE);
try (OutputStream out = new FileOutputStream(new File(Download.EXTERNAL_PATH, filename))) {
@@ -204,7 +205,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
// Patch boot image
if (!Shell.sh("cd " + installDir, Utils.fmt(
"KEEPFORCEENCRYPT=%b KEEPVERITY=%b sh update-binary indep boot_patch.sh %s",
mm.keepEnc, mm.keepVerity, mBoot))
Global.keepEnc, Global.keepVerity, mBoot))
.to(console, logs).exec().isSuccess())
return null;
@@ -258,7 +259,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
case DIRECT_MODE:
Shell.Job job = Shell.su(Utils.fmt("direct_install %s %s %s", patched, mBoot, installDir))
.to(console, logs);
if (!mm.keepVerity)
if (!Global.keepVerity)
job.add("find_dtbo_image", "patch_dtbo_image");
job.exec();
break;
@@ -331,7 +332,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
List<String> abis = Arrays.asList(Build.SUPPORTED_ABIS);
String arch;
if (mm.remoteMagiskVersionCode >= Const.MAGISK_VER.SEPOL_REFACTOR) {
if (Global.remoteMagiskVersionCode >= Const.MAGISK_VER.SEPOL_REFACTOR) {
// 32-bit only
if (abis.contains("x86")) arch = "x86";
else arch = "arm";
@@ -368,7 +369,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
protected void onPostExecute(Boolean result) {
if (mode == FIX_ENV_MODE) {
dialog.dismiss();
MagiskManager.toast(result ? R.string.setup_done : R.string.setup_fail, Toast.LENGTH_LONG);
Global.toast(result ? R.string.setup_done : R.string.setup_fail, Toast.LENGTH_LONG);
} else {
// Running in FlashActivity
FlashActivity activity = (FlashActivity) getActivity();