mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
refactor: Disable pip mode in shorts player
(Experimental Flags) setting now works on Android 12+ devices
This commit is contained in:
@ -0,0 +1,16 @@
|
|||||||
|
package app.revanced.patches.youtube.extended.shortspip.bytecode.fingerprints
|
||||||
|
|
||||||
|
import app.revanced.patcher.extensions.or
|
||||||
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
|
object PiPFingerprint : MethodFingerprint(
|
||||||
|
returnType = "V",
|
||||||
|
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
|
parameters = listOf("L"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.IF_NE,
|
||||||
|
Opcode.CONST_4
|
||||||
|
)
|
||||||
|
)
|
@ -3,10 +3,15 @@ package app.revanced.patches.youtube.extended.shortspip.bytecode.fingerprints
|
|||||||
import app.revanced.patcher.extensions.or
|
import app.revanced.patcher.extensions.or
|
||||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||||
import org.jf.dexlib2.AccessFlags
|
import org.jf.dexlib2.AccessFlags
|
||||||
|
import org.jf.dexlib2.Opcode
|
||||||
|
|
||||||
object DisableShortsPiPFingerprint : MethodFingerprint(
|
object PiPParentFingerprint : MethodFingerprint(
|
||||||
returnType = "L",
|
returnType = "V",
|
||||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||||
parameters = listOf("L"),
|
parameters = listOf("L"),
|
||||||
|
opcodes = listOf(
|
||||||
|
Opcode.SGET_OBJECT,
|
||||||
|
Opcode.NEW_INSTANCE
|
||||||
|
),
|
||||||
customFingerprint = { it.definingClass == "Lcom/google/android/apps/youtube/app/common/ui/pip/DefaultPipController;" }
|
customFingerprint = { it.definingClass == "Lcom/google/android/apps/youtube/app/common/ui/pip/DefaultPipController;" }
|
||||||
)
|
)
|
@ -5,20 +5,17 @@ import app.revanced.patcher.annotation.Version
|
|||||||
import app.revanced.patcher.data.BytecodeContext
|
import app.revanced.patcher.data.BytecodeContext
|
||||||
import app.revanced.patcher.extensions.addInstructions
|
import app.revanced.patcher.extensions.addInstructions
|
||||||
import app.revanced.patcher.extensions.instruction
|
import app.revanced.patcher.extensions.instruction
|
||||||
import app.revanced.patcher.extensions.removeInstruction
|
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint.Companion.resolve
|
||||||
import app.revanced.patcher.extensions.replaceInstruction
|
|
||||||
import app.revanced.patcher.patch.BytecodePatch
|
import app.revanced.patcher.patch.BytecodePatch
|
||||||
import app.revanced.patcher.patch.PatchResult
|
import app.revanced.patcher.patch.PatchResult
|
||||||
import app.revanced.patcher.patch.PatchResultSuccess
|
import app.revanced.patcher.patch.PatchResultSuccess
|
||||||
import app.revanced.patcher.patch.annotations.DependsOn
|
import app.revanced.patcher.patch.annotations.DependsOn
|
||||||
import app.revanced.patcher.util.smali.ExternalLabel
|
import app.revanced.patches.youtube.extended.shortspip.bytecode.fingerprints.*
|
||||||
import app.revanced.patches.youtube.extended.shortspip.bytecode.fingerprints.DisableShortsPiPFingerprint
|
|
||||||
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
import app.revanced.patches.youtube.misc.playertype.patch.PlayerTypeHookPatch
|
||||||
import app.revanced.shared.annotation.YouTubeCompatibility
|
import app.revanced.shared.annotation.YouTubeCompatibility
|
||||||
import app.revanced.shared.extensions.toErrorResult
|
import app.revanced.shared.extensions.toErrorResult
|
||||||
import app.revanced.shared.util.integrations.Constants.EXTENDED_PATH
|
import app.revanced.shared.util.integrations.Constants.EXTENDED_PATH
|
||||||
import org.jf.dexlib2.Opcode
|
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c
|
||||||
import org.jf.dexlib2.builder.instruction.BuilderInstruction35c
|
|
||||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||||
|
|
||||||
@Name("disable-shorts-pip-bytecode-patch")
|
@Name("disable-shorts-pip-bytecode-patch")
|
||||||
@ -31,48 +28,33 @@ import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
|||||||
@Version("0.0.1")
|
@Version("0.0.1")
|
||||||
class DisableShortsPiPBytecodePatch : BytecodePatch(
|
class DisableShortsPiPBytecodePatch : BytecodePatch(
|
||||||
listOf(
|
listOf(
|
||||||
DisableShortsPiPFingerprint
|
PiPParentFingerprint
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
override fun execute(context: BytecodeContext): PatchResult {
|
override fun execute(context: BytecodeContext): PatchResult {
|
||||||
|
|
||||||
DisableShortsPiPFingerprint.result?.mutableMethod?.let { method ->
|
PiPParentFingerprint.result?.let { result ->
|
||||||
|
val targetIndex = result.scanResult.patternScanResult!!.endIndex
|
||||||
|
val targetTnstuction = result.mutableMethod.instruction(targetIndex)
|
||||||
|
val imageButtonClass =
|
||||||
|
context.findClass((targetTnstuction as BuilderInstruction21c)
|
||||||
|
.reference.toString())!!
|
||||||
|
.mutableClass
|
||||||
|
|
||||||
with (method.implementation!!) {
|
PiPFingerprint.also { it.resolve(context, imageButtonClass) }.result?.let { newResult ->
|
||||||
val invokeIndex = this.instructions.indexOfFirst {
|
with (newResult.mutableMethod) {
|
||||||
it.opcode.ordinal == Opcode.INVOKE_VIRTUAL.ordinal &&
|
val endIndex = newResult.scanResult.patternScanResult!!.endIndex
|
||||||
((it as? BuilderInstruction35c)?.reference.toString() ==
|
val register = (implementation!!.instructions[endIndex] as OneRegisterInstruction).registerA
|
||||||
"$REFERENCE_DESCRIPTOR")
|
this.addInstructions(
|
||||||
|
endIndex + 1, """
|
||||||
|
invoke-static {v$register}, $EXTENDED_PATH/DisableShortsPiPPatch;->disableShortsPlayerPiP(Z)Z
|
||||||
|
move-result v$register
|
||||||
|
"""
|
||||||
|
)
|
||||||
}
|
}
|
||||||
val registerA = (method.instruction(invokeIndex + 1) as OneRegisterInstruction).registerA
|
} ?: return PiPFingerprint.toErrorResult()
|
||||||
|
} ?: return PiPParentFingerprint.toErrorResult()
|
||||||
val registerC = (method.instruction(invokeIndex) as BuilderInstruction35c).registerC
|
|
||||||
val registerE = (method.instruction(invokeIndex) as BuilderInstruction35c).registerE
|
|
||||||
|
|
||||||
method.addInstructions(
|
|
||||||
invokeIndex + 1,"""
|
|
||||||
invoke-static {}, $EXTENDED_PATH/DisableShortsPiPPatch;->disableShortsPlayerPiP()Z
|
|
||||||
move-result v$registerA
|
|
||||||
if-eqz v$registerA, :pip
|
|
||||||
goto :disablepip
|
|
||||||
:pip
|
|
||||||
invoke-virtual {v${registerC}, v${registerE}}, $REFERENCE_DESCRIPTOR
|
|
||||||
move-result v$registerA
|
|
||||||
""", listOf(ExternalLabel("disablepip", method.instruction(invokeIndex + 1)))
|
|
||||||
)
|
|
||||||
method.removeInstruction(invokeIndex)
|
|
||||||
method.replaceInstruction(
|
|
||||||
invokeIndex + 6, "nop"
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
} ?: return DisableShortsPiPFingerprint.toErrorResult()
|
|
||||||
|
|
||||||
return PatchResultSuccess()
|
return PatchResultSuccess()
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
|
||||||
const val REFERENCE_DESCRIPTOR =
|
|
||||||
"Landroid/app/Activity;->enterPictureInPictureMode(Landroid/app/PictureInPictureParams;)Z"
|
|
||||||
}
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user