From a34ed538b6ce57ddafd9cf69a9e46492cddb4f9c Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 3 Nov 2017 02:25:42 +0800 Subject: [PATCH] Fix potential bug --- .../topjohnwu/magisk/asyncs/InstallMagisk.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java b/app/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java index a479d510c..c8dddcde5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java +++ b/app/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java @@ -117,6 +117,7 @@ public class InstallMagisk extends ParallelTask { File boot = new File(install, "boot.img"); switch (mode) { case PATCH_MODE: + mList.add("- Use boot image: " + boot); // Copy boot image to local try ( InputStream in = mm.getContentResolver().openInputStream(mBootImg); @@ -146,19 +147,15 @@ public class InstallMagisk extends ParallelTask { mList.add("! Copy failed"); throw e; } - mList.add("- Use boot image: " + boot); break; case DIRECT_MODE: - try (OutputStream out = new FileOutputStream(boot)) { - Process process = Runtime.getRuntime().exec(new String[] { "su", "-c", "cat " + mBootLocation }); - Utils.inToOut(process.getInputStream(), out); - process.waitFor(); - process.destroy(); - } catch (Exception e) { - mList.add("! Dump boot image failed"); - throw e; - } mList.add("- Use boot image: " + mBootLocation); + if (boot.createNewFile()) { + Shell.su("cat " + mBootLocation + " > " + boot); + } else { + mList.add("! Dump boot image failed"); + return false; + } break; default: return false;