Fix boot patching

This commit is contained in:
topjohnwu 2017-11-21 00:34:25 +08:00
parent a8f124704d
commit c8dad43e00

View File

@ -204,21 +204,22 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
switch (mode) { switch (mode) {
case PATCH_MODE: case PATCH_MODE:
File dest = new File(Const.EXTERNAL_PATH, patched_boot + mm.bootFormat); File dest = new File(Const.EXTERNAL_PATH, "patched_boot" + mm.bootFormat);
dest.getParentFile().mkdirs(); dest.getParentFile().mkdirs();
OutputStream out;
switch (mm.bootFormat) { switch (mm.bootFormat) {
case ".img":
shell.run_raw(false, false, "cp -f " + patched_boot + " " + dest);
break;
case ".img.tar": case ".img.tar":
try ( out = new TarOutputStream(new BufferedOutputStream(new FileOutputStream(dest)));
TarOutputStream tar = new TarOutputStream(new BufferedOutputStream(new FileOutputStream(dest))); ((TarOutputStream) out).putNextEntry(new TarEntry(patched_boot, "boot.img"));
InputStream in = new FileInputStream(patched_boot)
) {
tar.putNextEntry(new TarEntry(patched_boot, "boot.img"));
Utils.inToOut(in, tar);
}
break; break;
default:
case ".img":
out = new BufferedOutputStream(new FileOutputStream(dest));
break;
}
try (InputStream in = new BufferedInputStream(new FileInputStream(patched_boot))) {
Utils.inToOut(in, out);
out.close();
} }
console.add(""); console.add("");
console.add("*********************************"); console.add("*********************************");
@ -234,13 +235,14 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
"mv -f " + install + "/* /data/magisk", "mv -f " + install + "/* /data/magisk",
"rm -rf " + install, "rm -rf " + install,
"flash_boot_image " + patched_boot + " " + mBootLocation, "flash_boot_image " + patched_boot + " " + mBootLocation,
"rm -rf " + patched_boot,
"patch_dtbo_image"); "patch_dtbo_image");
break; break;
default: default:
return false; return false;
} }
patched_boot.delete();
console.add("- All done!"); console.add("- All done!");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();