feat: override video playback rate

This commit is contained in:
rhunk
2024-02-14 17:40:55 +01:00
parent 60ee3680a4
commit 93e9a67daf
5 changed files with 117 additions and 23 deletions

View File

@ -1,5 +1,6 @@
package me.rhunk.snapenhance.mapper.impl
import com.android.tools.smali.dexlib2.iface.Method
import me.rhunk.snapenhance.mapper.AbstractClassMapper
import me.rhunk.snapenhance.mapper.ext.findConstString
import me.rhunk.snapenhance.mapper.ext.getClassName
@ -8,7 +9,14 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
class OperaViewerParamsMapper : AbstractClassMapper("OperaViewerParams") {
val classReference = classReference("class")
val putMethod = string("putMethod")
val getMethod = string("getMethod")
val getOrDefaultMethod = string("getOrDefaultMethod")
private fun Method.hasHashMapReference(methodName: String) = implementation?.instructions?.any {
val instruction = it as? Instruction35c ?: return@any false
val reference = instruction.reference as? MethodReference ?: return@any false
reference.name == methodName && reference.definingClass == "Ljava/util/concurrent/ConcurrentHashMap;"
} == true
init {
mapper {
@ -16,17 +24,23 @@ class OperaViewerParamsMapper : AbstractClassMapper("OperaViewerParams") {
classDef.fields.firstOrNull { it.type == "Ljava/util/concurrent/ConcurrentHashMap;" } ?: continue
if (classDef.methods.firstOrNull { it.name == "toString" }?.implementation?.findConstString("Params") != true) continue
val putDexMethod = classDef.methods.firstOrNull { method ->
method.implementation?.instructions?.any {
val instruction = it as? Instruction35c ?: return@any false
val reference = instruction.reference as? MethodReference ?: return@any false
reference.name == "put" && reference.definingClass == "Ljava/util/concurrent/ConcurrentHashMap;"
} == true
val getOrDefaultDexMethod = classDef.methods.firstOrNull { method ->
method.returnType == "Ljava/lang/Object;" &&
method.parameters.size == 2 &&
method.parameterTypes[1] == "Ljava/lang/Object;" &&
method.hasHashMapReference("get")
} ?: return@mapper
classReference.set(classDef.getClassName())
putMethod.set(putDexMethod.name)
val getDexMethod = classDef.methods.firstOrNull { method ->
method.returnType == "Ljava/lang/Object;" &&
method.parameters.size == 1 &&
method.parameterTypes[0] == getOrDefaultDexMethod.parameterTypes[0] &&
method.hasHashMapReference("get")
} ?: return@mapper
getMethod.set(getDexMethod.name)
getOrDefaultMethod.set(getOrDefaultDexMethod.name)
classReference.set(classDef.getClassName())
return@mapper
}
}