mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-05 00:54:32 +02:00
fix(YouTube/NavBar index): apply alternative fingerprint - supports wider version
This commit is contained in:
parent
12872b6163
commit
ccc5826ece
@ -31,9 +31,6 @@ object PowerSaveModeFingerprint : MethodFingerprint(
|
||||
|
||||
count++
|
||||
}
|
||||
if (count < 2)
|
||||
return@custom false
|
||||
|
||||
count == 2
|
||||
}
|
||||
)
|
@ -11,7 +11,6 @@ import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patches.youtube.utils.fingerprints.OnBackPressedFingerprint
|
||||
import app.revanced.patches.youtube.utils.navbarindex.fingerprints.MobileTopBarButtonOnClickFingerprint
|
||||
import app.revanced.patches.youtube.utils.navbarindex.fingerprints.NavButtonOnClickFingerprint
|
||||
import app.revanced.patches.youtube.utils.navbarindex.fingerprints.NavButtonOnClickLegacyFingerprint
|
||||
import app.revanced.patches.youtube.utils.navbarindex.fingerprints.OnResumeFragmentsFingerprints
|
||||
import app.revanced.patches.youtube.utils.navbarindex.fingerprints.SettingsActivityOnBackPressedFingerprint
|
||||
import app.revanced.util.integrations.Constants.UTILS_PATH
|
||||
@ -23,7 +22,6 @@ object NavBarIndexHookPatch : BytecodePatch(
|
||||
setOf(
|
||||
MobileTopBarButtonOnClickFingerprint,
|
||||
NavButtonOnClickFingerprint,
|
||||
NavButtonOnClickLegacyFingerprint,
|
||||
OnBackPressedFingerprint,
|
||||
OnResumeFragmentsFingerprints,
|
||||
SettingsActivityOnBackPressedFingerprint
|
||||
@ -31,14 +29,10 @@ object NavBarIndexHookPatch : BytecodePatch(
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
val navButtonOnClickFingerprintResult =
|
||||
NavButtonOnClickFingerprint.result
|
||||
?: NavButtonOnClickLegacyFingerprint.result
|
||||
?: throw NavButtonOnClickFingerprint.exception
|
||||
/**
|
||||
* Change NavBar Index value according to selected Tab
|
||||
*/
|
||||
navButtonOnClickFingerprintResult.let {
|
||||
NavButtonOnClickFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val insertIndex = it.scanResult.patternScanResult!!.endIndex - 1
|
||||
val targetString =
|
||||
@ -53,7 +47,7 @@ object NavBarIndexHookPatch : BytecodePatch(
|
||||
"invoke-static {v$indexRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->setCurrentNavBarIndex(I)V"
|
||||
)
|
||||
}
|
||||
}
|
||||
} ?: throw NavButtonOnClickFingerprint.exception
|
||||
|
||||
/**
|
||||
* Set NavBar index to last index on back press
|
||||
|
@ -4,14 +4,13 @@ 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
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||
|
||||
object NavButtonOnClickFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Landroid/view/View;"),
|
||||
opcodes = listOf(
|
||||
Opcode.NEW_INSTANCE,
|
||||
null,
|
||||
Opcode.INVOKE_DIRECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.RETURN_VOID,
|
||||
@ -23,7 +22,29 @@ object NavButtonOnClickFingerprint : MethodFingerprint(
|
||||
Opcode.INVOKE_VIRTUAL, // insert index
|
||||
Opcode.RETURN_VOID
|
||||
),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.name == "onClick"
|
||||
customFingerprint = custom@{ methodDef, classDef ->
|
||||
if (classDef.methods.count() != 3)
|
||||
return@custom false
|
||||
|
||||
if (methodDef.name != "onClick")
|
||||
return@custom false
|
||||
|
||||
val instructions = methodDef.implementation?.instructions!!
|
||||
|
||||
if (instructions.count() < 20)
|
||||
return@custom false
|
||||
|
||||
var count = 0
|
||||
for (instruction in instructions) {
|
||||
if (instruction.opcode != Opcode.INVOKE_VIRTUAL)
|
||||
continue
|
||||
|
||||
val invokeInstruction = instruction as ReferenceInstruction
|
||||
if (invokeInstruction.reference.toString() != "Ljava/util/ArrayList;->indexOf(Ljava/lang/Object;)I")
|
||||
continue
|
||||
|
||||
count++
|
||||
}
|
||||
count == 2
|
||||
}
|
||||
)
|
@ -1,26 +0,0 @@
|
||||
package app.revanced.patches.youtube.utils.navbarindex.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.util.bytecode.isNarrowLiteralExists
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
object NavButtonOnClickLegacyFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Landroid/view/View;"),
|
||||
opcodes = listOf(
|
||||
Opcode.RETURN_VOID,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.CHECK_CAST,
|
||||
Opcode.IGET_OBJECT,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT,
|
||||
Opcode.INVOKE_VIRTUAL, // insert index
|
||||
Opcode.RETURN_VOID
|
||||
),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.name == "onClick" && methodDef.isNarrowLiteralExists(16843611)
|
||||
}
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user