mirror of
https://github.com/rhunk/SnapEnhance.git
synced 2025-06-12 13:17:42 +02:00
feat: override video playback rate
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user