fix: bugfixes in microg
This commit is contained in:
parent
7bc60943cb
commit
a43b33bdbb
|
@ -20,3 +20,11 @@ internal fun String.startsWithAny(vararg prefix: String): Boolean {
|
|||
|
||||
return false
|
||||
}
|
||||
|
||||
internal fun String.containsAny(vararg others: String): Boolean {
|
||||
for (other in others)
|
||||
if (this.contains(other))
|
||||
return true
|
||||
|
||||
return false
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package app.revanced.patches.youtube.misc.microg.patch.bytecode
|
||||
|
||||
import app.revanced.extensions.containsAny
|
||||
import app.revanced.extensions.startsWithAny
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
|
@ -54,19 +55,20 @@ class MicroGBytecodePatch : BytecodePatch(
|
|||
val implementation = method.implementation ?: return@methodLoop
|
||||
|
||||
var proxiedImplementation: MutableMethodImplementation? = null
|
||||
|
||||
implementation.instructions.forEachIndexed { i, instruction ->
|
||||
if (instruction.opcode == Opcode.CONST_STRING) {
|
||||
if (instruction.opcode != Opcode.CONST_STRING) return@forEachIndexed
|
||||
|
||||
val stringValue = ((instruction as Instruction21c).reference as StringReference).string
|
||||
|
||||
val replaceMode = if (stringValue == "com.google" || stringValue.startsWithAny(
|
||||
"com.google.android.gms.auth.accounts",
|
||||
val replaceMode =
|
||||
if (stringValue == "com.google" || stringValue == "com.google.android.gms" ||
|
||||
stringValue.startsWithAny(
|
||||
"com.google.iid",
|
||||
"com.google.android.gms.chimera",
|
||||
"com.google.android.c2dm",
|
||||
"com.google.android.c2dm",
|
||||
) || stringValue.containsAny(
|
||||
"com.google.android.gms.auth.accounts",
|
||||
"com.google.android.gsf",
|
||||
"com.google.android.c2dm",
|
||||
"com.google.iid",
|
||||
"content://com.google.settings"
|
||||
)
|
||||
) {
|
||||
|
@ -83,7 +85,6 @@ class MicroGBytecodePatch : BytecodePatch(
|
|||
StringReplaceMode.DO_NOT_REPLACE
|
||||
}
|
||||
|
||||
|
||||
if (replaceMode != StringReplaceMode.DO_NOT_REPLACE) {
|
||||
if (proxiedClass == null) {
|
||||
proxiedClass = data.proxy(classDef).resolve()
|
||||
|
@ -95,8 +96,7 @@ class MicroGBytecodePatch : BytecodePatch(
|
|||
}.implementation!!
|
||||
}
|
||||
|
||||
val newString =
|
||||
if (replaceMode == StringReplaceMode.REPLACE_WITH_REVANCED) stringValue.replace(
|
||||
val newString = if (replaceMode == StringReplaceMode.REPLACE_WITH_REVANCED) stringValue.replace(
|
||||
"com.google.android.youtube", REVANCED_PACKAGE_NAME
|
||||
)
|
||||
else stringValue.replace("com.google", BASE_MICROG_PACKAGE_NAME)
|
||||
|
@ -110,7 +110,6 @@ class MicroGBytecodePatch : BytecodePatch(
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// replace string back
|
||||
|
@ -126,9 +125,6 @@ class MicroGBytecodePatch : BytecodePatch(
|
|||
"const-string v0, \"com.google.android.gms\"".toInstruction()
|
||||
)
|
||||
|
||||
// allow GC to clean unused/ replaced immutable class definitions after this call
|
||||
data.classes.applyProxies()
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue