mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-02-17 20:48:28 +00:00
Improve Magisk direct install
This commit is contained in:
parent
166469827f
commit
fd19fbf300
@ -183,18 +183,23 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
|||||||
shell.run(mList,
|
shell.run(mList,
|
||||||
"cd " + install,
|
"cd " + install,
|
||||||
"KEEPFORCEENCRYPT=" + mKeepEnc + " KEEPVERITY=" + mKeepVerity + " sh " +
|
"KEEPFORCEENCRYPT=" + mKeepEnc + " KEEPVERITY=" + mKeepVerity + " sh " +
|
||||||
"update-binary indep boot_patch.sh " + boot +
|
"update-binary indep boot_patch.sh " + boot + " || echo 'Failed!'"
|
||||||
" && echo 'Success!' || echo 'Failed!'"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!TextUtils.equals(mList.get(mList.size() - 1), "Success!"))
|
if (TextUtils.equals(mList.get(mList.size() - 1), "Failed!"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
File patched_boot = new File(install, "new-boot.img");
|
shell.run(mList,
|
||||||
|
"mv -f new-boot.img ../ 2>/dev/null",
|
||||||
|
"mv bin/busybox busybox 2>/dev/null",
|
||||||
|
"rm -rf bin *.img update-binary 2>/dev/null",
|
||||||
|
"cd /");
|
||||||
|
|
||||||
|
File patched_boot = new File(install.getParent(), "new-boot.img");
|
||||||
|
|
||||||
if (isSigned) {
|
if (isSigned) {
|
||||||
mList.add("- Signing boot image");
|
mList.add("- Signing boot image");
|
||||||
File signed = new File(install, "signed.img");
|
File signed = new File(install.getParent(), "signed.img");
|
||||||
AssetManager assets = mm.getAssets();
|
AssetManager assets = mm.getAssets();
|
||||||
try (
|
try (
|
||||||
InputStream in = new FileInputStream(patched_boot);
|
InputStream in = new FileInputStream(patched_boot);
|
||||||
@ -207,7 +212,6 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
|||||||
shell.run_raw(false, "mv -f " + signed + " " + patched_boot);
|
shell.run_raw(false, "mv -f " + signed + " " + patched_boot);
|
||||||
}
|
}
|
||||||
|
|
||||||
mList.add("");
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case PATCH_MODE:
|
case PATCH_MODE:
|
||||||
File dest = new File(Environment.getExternalStorageDirectory() + "/MagiskManager/patched_boot" + mm.bootFormat);
|
File dest = new File(Environment.getExternalStorageDirectory() + "/MagiskManager/patched_boot" + mm.bootFormat);
|
||||||
@ -226,6 +230,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
mList.add("");
|
||||||
mList.add("*********************************");
|
mList.add("*********************************");
|
||||||
mList.add(" Patched Boot Image is placed in ");
|
mList.add(" Patched Boot Image is placed in ");
|
||||||
mList.add(" " + dest + " ");
|
mList.add(" " + dest + " ");
|
||||||
@ -233,18 +238,18 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
|
|||||||
break;
|
break;
|
||||||
case DIRECT_MODE:
|
case DIRECT_MODE:
|
||||||
// Direct flash boot image
|
// Direct flash boot image
|
||||||
Shell.su(mList, "flash_boot_image " + patched_boot + " " + mBootLocation);
|
Shell.su(mList,
|
||||||
|
"rm -rf /data/magisk/*",
|
||||||
|
"mv -f " + install + "/* /data/magisk",
|
||||||
|
"rm -rf " + install,
|
||||||
|
"flash_boot_image " + patched_boot + " " + mBootLocation,
|
||||||
|
"rm -rf " + patched_boot);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finals
|
mList.add("- All done!");
|
||||||
shell.run_raw(false,
|
|
||||||
"cd " + install,
|
|
||||||
"mv bin/busybox busybox",
|
|
||||||
"rm -rf bin *.img update-binary",
|
|
||||||
"cd /");
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user