mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-05 00:54:32 +02:00
fix(YouTube): Force fullscreen
patch fails on some versions
This commit is contained in:
parent
73384bed22
commit
8467b7058c
@ -9,11 +9,13 @@ import app.revanced.patcher.patch.BytecodePatch
|
|||||||
import app.revanced.patcher.patch.PatchException
|
import app.revanced.patcher.patch.PatchException
|
||||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
|
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
|
||||||
import app.revanced.patches.youtube.fullscreen.forcefullscreen.fingerprints.ClientSettingEndpointFingerprint
|
import app.revanced.patches.youtube.fullscreen.forcefullscreen.fingerprints.ClientSettingEndpointFingerprint
|
||||||
import app.revanced.patches.youtube.fullscreen.forcefullscreen.fingerprints.VideoPortraitParentFingerprint
|
import app.revanced.patches.youtube.fullscreen.forcefullscreen.fingerprints.VideoPortraitParentFingerprint
|
||||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||||
import app.revanced.util.bytecode.getStringIndex
|
import app.revanced.util.bytecode.getStringIndex
|
||||||
import app.revanced.util.integrations.Constants.FULLSCREEN
|
import app.revanced.util.integrations.Constants.FULLSCREEN
|
||||||
|
import com.android.tools.smali.dexlib2.Opcode
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.FiveRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
import com.android.tools.smali.dexlib2.iface.instruction.ReferenceInstruction
|
||||||
@ -96,7 +98,9 @@ object ForceFullscreenPatch : BytecodePatch(
|
|||||||
*/
|
*/
|
||||||
VideoPortraitParentFingerprint.result?.let {
|
VideoPortraitParentFingerprint.result?.let {
|
||||||
it.mutableMethod.apply {
|
it.mutableMethod.apply {
|
||||||
val targetIndex = it.scanResult.patternScanResult!!.endIndex - 1
|
val stringIndex = getStringIndex("Acquiring NetLatencyActionLogger failed. taskId=")
|
||||||
|
val invokeIndex = getTargetIndexTo(stringIndex, Opcode.INVOKE_INTERFACE)
|
||||||
|
val targetIndex = getTargetIndexTo(invokeIndex, Opcode.CHECK_CAST)
|
||||||
val targetClass = context
|
val targetClass = context
|
||||||
.findClass(getInstruction<ReferenceInstruction>(targetIndex).reference.toString())!!
|
.findClass(getInstruction<ReferenceInstruction>(targetIndex).reference.toString())!!
|
||||||
.mutableClass
|
.mutableClass
|
||||||
@ -125,4 +129,17 @@ object ForceFullscreenPatch : BytecodePatch(
|
|||||||
SettingsPatch.updatePatchStatus("Force fullscreen")
|
SettingsPatch.updatePatchStatus("Force fullscreen")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun MutableMethod.getTargetIndexTo(
|
||||||
|
startIndex: Int,
|
||||||
|
opcode: Opcode
|
||||||
|
): Int {
|
||||||
|
for (index in startIndex until implementation!!.instructions.size) {
|
||||||
|
if (getInstruction(index).opcode != opcode)
|
||||||
|
continue
|
||||||
|
|
||||||
|
return index
|
||||||
|
}
|
||||||
|
throw PatchException("Failed to find target index")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,17 +3,10 @@ package app.revanced.patches.youtube.fullscreen.forcefullscreen.fingerprints
|
|||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||||
import com.android.tools.smali.dexlib2.AccessFlags
|
import com.android.tools.smali.dexlib2.AccessFlags
|
||||||
import com.android.tools.smali.dexlib2.Opcode
|
|
||||||
|
|
||||||
object VideoPortraitParentFingerprint : MethodFingerprint(
|
object VideoPortraitParentFingerprint : MethodFingerprint(
|
||||||
returnType = "V",
|
returnType = "V",
|
||||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
parameters = listOf("L", "Ljava/util/Map;"),
|
parameters = listOf("L", "Ljava/util/Map;"),
|
||||||
opcodes = listOf(
|
|
||||||
Opcode.INVOKE_INTERFACE,
|
|
||||||
Opcode.MOVE_RESULT_OBJECT,
|
|
||||||
Opcode.CHECK_CAST,
|
|
||||||
Opcode.GOTO
|
|
||||||
),
|
|
||||||
strings = listOf("Acquiring NetLatencyActionLogger failed. taskId=")
|
strings = listOf("Acquiring NetLatencyActionLogger failed. taskId=")
|
||||||
)
|
)
|
Loading…
x
Reference in New Issue
Block a user