Commit a34ed538 authored by topjohnwu's avatar topjohnwu

Fix potential bug

parent 5f22d3e0
...@@ -117,6 +117,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> { ...@@ -117,6 +117,7 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
File boot = new File(install, "boot.img"); File boot = new File(install, "boot.img");
switch (mode) { switch (mode) {
case PATCH_MODE: case PATCH_MODE:
mList.add("- Use boot image: " + boot);
// Copy boot image to local // Copy boot image to local
try ( try (
InputStream in = mm.getContentResolver().openInputStream(mBootImg); InputStream in = mm.getContentResolver().openInputStream(mBootImg);
...@@ -146,19 +147,15 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> { ...@@ -146,19 +147,15 @@ public class InstallMagisk extends ParallelTask<Void, Void, Boolean> {
mList.add("! Copy failed"); mList.add("! Copy failed");
throw e; throw e;
} }
mList.add("- Use boot image: " + boot);
break; break;
case DIRECT_MODE: case DIRECT_MODE:
try (OutputStream out = new FileOutputStream(boot)) { mList.add("- Use boot image: " + mBootLocation);
Process process = Runtime.getRuntime().exec(new String[] { "su", "-c", "cat " + mBootLocation }); if (boot.createNewFile()) {
Utils.inToOut(process.getInputStream(), out); Shell.su("cat " + mBootLocation + " > " + boot);
process.waitFor(); } else {
process.destroy();
} catch (Exception e) {
mList.add("! Dump boot image failed"); mList.add("! Dump boot image failed");
throw e; return false;
} }
mList.add("- Use boot image: " + mBootLocation);
break; break;
default: default:
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment