mirror of
https://github.com/revanced/revanced-patches.git
synced 2025-04-29 22:24:27 +02:00
fix(YouTube - Remove background playback restrictions): Restore PiP button functionality after screen is unlocked
This commit is contained in:
parent
95440273a6
commit
6837348c45
@ -14,7 +14,7 @@ import app.revanced.util.findFreeRegister
|
||||
import app.revanced.util.findInstructionIndicesReversedOrThrow
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.insertFeatureFlagBooleanOverride
|
||||
import app.revanced.util.insertLiteralOverride
|
||||
import app.revanced.util.returnEarly
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
@ -235,7 +235,7 @@ fun spoofVideoStreamsPatch(
|
||||
|
||||
// region Fix iOS livestream current time.
|
||||
|
||||
hlsCurrentTimeFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
hlsCurrentTimeFingerprint.method.insertLiteralOverride(
|
||||
HLS_CURRENT_TIME_FEATURE_FLAG,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->fixHLSCurrentTime(Z)Z"
|
||||
)
|
||||
@ -245,21 +245,21 @@ fun spoofVideoStreamsPatch(
|
||||
// region turn off stream config replacement feature flag.
|
||||
|
||||
if (fixMediaFetchHotConfigChanges()) {
|
||||
mediaFetchHotConfigFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
mediaFetchHotConfigFingerprint.method.insertLiteralOverride(
|
||||
MEDIA_FETCH_HOT_CONFIG_FEATURE_FLAG,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->useMediaFetchHotConfigReplacement(Z)Z"
|
||||
)
|
||||
}
|
||||
|
||||
if (fixMediaFetchHotConfigAlternativeChanges()) {
|
||||
mediaFetchHotConfigAlternativeFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
mediaFetchHotConfigAlternativeFingerprint.method.insertLiteralOverride(
|
||||
MEDIA_FETCH_HOT_CONFIG_ALTERNATIVE_FEATURE_FLAG,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->useMediaFetchHotConfigReplacement(Z)Z"
|
||||
)
|
||||
}
|
||||
|
||||
if (fixParsePlaybackResponseFeatureFlag()) {
|
||||
playbackStartDescriptorFeatureFlagFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
playbackStartDescriptorFeatureFlagFingerprint.method.insertLiteralOverride(
|
||||
PLAYBACK_START_CHECK_ENDPOINT_USED_FEATURE_FLAG,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->usePlaybackStartFeatureFlag(Z)Z"
|
||||
)
|
||||
|
@ -117,7 +117,7 @@ val swipeControlsPatch = bytecodePatch(
|
||||
// region patch to enable/disable swipe to change video.
|
||||
|
||||
if (is_19_43_or_greater) {
|
||||
swipeChangeVideoFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
swipeChangeVideoFingerprint.method.insertLiteralOverride(
|
||||
SWIPE_CHANGE_VIDEO_FEATURE_FLAG,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->allowSwipeChangeVideo(Z)Z"
|
||||
)
|
||||
|
@ -18,7 +18,7 @@ import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.insertFeatureFlagBooleanOverride
|
||||
import app.revanced.util.insertLiteralOverride
|
||||
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.reference.MethodReference
|
||||
@ -119,17 +119,17 @@ val navigationButtonsPatch = bytecodePatch(
|
||||
|
||||
// Force on/off translucent effect on status bar and navigation buttons.
|
||||
if (is_19_25_or_greater) {
|
||||
translucentNavigationStatusBarFeatureFlagFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
translucentNavigationStatusBarFeatureFlagFingerprint.method.insertLiteralOverride(
|
||||
TRANSLUCENT_NAVIGATION_STATUS_BAR_FEATURE_FLAG,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->useTranslucentNavigationStatusBar(Z)Z",
|
||||
)
|
||||
|
||||
translucentNavigationButtonsFeatureFlagFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
translucentNavigationButtonsFeatureFlagFingerprint.method.insertLiteralOverride(
|
||||
TRANSLUCENT_NAVIGATION_BUTTONS_FEATURE_FLAG,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->useTranslucentNavigationButtons(Z)Z",
|
||||
)
|
||||
|
||||
translucentNavigationButtonsSystemFeatureFlagFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
translucentNavigationButtonsSystemFeatureFlagFingerprint.method.insertLiteralOverride(
|
||||
TRANSLUCENT_NAVIGATION_BUTTONS_SYSTEM_FEATURE_FLAG,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->useTranslucentNavigationButtons(Z)Z",
|
||||
)
|
||||
|
@ -278,7 +278,7 @@ val miniplayerPatch = bytecodePatch(
|
||||
fun Fingerprint.insertMiniplayerFeatureFlagBooleanOverride(
|
||||
literal: Long,
|
||||
extensionMethod: String,
|
||||
) = method.insertFeatureFlagBooleanOverride(
|
||||
) = method.insertLiteralOverride(
|
||||
literal,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->$extensionMethod(Z)Z"
|
||||
)
|
||||
|
@ -5,7 +5,7 @@ import app.revanced.patches.youtube.layout.shortsplayer.openShortsInRegularPlaye
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_46_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||
import app.revanced.util.insertFeatureFlagBooleanOverride
|
||||
import app.revanced.util.insertLiteralOverride
|
||||
|
||||
internal const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
"Lapp/revanced/extension/youtube/patches/OpenVideosFullscreenHookPatch;"
|
||||
@ -24,7 +24,7 @@ internal val openVideosFullscreenHookPatch = bytecodePatch {
|
||||
return@execute
|
||||
}
|
||||
|
||||
openVideosFullscreenPortraitFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
openVideosFullscreenPortraitFingerprint.method.insertLiteralOverride(
|
||||
OPEN_VIDEOS_FULLSCREEN_PORTRAIT_FEATURE_FLAG,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->openVideoFullscreenPortrait(Z)Z"
|
||||
)
|
||||
|
@ -28,9 +28,8 @@ import app.revanced.util.findElementByAttributeValueOrThrow
|
||||
import app.revanced.util.findInstructionIndicesReversedOrThrow
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.indexOfFirstLiteralInstructionOrThrow
|
||||
import app.revanced.util.inputStreamFromBundledResource
|
||||
import app.revanced.util.insertFeatureFlagBooleanOverride
|
||||
import app.revanced.util.insertLiteralOverride
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.builder.MutableMethodImplementation
|
||||
@ -229,16 +228,9 @@ val seekbarColorPatch = bytecodePatch(
|
||||
|
||||
execute {
|
||||
fun MutableMethod.addColorChangeInstructions(resourceId: Long) {
|
||||
val index = indexOfFirstLiteralInstructionOrThrow(resourceId)
|
||||
val insertIndex = indexOfFirstInstructionOrThrow(index, Opcode.MOVE_RESULT)
|
||||
val register = getInstruction<OneRegisterInstruction>(insertIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
insertIndex + 1,
|
||||
"""
|
||||
invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR->getVideoPlayerSeekbarColor(I)I
|
||||
move-result v$register
|
||||
"""
|
||||
insertLiteralOverride(
|
||||
resourceId,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->getVideoPlayerSeekbarColor(I)I"
|
||||
)
|
||||
}
|
||||
|
||||
@ -354,7 +346,7 @@ val seekbarColorPatch = bytecodePatch(
|
||||
launchScreenLayoutTypeFingerprint,
|
||||
mainActivityOnCreateFingerprint
|
||||
).forEach { fingerprint ->
|
||||
fingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
fingerprint.method.insertLiteralOverride(
|
||||
launchScreenLayoutTypeLotteFeatureFlag,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->useLotteLaunchSplashScreen(Z)Z"
|
||||
)
|
||||
|
@ -21,7 +21,7 @@ import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
import app.revanced.util.forEachChildElement
|
||||
import app.revanced.util.insertFeatureFlagBooleanOverride
|
||||
import app.revanced.util.insertLiteralOverride
|
||||
import org.w3c.dom.Element
|
||||
|
||||
private const val EXTENSION_CLASS_DESCRIPTOR =
|
||||
@ -233,7 +233,7 @@ val themePatch = bytecodePatch(
|
||||
SwitchPreference("revanced_gradient_loading_screen"),
|
||||
)
|
||||
|
||||
useGradientLoadingScreenFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
useGradientLoadingScreenFingerprint.method.insertLiteralOverride(
|
||||
GRADIENT_LOADING_SCREEN_AB_CONSTANT,
|
||||
"$EXTENSION_CLASS_DESCRIPTOR->gradientLoadingScreenEnabled(Z)Z"
|
||||
)
|
||||
|
@ -12,6 +12,8 @@ import app.revanced.patches.shared.misc.mapping.resourceMappings
|
||||
import app.revanced.patches.shared.misc.settings.preference.SwitchPreference
|
||||
import app.revanced.patches.youtube.misc.extension.sharedExtensionPatch
|
||||
import app.revanced.patches.youtube.misc.playertype.playerTypeHookPatch
|
||||
import app.revanced.patches.youtube.misc.playservice.is_19_34_or_greater
|
||||
import app.revanced.patches.youtube.misc.playservice.versionCheckPatch
|
||||
import app.revanced.patches.youtube.misc.settings.PreferenceScreen
|
||||
import app.revanced.patches.youtube.misc.settings.settingsPatch
|
||||
import app.revanced.patches.youtube.video.information.videoInformationPatch
|
||||
@ -44,6 +46,7 @@ val backgroundPlaybackPatch = bytecodePatch(
|
||||
playerTypeHookPatch,
|
||||
videoInformationPatch,
|
||||
settingsPatch,
|
||||
versionCheckPatch
|
||||
)
|
||||
|
||||
compatibleWith(
|
||||
@ -100,5 +103,13 @@ val backgroundPlaybackPatch = bytecodePatch(
|
||||
|
||||
// Force allowing background play for videos labeled for kids.
|
||||
kidsBackgroundPlaybackPolicyControllerFingerprint.method.returnEarly()
|
||||
|
||||
// Fix PiP buttons not working after locking/unlocking device screen.
|
||||
if (is_19_34_or_greater) {
|
||||
pipInputConsumerFeatureFlagFingerprint.method.insertLiteralOverride(
|
||||
PIP_INPUT_CONSUMER_FEATURE_FLAG,
|
||||
false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,4 +83,11 @@ internal val shortsBackgroundPlaybackFeatureFlagFingerprint = fingerprint {
|
||||
returns("Z")
|
||||
parameters()
|
||||
literal { 45415425 }
|
||||
}
|
||||
|
||||
internal const val PIP_INPUT_CONSUMER_FEATURE_FLAG = 45638483L
|
||||
|
||||
// Fix 'E/InputDispatcher: Window handle pip_input_consumer has no registered input channel'
|
||||
internal val pipInputConsumerFeatureFlagFingerprint = fingerprint {
|
||||
literal { PIP_INPUT_CONSUMER_FEATURE_FLAG}
|
||||
}
|
@ -269,7 +269,7 @@ val settingsPatch = bytecodePatch(
|
||||
}
|
||||
|
||||
// Add setting to force cairo settings fragment on/off.
|
||||
cairoFragmentConfigFingerprint.method.insertFeatureFlagBooleanOverride(
|
||||
cairoFragmentConfigFingerprint.method.insertLiteralOverride(
|
||||
CAIRO_CONFIG_LITERAL_VALUE,
|
||||
"$activityHookClassDescriptor->useCairoSettingsFragment(Z)Z"
|
||||
)
|
||||
|
@ -636,7 +636,12 @@ fun Method.findInstructionIndicesReversedOrThrow(opcode: Opcode): List<Int> {
|
||||
return instructions
|
||||
}
|
||||
|
||||
internal fun MutableMethod.insertFeatureFlagBooleanOverride(literal: Long, extensionsMethod: String) {
|
||||
/**
|
||||
* Overrides the first move result with an extension call.
|
||||
* Suitable for calls to extension code to override boolean and integer values.
|
||||
*/
|
||||
internal fun MutableMethod.insertLiteralOverride(literal: Long, extensionMethodDescriptor: String) {
|
||||
// TODO: make this work with objects and wide values.
|
||||
val literalIndex = indexOfFirstLiteralInstructionOrThrow(literal)
|
||||
val index = indexOfFirstInstructionOrThrow(literalIndex, MOVE_RESULT)
|
||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
@ -650,9 +655,24 @@ internal fun MutableMethod.insertFeatureFlagBooleanOverride(literal: Long, exten
|
||||
addInstructions(
|
||||
index + 1,
|
||||
"""
|
||||
$operation, $extensionsMethod
|
||||
$operation, $extensionMethodDescriptor
|
||||
move-result v$register
|
||||
""",
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides a literal value result with a constant value.
|
||||
*/
|
||||
internal fun MutableMethod.insertLiteralOverride(literal: Long, override: Boolean) {
|
||||
val literalIndex = indexOfFirstLiteralInstructionOrThrow(literal)
|
||||
val index = indexOfFirstInstructionOrThrow(literalIndex, MOVE_RESULT)
|
||||
val register = getInstruction<OneRegisterInstruction>(index).registerA
|
||||
val overrideValue = if (override) "0x1" else "0x0"
|
||||
|
||||
addInstruction(
|
||||
index + 1,
|
||||
"const v$register, $overrideValue"
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user