mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-22 19:09:12 +02:00
add bypass-ambient-mode-restrictions
patch
This commit is contained in:
parent
363b752e06
commit
53d853500d
@ -0,0 +1,19 @@
|
||||
package app.revanced.patches.youtube.misc.ambientmode.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
|
||||
import org.jf.dexlib2.iface.instruction.NarrowLiteralInstruction
|
||||
|
||||
object PowerSaveModeFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
access = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(Opcode.SUB_INT_2ADDR),
|
||||
customFingerprint = { methodDef ->
|
||||
methodDef.implementation!!.instructions.any {
|
||||
((it as? NarrowLiteralInstruction)?.narrowLiteral == 107243)
|
||||
}
|
||||
}
|
||||
)
|
@ -0,0 +1,68 @@
|
||||
package app.revanced.patches.youtube.misc.ambientmode.patch
|
||||
|
||||
import app.revanced.extensions.toErrorResult
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.addInstructions
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
import app.revanced.patches.youtube.misc.ambientmode.fingerprints.PowerSaveModeFingerprint
|
||||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsPatch
|
||||
import app.revanced.util.integrations.Constants.MISC_PATH
|
||||
import org.jf.dexlib2.Opcode
|
||||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
|
||||
import org.jf.dexlib2.iface.instruction.formats.Instruction35c
|
||||
import org.jf.dexlib2.iface.reference.MethodReference
|
||||
|
||||
@Patch
|
||||
@Name("bypass-ambient-mode-restrictions")
|
||||
@Description("Bypass ambient mode restrictions in battery saver mode.")
|
||||
@DependsOn([SettingsPatch::class])
|
||||
@YouTubeCompatibility
|
||||
@Version("0.0.1")
|
||||
class PowerSaveModePatch : BytecodePatch(
|
||||
listOf(PowerSaveModeFingerprint)
|
||||
) {
|
||||
override fun execute(context: BytecodeContext): PatchResult {
|
||||
|
||||
PowerSaveModeFingerprint.result?.mutableMethod?.let {
|
||||
val instructions = it.implementation!!.instructions
|
||||
for ((index, instruction) in instructions.withIndex()) {
|
||||
if (instruction.opcode != Opcode.INVOKE_VIRTUAL) continue
|
||||
|
||||
val invokeInstruction = instruction as Instruction35c
|
||||
if ((invokeInstruction.reference as MethodReference).name != "isPowerSaveMode") continue
|
||||
|
||||
val targetIndex = index + 1
|
||||
|
||||
val targetRegister = (instructions.elementAt(targetIndex) as OneRegisterInstruction).registerA
|
||||
|
||||
it.addInstructions(
|
||||
targetIndex + 1, """
|
||||
invoke-static {v$targetRegister}, $MISC_PATH/PowerSaveModePatch;->bypassPowerSaveModeRestrictions(Z)Z
|
||||
move-result v$targetRegister
|
||||
"""
|
||||
)
|
||||
}
|
||||
} ?: return PowerSaveModeFingerprint.toErrorResult()
|
||||
|
||||
/*
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
arrayOf(
|
||||
"SETTINGS: BYPASS_AMBIENT_MODE_RESTRICTIONS"
|
||||
)
|
||||
)
|
||||
|
||||
SettingsPatch.updatePatchStatus("bypass-ambient-mode-restrictions")
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
}
|
@ -154,6 +154,9 @@ Is it ready to submit?"</string>
|
||||
<string name="revanced_backup_summary">Import ReVanced settings from file or export ReVanced settings to file</string>
|
||||
<string name="revanced_bottom_player">Bottom player</string>
|
||||
<string name="revanced_button_container_title">Button container</string>
|
||||
<string name="revanced_bypass_ambient_mode_restrictions_summary_off">Ambient mode is disabled in battery saver mode</string>
|
||||
<string name="revanced_bypass_ambient_mode_restrictions_summary_on">Ambient mode is enabled in battery saver mode</string>
|
||||
<string name="revanced_bypass_ambient_mode_restrictions_title">Bypass ambient mode restrictions</string>
|
||||
<string name="revanced_comments_title">Comments</string>
|
||||
<string name="revanced_copytimestamp_success">Time Stamp copied to clipboard</string>
|
||||
<string name="revanced_custom_seekbar_color_value_summary">Type the hex code of the seekbar color to use in dark mode</string>
|
||||
|
@ -402,6 +402,9 @@
|
||||
<!-- SETTINGS: ENABLE_MINIMIZED_PLAYBACK
|
||||
<SwitchPreference android:title="@string/revanced_enable_minimized_playback_title" android:key="revanced_enable_minimized_playback" android:defaultValue="true" android:summaryOn="@string/revanced_enable_minimized_playback_summary_on" android:summaryOff="@string/revanced_enable_minimized_playback_summary_off" />SETTINGS: ENABLE_MINIMIZED_PLAYBACK -->
|
||||
|
||||
<!-- SETTINGS: BYPASS_AMBIENT_MODE_RESTRICTIONS
|
||||
<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" />SETTINGS: BYPASS_AMBIENT_MODE_RESTRICTIONS -->
|
||||
|
||||
<!-- 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:defaultValue="2" />SETTINGS: DOUBLE_BACK_TIMEOUT -->
|
||||
|
||||
@ -510,6 +513,7 @@
|
||||
<Preference android:title="enable-external-browser" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="enable-open-links-directly" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="enable-minimized-playback" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="bypass-ambient-mode-restrictions" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="enable-old-layout" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="layout-switch" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
<Preference android:title="force-vp9-codec" android:summary="@string/revanced_patches_excluded" android:selectable="false"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user