mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-04 08:34:27 +02:00
feat(YouTube): remove navbar index patch
This commit is contained in:
parent
fa71b9ba3e
commit
e7a00f73da
@ -1,72 +0,0 @@
|
||||
package app.revanced.patches.youtube.utils.navbarindex
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.UTILS_PATH
|
||||
import app.revanced.patches.youtube.utils.navbarindex.fingerprints.MobileTopBarButtonOnClickFingerprint
|
||||
import app.revanced.patches.youtube.utils.navbarindex.fingerprints.PivotBarIndexFingerprint
|
||||
import app.revanced.patches.youtube.utils.navbarindex.fingerprints.SettingsActivityOnBackPressedFingerprint
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
|
||||
@Suppress("unused")
|
||||
object NavBarIndexHookPatch : BytecodePatch(
|
||||
setOf(
|
||||
MobileTopBarButtonOnClickFingerprint,
|
||||
PivotBarIndexFingerprint,
|
||||
SettingsActivityOnBackPressedFingerprint
|
||||
)
|
||||
) {
|
||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"$UTILS_PATH/NavBarIndexPatch;"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
/**
|
||||
* Change NavBar Index value according to selected Tab.
|
||||
*/
|
||||
PivotBarIndexFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.startIndex + 1
|
||||
val booleanRegister = getInstruction<FiveRegisterInstruction>(insertIndex).registerD
|
||||
val freeRegister = implementation!!.registerCount - parameters.size - 2
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static {v$freeRegister, v$booleanRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->setNavBarIndex(IZ)V"
|
||||
)
|
||||
addInstruction(
|
||||
0,
|
||||
"move/16 v$freeRegister, p1"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Since it is used only after opening the library tab, set index to 4.
|
||||
*/
|
||||
arrayOf(
|
||||
MobileTopBarButtonOnClickFingerprint,
|
||||
SettingsActivityOnBackPressedFingerprint
|
||||
).forEach { fingerprint ->
|
||||
fingerprint.injectIndex()
|
||||
}
|
||||
}
|
||||
|
||||
private fun MethodFingerprint.injectIndex() {
|
||||
resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
addInstructions(
|
||||
0, """
|
||||
const/4 v0, 0x4
|
||||
invoke-static {v0}, $INTEGRATIONS_CLASS_DESCRIPTOR->setNavBarIndex(I)V
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package app.revanced.patches.youtube.utils.navbarindex.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
|
||||
internal object MobileTopBarButtonOnClickFingerprint : MethodFingerprint(
|
||||
strings = listOf("MenuButtonRendererKey"),
|
||||
customFingerprint = { methodDef, _ -> methodDef.name == "onClick" }
|
||||
)
|
@ -1,14 +0,0 @@
|
||||
package app.revanced.patches.youtube.utils.navbarindex.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal object SettingsActivityOnBackPressedFingerprint : MethodFingerprint(
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
returnType = "V",
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass.endsWith("/SettingsActivity;")
|
||||
&& methodDef.name == "onBackPressed"
|
||||
}
|
||||
)
|
@ -10,15 +10,18 @@ import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||
import app.revanced.patches.youtube.utils.fingerprints.InitializeButtonsFingerprint
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.SHARED_PATH
|
||||
import app.revanced.patches.youtube.utils.mainactivity.MainActivityResolvePatch
|
||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.NavigationEnumFingerprint
|
||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarButtonsCreateDrawableViewFingerprint
|
||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarButtonsCreateResourceViewFingerprint
|
||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarButtonsViewSetSelectedFingerprint
|
||||
import app.revanced.patches.youtube.utils.navigation.fingerprints.PivotBarConstructorFingerprint
|
||||
import app.revanced.patches.youtube.utils.playertype.PlayerTypeHookPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.Instruction
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
@ -27,6 +30,7 @@ import com.android.tools.smali.dexlib2.util.MethodUtil
|
||||
@Patch(
|
||||
description = "Hooks the active navigation or search bar.",
|
||||
dependencies = [
|
||||
MainActivityResolvePatch::class,
|
||||
PlayerTypeHookPatch::class,
|
||||
SharedResourceIdPatch::class
|
||||
],
|
||||
@ -37,6 +41,7 @@ object NavigationBarHookPatch : BytecodePatch(
|
||||
NavigationEnumFingerprint,
|
||||
PivotBarButtonsCreateDrawableViewFingerprint,
|
||||
PivotBarButtonsCreateResourceViewFingerprint,
|
||||
PivotBarButtonsViewSetSelectedFingerprint,
|
||||
PivotBarConstructorFingerprint
|
||||
),
|
||||
) {
|
||||
@ -92,6 +97,26 @@ object NavigationBarHookPatch : BytecodePatch(
|
||||
}
|
||||
}
|
||||
|
||||
PivotBarButtonsViewSetSelectedFingerprint.resultOrThrow().let {
|
||||
it.mutableMethod.apply {
|
||||
val index = it.scanResult.patternScanResult!!.startIndex + 1
|
||||
val instruction = getInstruction<FiveRegisterInstruction>(index)
|
||||
val viewRegister = instruction.registerC
|
||||
val isSelectedRegister = instruction.registerD
|
||||
|
||||
addInstruction(
|
||||
index + 1,
|
||||
"invoke-static { v$viewRegister, v$isSelectedRegister }, " +
|
||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->navigationTabSelected(Landroid/view/View;Z)V",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
MainActivityResolvePatch.injectOnBackPressedMethodCall(
|
||||
INTEGRATIONS_CLASS_DESCRIPTOR,
|
||||
"onBackPressed"
|
||||
)
|
||||
|
||||
navigationTabCreatedCallback = context.findClass(INTEGRATIONS_CLASS_DESCRIPTOR)?.mutableClass?.methods?.first { method ->
|
||||
method.name == "navigationTabCreatedCallback"
|
||||
} ?: throw PatchException("Could not find navigationTabCreatedCallback method")
|
||||
|
@ -1,11 +1,11 @@
|
||||
package app.revanced.patches.youtube.utils.navbarindex.fingerprints
|
||||
package app.revanced.patches.youtube.utils.navigation.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal object PivotBarIndexFingerprint : MethodFingerprint(
|
||||
internal object PivotBarButtonsViewSetSelectedFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("I", "Z"),
|
||||
@ -14,5 +14,7 @@ internal object PivotBarIndexFingerprint : MethodFingerprint(
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.INVOKE_VIRTUAL
|
||||
),
|
||||
customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/PivotBar;") }
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass.endsWith("/PivotBar;")
|
||||
}
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user