fix: force-vp9-codec patch applied to wrong method

This commit is contained in:
inotia00 2023-01-30 10:47:55 +09:00
parent 96a55c5049
commit 5cee503357

View File

@ -28,28 +28,29 @@ import org.jf.dexlib2.iface.instruction.ReferenceInstruction
class ForceVP9CodecBytecodePatch : BytecodePatch( class ForceVP9CodecBytecodePatch : BytecodePatch(
listOf( listOf(
LayoutSwitchFingerprint, LayoutSwitchFingerprint,
Vp9PrimaryFingerprint, Vp9PropsParentFingerprint
Vp9PropsFingerprint,
Vp9PropsParentFingerprint,
Vp9SecondaryFingerprint
) )
) { ) {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
LayoutSwitchFingerprint.result?.let { parentResult -> LayoutSwitchFingerprint.result?.classDef?.let { classDef ->
arrayOf( arrayOf(
Vp9PrimaryFingerprint, Vp9PrimaryFingerprint,
Vp9SecondaryFingerprint Vp9SecondaryFingerprint
).map { ).forEach { fingerprint ->
it.also { it.resolve(context, parentResult.classDef) }.result?.injectOverride() ?: return it.toErrorResult() fingerprint.also { it.resolve(context, classDef) }.result?.injectOverride() ?: return fingerprint.toErrorResult()
} }
} ?: return LayoutSwitchFingerprint.toErrorResult() } ?: return LayoutSwitchFingerprint.toErrorResult()
Vp9PropsParentFingerprint.result?.let { parentResult -> Vp9PropsParentFingerprint.result?.let { parentResult ->
Vp9PropsFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let { Vp9PropsFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let {
it.hookProps("MANUFACTURER", "getManufacturer") mapOf(
it.hookProps("BRAND", "getBrand") "MANUFACTURER" to "getManufacturer",
it.hookProps("MODEL", "getModel") "BRAND" to "getBrand",
"MODEL" to "getModel"
).forEach { (fieldName, descriptor) ->
it.hookProps(fieldName, descriptor)
}
} ?: return Vp9PropsFingerprint.toErrorResult() } ?: return Vp9PropsFingerprint.toErrorResult()
} ?: return Vp9PropsParentFingerprint.toErrorResult() } ?: return Vp9PropsParentFingerprint.toErrorResult()
@ -92,12 +93,12 @@ class ForceVP9CodecBytecodePatch : BytecodePatch(
} }
fun MutableMethod.hookProps( fun MutableMethod.hookProps(
descriptor: String, fieldName: String,
fieldName: String descriptor: String
) { ) {
val insertInstructions = implementation!!.instructions val insertInstructions = implementation!!.instructions
val targetString = "Landroid/os/Build;->" + val targetString = "Landroid/os/Build;->" +
descriptor + fieldName +
":Ljava/lang/String;" ":Ljava/lang/String;"
for ((index, instruction) in insertInstructions.withIndex()) { for ((index, instruction) in insertInstructions.withIndex()) {
@ -111,7 +112,7 @@ class ForceVP9CodecBytecodePatch : BytecodePatch(
addInstructions( addInstructions(
index + 1, """ index + 1, """
invoke-static {v$register}, $INTEGRATIONS_CLASS_DESCRIPTOR->$fieldName(Ljava/lang/String;)Ljava/lang/String; invoke-static {v$register}, $INTEGRATIONS_CLASS_DESCRIPTOR->$descriptor(Ljava/lang/String;)Ljava/lang/String;
move-result-object v$register move-result-object v$register
""" """
) )