mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 23:17:39 +00:00
Fix manager hiding
Workaround bizarre optimization bugs
This commit is contained in:
parent
788db036fd
commit
1d89fe503b
@ -35,7 +35,7 @@ object PatchAPK {
|
|||||||
val ALPHANUM = ALPHA + DIGITS
|
val ALPHANUM = ALPHA + DIGITS
|
||||||
private val ALPHANUMDOTS = "$ALPHANUM............"
|
private val ALPHANUMDOTS = "$ALPHANUM............"
|
||||||
|
|
||||||
private fun genPackageName(prefix: String, length: Int): String {
|
private fun genPackageName(prefix: String, length: Int): CharSequence {
|
||||||
val builder = StringBuilder(length)
|
val builder = StringBuilder(length)
|
||||||
builder.append(prefix)
|
builder.append(prefix)
|
||||||
val len = length - prefix.length
|
val len = length - prefix.length
|
||||||
@ -51,10 +51,10 @@ object PatchAPK {
|
|||||||
builder.append(next)
|
builder.append(next)
|
||||||
prev = 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)
|
if (to.length > from.length)
|
||||||
return false
|
return false
|
||||||
val buf = ByteBuffer.wrap(xml).order(ByteOrder.LITTLE_ENDIAN).asCharBuffer()
|
val buf = ByteBuffer.wrap(xml).order(ByteOrder.LITTLE_ENDIAN).asCharBuffer()
|
||||||
@ -73,7 +73,7 @@ object PatchAPK {
|
|||||||
if (offList.isEmpty())
|
if (offList.isEmpty())
|
||||||
return false
|
return false
|
||||||
|
|
||||||
val toBuf = to.toCharArray().copyOf(from.length)
|
val toBuf = to.toString().toCharArray().copyOf(from.length)
|
||||||
for (off in offList) {
|
for (off in offList) {
|
||||||
buf.position(off)
|
buf.position(off)
|
||||||
buf.put(toBuf)
|
buf.put(toBuf)
|
||||||
@ -113,7 +113,7 @@ object PatchAPK {
|
|||||||
if (!Shell.su("force_pm_install $repack").exec().isSuccess)
|
if (!Shell.su("force_pm_install $repack").exec().isSuccess)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
Config.suManager = pkg
|
Config.suManager = pkg.toString()
|
||||||
Config.export()
|
Config.export()
|
||||||
Shell.su("pm uninstall ${BuildConfig.APPLICATION_ID}").submit()
|
Shell.su("pm uninstall ${BuildConfig.APPLICATION_ID}").submit()
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ object PatchAPK {
|
|||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@JvmOverloads
|
@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 {
|
try {
|
||||||
val jar = JarMap.open(apk)
|
val jar = JarMap.open(apk)
|
||||||
val je = jar.getJarEntry(Const.ANDROID_MANIFEST)
|
val je = jar.getJarEntry(Const.ANDROID_MANIFEST)
|
||||||
@ -144,7 +144,7 @@ object PatchAPK {
|
|||||||
return true
|
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 {
|
try {
|
||||||
if (apk.length() < 1 shl 18) {
|
if (apk.length() < 1 shl 18) {
|
||||||
// APK is smaller than 256K, must be stub
|
// APK is smaller than 256K, must be stub
|
||||||
|
Loading…
x
Reference in New Issue
Block a user