From 1d89fe503ba07f9dca15dc9c952b5b725e8ffb96 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 29 Jan 2020 20:55:20 +0800 Subject: [PATCH] Fix manager hiding Workaround bizarre optimization bugs --- .../com/topjohnwu/magisk/core/utils/PatchAPK.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/core/utils/PatchAPK.kt b/app/src/main/java/com/topjohnwu/magisk/core/utils/PatchAPK.kt index 4a56efd91..4a9ba8f47 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/utils/PatchAPK.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/utils/PatchAPK.kt @@ -35,7 +35,7 @@ object PatchAPK { val ALPHANUM = ALPHA + DIGITS private val ALPHANUMDOTS = "$ALPHANUM............" - private fun genPackageName(prefix: String, length: Int): String { + private fun genPackageName(prefix: String, length: Int): CharSequence { val builder = StringBuilder(length) builder.append(prefix) val len = length - prefix.length @@ -51,10 +51,10 @@ object PatchAPK { builder.append(next) prev = next } - return builder.toString() + return builder } - private fun findAndPatch(xml: ByteArray, from: String, to: String): Boolean { + private fun findAndPatch(xml: ByteArray, from: CharSequence, to: CharSequence): Boolean { if (to.length > from.length) return false val buf = ByteBuffer.wrap(xml).order(ByteOrder.LITTLE_ENDIAN).asCharBuffer() @@ -73,7 +73,7 @@ object PatchAPK { if (offList.isEmpty()) return false - val toBuf = to.toCharArray().copyOf(from.length) + val toBuf = to.toString().toCharArray().copyOf(from.length) for (off in offList) { buf.position(off) buf.put(toBuf) @@ -113,7 +113,7 @@ object PatchAPK { if (!Shell.su("force_pm_install $repack").exec().isSuccess) return false - Config.suManager = pkg + Config.suManager = pkg.toString() Config.export() Shell.su("pm uninstall ${BuildConfig.APPLICATION_ID}").submit() @@ -122,7 +122,7 @@ object PatchAPK { @JvmStatic @JvmOverloads - fun patch(apk: String, out: String, pkg: String, label: String = "Manager"): Boolean { + fun patch(apk: String, out: String, pkg: CharSequence, label: String = "Manager"): Boolean { try { val jar = JarMap.open(apk) val je = jar.getJarEntry(Const.ANDROID_MANIFEST) @@ -144,7 +144,7 @@ object PatchAPK { return true } - fun patch(apk: File, out: File, pkg: String, label: String): Boolean { + fun patch(apk: File, out: File, pkg: CharSequence, label: String): Boolean { try { if (apk.length() < 1 shl 18) { // APK is smaller than 256K, must be stub