feat(YouTube Music): remove Enable sleep timer patch

This commit is contained in:
inotia00 2024-01-23 07:11:55 +09:00
parent 0ef43e4a0b
commit bd05ad0bbb
4 changed files with 23 additions and 69 deletions

View File

@ -1,12 +1,14 @@
package app.revanced.patches.music.flyoutpanel.component package app.revanced.patches.music.flyoutpanel.component
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch import app.revanced.patcher.patch.BytecodePatch
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.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.music.flyoutpanel.component.fingerprints.SleepTimerFingerprint
import app.revanced.patches.music.flyoutpanel.utils.EnumUtils.getEnumIndex import app.revanced.patches.music.flyoutpanel.utils.EnumUtils.getEnumIndex
import app.revanced.patches.music.utils.fingerprints.MenuItemFingerprint import app.revanced.patches.music.utils.fingerprints.MenuItemFingerprint
import app.revanced.patches.music.utils.flyoutbutton.FlyoutButtonContainerPatch import app.revanced.patches.music.utils.flyoutbutton.FlyoutButtonContainerPatch
@ -46,7 +48,10 @@ import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
) )
@Suppress("unused") @Suppress("unused")
object FlyoutPanelPatch : BytecodePatch( object FlyoutPanelPatch : BytecodePatch(
setOf(MenuItemFingerprint) setOf(
MenuItemFingerprint,
SleepTimerFingerprint
)
) { ) {
override fun execute(context: BytecodeContext) { override fun execute(context: BytecodeContext) {
MenuItemFingerprint.result?.let { MenuItemFingerprint.result?.let {
@ -72,6 +77,22 @@ object FlyoutPanelPatch : BytecodePatch(
} }
} ?: throw MenuItemFingerprint.exception } ?: throw MenuItemFingerprint.exception
/**
* Forces sleep timer menu to be enabled.
* This method may be deperated in the future.
*/
SleepTimerFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = implementation!!.instructions.size - 1
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
addInstruction(
insertIndex,
"const/4 v$targetRegister, 0x1"
)
}
}
SettingsPatch.addMusicPreferenceWithoutSummary( SettingsPatch.addMusicPreferenceWithoutSummary(
CategoryType.FLYOUT, CategoryType.FLYOUT,
"revanced_hide_flyout_panel_add_to_queue", "revanced_hide_flyout_panel_add_to_queue",

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.flyoutpanel.sleeptimer.fingerprints package app.revanced.patches.music.flyoutpanel.component.fingerprints
import app.revanced.util.fingerprint.LiteralValueFingerprint import app.revanced.util.fingerprint.LiteralValueFingerprint

View File

@ -1,65 +0,0 @@
package app.revanced.patches.music.flyoutpanel.sleeptimer
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.annotation.CompatiblePackage
import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patches.music.flyoutpanel.sleeptimer.fingerprints.SleepTimerFingerprint
import app.revanced.patches.music.utils.integrations.Constants.FLYOUT
import app.revanced.patches.music.utils.settings.CategoryType
import app.revanced.patches.music.utils.settings.SettingsPatch
import app.revanced.util.exception
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
@Patch(
name = "Enable sleep timer",
description = "Adds an option to add the sleep timer to the flyout menu.",
dependencies = [SettingsPatch::class],
compatiblePackages = [
CompatiblePackage(
"com.google.android.apps.youtube.music",
[
"6.21.52",
"6.22.52",
"6.23.56",
"6.25.53",
"6.26.51",
"6.27.54",
"6.28.53",
"6.29.58",
"6.31.55",
"6.33.52"
]
)
]
)
@Suppress("unused")
object SleepTimerPatch : BytecodePatch(
setOf(SleepTimerFingerprint)
) {
override fun execute(context: BytecodeContext) {
SleepTimerFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = implementation!!.instructions.size - 1
val targetRegister = getInstruction<OneRegisterInstruction>(insertIndex).registerA
addInstructions(
insertIndex, """
invoke-static {}, $FLYOUT->enableSleepTimer()Z
move-result v$targetRegister
"""
)
}
} ?: throw SleepTimerFingerprint.exception
SettingsPatch.addMusicPreference(
CategoryType.FLYOUT,
"revanced_enable_sleep_timer",
"true"
)
}
}

View File

@ -69,8 +69,6 @@ WARNING: Do not enable "New player background" while this is enabled."</string>
<string name="revanced_enable_save_playback_speed_title">Enable save playback speed</string> <string name="revanced_enable_save_playback_speed_title">Enable save playback speed</string>
<string name="revanced_enable_save_video_quality_summary">Remembers the last video quality selected.</string> <string name="revanced_enable_save_video_quality_summary">Remembers the last video quality selected.</string>
<string name="revanced_enable_save_video_quality_title">Enable save video quality</string> <string name="revanced_enable_save_video_quality_title">Enable save video quality</string>
<string name="revanced_enable_sleep_timer_summary">Adds the sleep timer to the flyout menu.</string>
<string name="revanced_enable_sleep_timer_title">Enable sleep timer</string>
<string name="revanced_enable_zen_mode_summary">Changes the player background to light grey to reduce eye strain.</string> <string name="revanced_enable_zen_mode_summary">Changes the player background to light grey to reduce eye strain.</string>
<string name="revanced_enable_zen_mode_title">Enable zen mode</string> <string name="revanced_enable_zen_mode_title">Enable zen mode</string>
<string name="revanced_extended_settings_export_as_file">Export settings to file</string> <string name="revanced_extended_settings_export_as_file">Export settings to file</string>