diff --git a/build.gradle b/build.gradle index fc52fa8b3..6ef3d6759 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ android { applicationId "com.topjohnwu.magisk" minSdkVersion 21 targetSdkVersion 27 - versionCode 71 + versionCode 72 versionName "5.4.3" ndk { moduleName 'zipadjust' diff --git a/src/main/assets/changelog.md b/src/main/assets/changelog.md index 3758aad90..fc7c326b1 100644 --- a/src/main/assets/changelog.md +++ b/src/main/assets/changelog.md @@ -1,7 +1,8 @@ -### v5.4.3 (71) +### v5.4.3 (72) - Fix dynamic resource loading, should prevent crashing when checking SafetyNet - Update SignAPK to use very little RAM, should expand old device support - Support settings migration after hiding Magisk Manager - Add reboot menu in modules section - Add changelog in app -- Add dark theme to superuser requests \ No newline at end of file +- Add dark theme to superuser requests +- Properly handle new `KEEPVERITY` and `HIGHCOMP` flags for installation \ No newline at end of file diff --git a/src/main/java/com/topjohnwu/magisk/MagiskFragment.java b/src/main/java/com/topjohnwu/magisk/MagiskFragment.java index f8aa61055..0fbb9107f 100644 --- a/src/main/java/com/topjohnwu/magisk/MagiskFragment.java +++ b/src/main/java/com/topjohnwu/magisk/MagiskFragment.java @@ -138,6 +138,9 @@ public class MagiskFragment extends Fragment expandableContainer.expandLayout = expandLayout; setupExpandable(); + keepVerityChkbox.setChecked(mm.keepVerity); + keepEncChkbox.setChecked(mm.keepEnc); + mSwipeRefreshLayout.setOnRefreshListener(this); updateUI(); diff --git a/src/main/java/com/topjohnwu/magisk/MagiskManager.java b/src/main/java/com/topjohnwu/magisk/MagiskManager.java index 08b4b328c..3dfda6d5d 100644 --- a/src/main/java/com/topjohnwu/magisk/MagiskManager.java +++ b/src/main/java/com/topjohnwu/magisk/MagiskManager.java @@ -51,6 +51,8 @@ public class MagiskManager extends Application { public String managerLink; public String bootBlock = null; public int snetVersion; + public boolean keepVerity; + public boolean keepEnc; // Data public Map moduleMap; @@ -197,6 +199,23 @@ public class MagiskManager extends Application { } catch (NumberFormatException e) { magiskHide = true; } + + ret = Shell.su( + "getvar KEEPVERITY", + "echo $KEEPVERITY"); + try { + keepVerity = Utils.isValidShellResponse(ret) && Boolean.parseBoolean(ret.get(0)); + } catch (NumberFormatException e) { + keepVerity = false; + } + ret = Shell.su( + "getvar KEEPFORCEENCRYPT", + "echo $KEEPFORCEENCRYPT"); + try { + keepEnc = Utils.isValidShellResponse(ret) && Boolean.parseBoolean(ret.get(0)); + } catch (NumberFormatException e) { + keepEnc = false; + } } public void setPermissionGrantCallback(Runnable callback) { diff --git a/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java b/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java index e9d6bfd89..78076dc01 100644 --- a/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java +++ b/src/main/java/com/topjohnwu/magisk/asyncs/InstallMagisk.java @@ -28,6 +28,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -104,8 +105,10 @@ public class InstallMagisk extends ParallelTask { console.add("! Cannot unzip zip"); throw e; } + Shell.sh("chmod 755 " + install + "/*"); File boot = new File(install, "boot.img"); + boolean highCompression = false; switch (mode) { case PATCH_MODE: console.add("- Use boot image: " + boot); @@ -141,6 +144,18 @@ public class InstallMagisk extends ParallelTask { break; case DIRECT_MODE: console.add("- Use boot image: " + mBootLocation); + if (mm.remoteMagiskVersionCode >= 1463) { + List ret = new ArrayList<>(); + Shell.getShell().run(ret, logs, + install + "/magiskboot --parse " + mBootLocation, + "echo $?" + ); + if (Utils.isValidShellResponse(ret)) { + highCompression = Integer.parseInt(ret.get(ret.size() - 1)) == 2; + if (highCompression) + console.add("! Insufficient boot partition size detected"); + } + } if (boot.createNewFile()) { Shell.su("cat " + mBootLocation + " > " + boot); } else { @@ -173,8 +188,8 @@ public class InstallMagisk extends ParallelTask { // Patch boot image shell.run(console, logs, "cd " + install, - "KEEPFORCEENCRYPT=" + mKeepEnc + " KEEPVERITY=" + mKeepVerity + " sh " + - "update-binary indep boot_patch.sh " + boot + " || echo 'Failed!'"); + "KEEPFORCEENCRYPT=" + mKeepEnc + " KEEPVERITY=" + mKeepVerity + " HIGHCOMP=" + highCompression + + " sh update-binary indep boot_patch.sh " + boot + " || echo 'Failed!'"); if (TextUtils.equals(console.get(console.size() - 1), "Failed!")) return false; diff --git a/src/main/java/com/topjohnwu/magisk/utils/Utils.java b/src/main/java/com/topjohnwu/magisk/utils/Utils.java index 84e472645..1473f99bc 100644 --- a/src/main/java/com/topjohnwu/magisk/utils/Utils.java +++ b/src/main/java/com/topjohnwu/magisk/utils/Utils.java @@ -240,7 +240,8 @@ public class Utils { } public static void patchDTBO() { - if (MagiskManager.get().magiskVersionCode >= 1446) { + MagiskManager mm = MagiskManager.get(); + if (mm.magiskVersionCode >= 1446 && !mm.keepVerity) { List ret = Shell.su("patch_dtbo_image && echo true || echo false"); if (Utils.isValidShellResponse(ret) && Boolean.parseBoolean(ret.get(ret.size() - 1))) { ShowUI.dtboPatchedNotification();