From c8f65fc9a1612f465559ce27ec76fa4bdc640b68 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 27 Jun 2018 01:08:48 +0800 Subject: [PATCH] Fix selinux error while installing Magisk on some devices --- .../java/com/topjohnwu/magisk/asyncs/InstallMagisk.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java b/src/full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java index 31c61459b..9fa62cf16 100644 --- a/src/full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java +++ b/src/full/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java @@ -168,12 +168,12 @@ public class InstallMagisk extends ParallelTask { if (isSigned) { console.add("- Signing boot image with test keys"); File signed = new File(installDir, "signed.img"); - try (InputStream in = new BufferedInputStream(new FileInputStream(patched)); + try (InputStream in = new SuFileInputStream(patched); OutputStream out = new BufferedOutputStream(new FileOutputStream(signed)) ) { SignBoot.doSignature("/boot", in, out, null, null); } - signed.renameTo(patched); + Shell.Sync.su("mv -f " + signed + " " + patched); } return patched; } @@ -194,7 +194,7 @@ public class InstallMagisk extends ParallelTask { out = new BufferedOutputStream(new FileOutputStream(dest)); break; } - try (InputStream in = new FileInputStream(patched)) { + try (InputStream in = new SuFileInputStream(patched)) { ShellUtils.pump(in, out); out.close(); } @@ -215,7 +215,7 @@ public class InstallMagisk extends ParallelTask { mm.keepVerity ? "" : "patch_dtbo_image"); break; } - patched.delete(); + Shell.Sync.su("rm -f " + patched); } @Override