mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-20 16:27:17 +02:00
feat(YouTube/Ambient mode switch): add Disable ambient mode in fullscreen
settings
This commit is contained in:
parent
a32a14b85c
commit
b3491491d1
@ -8,8 +8,11 @@ import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.annotation.CompatiblePackage
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.youtube.misc.ambientmode.fingerprints.AmbientModeInFullscreenFingerprint
|
||||
import app.revanced.patches.youtube.misc.ambientmode.fingerprints.PowerSaveModeFingerprint
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
import app.revanced.util.bytecode.getWide32LiteralIndex
|
||||
import app.revanced.util.integrations.Constants.FULLSCREEN
|
||||
import app.revanced.util.integrations.Constants.MISC_PATH
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
@ -17,8 +20,8 @@ import com.android.tools.smali.dexlib2.iface.instruction.formats.Instruction35c
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
@Patch(
|
||||
name = "Bypass ambient mode restrictions",
|
||||
description = "Bypass ambient mode restrictions in battery saver mode.",
|
||||
name = "Ambient mode switch",
|
||||
description = "Bypass the restrictions of ambient mode or disable it completely.",
|
||||
dependencies = [SettingsPatch::class],
|
||||
compatiblePackages = [
|
||||
CompatiblePackage(
|
||||
@ -44,8 +47,11 @@ import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
]
|
||||
)
|
||||
@Suppress("unused")
|
||||
object PowerSaveModePatch : BytecodePatch(
|
||||
setOf(PowerSaveModeFingerprint)
|
||||
object AmbientModeSwitchPatch : BytecodePatch(
|
||||
setOf(
|
||||
AmbientModeInFullscreenFingerprint,
|
||||
PowerSaveModeFingerprint
|
||||
)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
@ -65,7 +71,7 @@ object PowerSaveModePatch : BytecodePatch(
|
||||
|
||||
addInstructions(
|
||||
insertIndex, """
|
||||
invoke-static {v$targetRegister}, $MISC_PATH/PowerSaveModePatch;->bypassPowerSaveModeRestrictions(Z)Z
|
||||
invoke-static {v$targetRegister}, $MISC_PATH/AmbientModePatch;->bypassPowerSaveModeRestrictions(Z)Z
|
||||
move-result v$targetRegister
|
||||
"""
|
||||
)
|
||||
@ -75,16 +81,31 @@ object PowerSaveModePatch : BytecodePatch(
|
||||
}
|
||||
} ?: throw PowerSaveModeFingerprint.exception
|
||||
|
||||
AmbientModeInFullscreenFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val targetIndex = getWide32LiteralIndex(45389368) + 3
|
||||
val targetRegister = getInstruction<OneRegisterInstruction>(targetIndex).registerA
|
||||
|
||||
addInstructions(
|
||||
targetIndex + 1, """
|
||||
invoke-static {}, $FULLSCREEN->disableAmbientMode()Z
|
||||
move-result v$targetRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: throw AmbientModeInFullscreenFingerprint.exception
|
||||
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"SETTINGS: BYPASS_AMBIENT_MODE_RESTRICTIONS"
|
||||
"PREFERENCE: FULLSCREEN_SETTINGS",
|
||||
"SETTINGS: AMBIENT_MODE_SWITCH"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("Bypass ambient mode restrictions")
|
||||
SettingsPatch.updatePatchStatus("Ambient mode switch")
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package app.revanced.patches.youtube.misc.ambientmode.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
|
||||
import app.revanced.util.bytecode.isWide32LiteralExists
|
||||
|
||||
object AmbientModeInFullscreenFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.isWide32LiteralExists(45389368)
|
||||
}
|
||||
)
|
@ -63,6 +63,8 @@
|
||||
<string name="revanced_default_video_quality_mobile_title">Default video quality on Mobile network</string>
|
||||
<string name="revanced_default_video_quality_wifi_title">Default video quality on Wi-Fi network</string>
|
||||
<string name="revanced_description_title">Description</string>
|
||||
<string name="revanced_disable_ambient_mode_in_fullscreen_summary">Disables ambient mode in full screen</string>
|
||||
<string name="revanced_disable_ambient_mode_in_fullscreen_title">Disable ambient mode in fullscreen</string>
|
||||
<string name="revanced_disable_ambient_mode_summary">Always disable ambient mode</string>
|
||||
<string name="revanced_disable_ambient_mode_title">Disable ambient mode</string>
|
||||
<string name="revanced_disable_auto_captions_summary_off">Forced auto captions are enabled</string>
|
||||
@ -115,9 +117,6 @@
|
||||
<string name="revanced_enable_language_switch_summary_off">Language switch is disabled</string>
|
||||
<string name="revanced_enable_language_switch_summary_on">Language switch is enabled</string>
|
||||
<string name="revanced_enable_language_switch_title">Enable language switch</string>
|
||||
<string name="revanced_enable_new_comment_popup_panels_summary_off">New comment popup panels is disabled</string>
|
||||
<string name="revanced_enable_new_comment_popup_panels_summary_on">New comment popup panels is enabled</string>
|
||||
<string name="revanced_enable_new_comment_popup_panels_title">Enable new comment popup panels</string>
|
||||
<string name="revanced_enable_new_splash_animation_summary_off">New splash animation is disabled</string>
|
||||
<string name="revanced_enable_new_splash_animation_summary_on">New splash animation is enabled</string>
|
||||
<string name="revanced_enable_new_splash_animation_title">Enable new splash animation</string>
|
||||
|
@ -113,6 +113,9 @@
|
||||
<PreferenceScreen android:title="@string/revanced_fullscreen" android:key="fullscreen">
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_fullscreen" />PREFERENCE: FULLSCREEN_SETTINGS -->
|
||||
|
||||
<!-- SETTINGS: AMBIENT_MODE_SWITCH
|
||||
<SwitchPreference android:title="@string/revanced_disable_ambient_mode_in_fullscreen_title" android:key="revanced_disable_ambient_mode_in_fullscreen" android:defaultValue="false" android:summary="@string/revanced_disable_ambient_mode_in_fullscreen_summary" />SETTINGS: AMBIENT_MODE_SWITCH -->
|
||||
|
||||
<!-- SETTINGS: DISABLE_LANDSCAPE_MODE
|
||||
<SwitchPreference android:title="@string/revanced_disable_landscape_mode_title" android:key="revanced_disable_landscape_mode" android:defaultValue="false" android:summaryOn="@string/revanced_disable_landscape_mode_summary_on" android:summaryOff="@string/revanced_disable_landscape_mode_summary_off" />SETTINGS: DISABLE_LANDSCAPE_MODE -->
|
||||
|
||||
@ -253,9 +256,9 @@
|
||||
<PreferenceScreen android:title="@string/revanced_misc" android:key="misc">
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_misc" />
|
||||
|
||||
<!-- SETTINGS: BYPASS_AMBIENT_MODE_RESTRICTIONS
|
||||
<!-- SETTINGS: AMBIENT_MODE_SWITCH
|
||||
<SwitchPreference android:title="@string/revanced_bypass_ambient_mode_restrictions_title" android:key="revanced_bypass_ambient_mode_restrictions" android:defaultValue="false" android:summaryOn="@string/revanced_bypass_ambient_mode_restrictions_summary_on" android:summaryOff="@string/revanced_bypass_ambient_mode_restrictions_summary_off" />
|
||||
<SwitchPreference android:title="@string/revanced_disable_ambient_mode_title" android:key="revanced_disable_ambient_mode" android:defaultValue="false" android:summary="@string/revanced_disable_ambient_mode_summary" />SETTINGS: BYPASS_AMBIENT_MODE_RESTRICTIONS -->
|
||||
<SwitchPreference android:title="@string/revanced_disable_ambient_mode_title" android:key="revanced_disable_ambient_mode" android:defaultValue="false" android:summary="@string/revanced_disable_ambient_mode_summary" />SETTINGS: AMBIENT_MODE_SWITCH -->
|
||||
|
||||
<!-- SETTINGS: DOUBLE_BACK_TIMEOUT
|
||||
<ListPreference android:title="@string/revanced_double_back_timeout_title" android:summary="@string/revanced_double_back_timeout_summary" android:key="revanced_double_back_timeout" android:entries="@array/revanced_double_back_timeout_entry" android:defaultValue="2" android:entryValues="@array/revanced_double_back_timeout_value" />SETTINGS: DOUBLE_BACK_TIMEOUT -->
|
||||
@ -368,7 +371,7 @@
|
||||
<Preference android:title="Hide trending searches" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
||||
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_misc" />
|
||||
<Preference android:title="Bypass ambient mode restrictions" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Ambient mode switch" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Disable QUIC protocol" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Enable debug logging" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="Enable external browser" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user