feat: swipe-controls
override volume button behaviour (#285)
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
package app.revanced.extensions
|
||||
|
||||
import app.revanced.patcher.data.impl.BytecodeData
|
||||
import app.revanced.patcher.data.impl.ResourceData
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableClass
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patcher.util.smali.toInstruction
|
||||
import org.jf.dexlib2.AccessFlags
|
||||
@ -27,6 +29,30 @@ internal fun MutableMethodImplementation.injectHideCall(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* traverse the class hierarchy starting from the given root class
|
||||
*
|
||||
* @param targetClass the class to start traversing the class hierarchy from
|
||||
* @param callback function that is called for every class in the hierarchy
|
||||
*/
|
||||
fun BytecodeData.traverseClassHierarchy(targetClass: MutableClass, callback: MutableClass.() -> Unit) {
|
||||
callback(targetClass)
|
||||
this.findClass(targetClass.superclass ?: return)?.resolve()?.let {
|
||||
traverseClassHierarchy(it, callback)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* apply a transform to all methods of the class
|
||||
*
|
||||
* @param transform the transformation function. original method goes in, transformed method goes out
|
||||
*/
|
||||
fun MutableClass.transformMethods(transform: MutableMethod.() -> MutableMethod) {
|
||||
val transformedMethods = methods.map { it.transform() }
|
||||
methods.clear()
|
||||
methods.addAll(transformedMethods)
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert an event hook at the top of the method. If the hook returns true, the event is consumed and the method will return with true
|
||||
*
|
||||
|
Reference in New Issue
Block a user