refactor(music-settings): rebase integrations

This commit is contained in:
inotia00 2023-04-28 11:13:27 +09:00
parent d30aa88904
commit 02682b31ba
41 changed files with 325 additions and 113 deletions

View File

@ -10,10 +10,11 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.misc.litho.patch.MusicLithoFilterPatch import app.revanced.patches.music.misc.litho.patch.MusicLithoFilterPatch
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.patches.shared.patch.videoads.GeneralVideoAdsPatch import app.revanced.patches.shared.patch.videoads.GeneralVideoAdsPatch
import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
@Patch @Patch
@Name("hide-music-ads") @Name("hide-music-ads")
@ -34,11 +35,11 @@ class MusicVideoAdsPatch : BytecodePatch() {
GeneralVideoAdsPatch.injectMainstreamAds(INTEGRATIONS_CLASS_DESCRIPTOR) GeneralVideoAdsPatch.injectMainstreamAds(INTEGRATIONS_CLASS_DESCRIPTOR)
MusicSettingsPatch.addMusicPreference("ads", "revanced_hide_music_ads", "true") MusicSettingsPatch.addMusicPreference(CategoryType.ADS, "revanced_hide_music_ads", "true")
return PatchResultSuccess() return PatchResultSuccess()
} }
private companion object { private companion object {
const val INTEGRATIONS_CLASS_DESCRIPTOR = "$MUSIC_SETTINGS_PATH->hideMusicAds()Z" const val INTEGRATIONS_CLASS_DESCRIPTOR = "$MUSIC_ADS_PATH/HideMusicAdsPatch;->hideMusicAds()Z"
} }
} }

View File

@ -11,10 +11,11 @@ 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.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.patches.shared.fingerprints.SubtitleTrackFingerprint import app.revanced.patches.shared.fingerprints.SubtitleTrackFingerprint
import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_LAYOUT
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch @Patch
@ -36,14 +37,14 @@ class DisableAutoCaptionsPatch : BytecodePatch(
val register = (elementAt(index) as OneRegisterInstruction).registerA val register = (elementAt(index) as OneRegisterInstruction).registerA
it.addInstructions( it.addInstructions(
index, """ index, """
invoke-static {v$register}, $MUSIC_SETTINGS_PATH->disableAutoCaptions(Z)Z invoke-static {v$register}, $MUSIC_LAYOUT->disableAutoCaptions(Z)Z
move-result v$register move-result v$register
""" """
) )
} }
} ?: return SubtitleTrackFingerprint.toErrorResult() } ?: return SubtitleTrackFingerprint.toErrorResult()
MusicSettingsPatch.addMusicPreference("design", "revanced_disable_auto_captions", "false") MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_disable_auto_captions", "false")
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -15,9 +15,10 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.music.layout.blacknavbar.fingerprints.TabLayoutFingerprint import app.revanced.patches.music.layout.blacknavbar.fingerprints.TabLayoutFingerprint
import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_LAYOUT
import org.jf.dexlib2.iface.instruction.formats.Instruction11x import org.jf.dexlib2.iface.instruction.formats.Instruction11x
import org.jf.dexlib2.iface.instruction.formats.Instruction31i import org.jf.dexlib2.iface.instruction.formats.Instruction31i
@ -50,7 +51,7 @@ class BlackNavbarPatch : BytecodePatch(
addInstructions( addInstructions(
insertIndex, """ insertIndex, """
invoke-static {}, $MUSIC_SETTINGS_PATH->enableBlackNavbar()Z invoke-static {}, $MUSIC_LAYOUT->enableBlackNavbar()Z
move-result v$dummyRegister move-result v$dummyRegister
if-eqz v$dummyRegister, :default if-eqz v$dummyRegister, :default
const/high16 v$targetRegister, -0x1000000 const/high16 v$targetRegister, -0x1000000
@ -59,7 +60,7 @@ class BlackNavbarPatch : BytecodePatch(
} }
} ?: return TabLayoutFingerprint.toErrorResult() } ?: return TabLayoutFingerprint.toErrorResult()
MusicSettingsPatch.addMusicPreference("design", "revanced_enable_black_navbar", "true") MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_black_navbar", "true")
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -14,10 +14,10 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.castbutton.fingerprints.HideCastButtonFingerprint import app.revanced.patches.music.layout.castbutton.fingerprints.HideCastButtonFingerprint
import app.revanced.patches.music.layout.castbutton.fingerprints.HideCastButtonParentFingerprint import app.revanced.patches.music.layout.castbutton.fingerprints.HideCastButtonParentFingerprint
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_LAYOUT
@Patch @Patch
@Name("hide-music-cast-button") @Name("hide-music-cast-button")
@Description("Hides the cast button in the video player and header.") @Description("Hides the cast button in the video player and header.")
@ -34,13 +34,13 @@ class HideCastButtonPatch : BytecodePatch(
HideCastButtonParentFingerprint.result?.let { parentResult -> HideCastButtonParentFingerprint.result?.let { parentResult ->
HideCastButtonFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstructions( HideCastButtonFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.addInstructions(
0, """ 0, """
invoke-static {p1}, $MUSIC_SETTINGS_PATH->hideCastButton(I)I invoke-static {p1}, $MUSIC_LAYOUT->hideCastButton(I)I
move-result p1 move-result p1
""" """
) ?: return HideCastButtonFingerprint.toErrorResult() ) ?: return HideCastButtonFingerprint.toErrorResult()
} ?: return HideCastButtonParentFingerprint.toErrorResult() } ?: return HideCastButtonParentFingerprint.toErrorResult()
MusicSettingsPatch.addMusicPreference("navigation", "revanced_hide_cast_button", "true") MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_hide_cast_button", "true")
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -15,9 +15,10 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.music.layout.compactdialog.fingerprints.DialogSolidFingerprint import app.revanced.patches.music.layout.compactdialog.fingerprints.DialogSolidFingerprint
import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_LAYOUT
@Patch @Patch
@Name("enable-compact-dialog") @Name("enable-compact-dialog")
@ -44,14 +45,14 @@ class CompactDialogPatch : BytecodePatch(
) { ) {
addInstructions( addInstructions(
2, """ 2, """
invoke-static {p0}, $MUSIC_SETTINGS_PATH->enableCompactDialog(I)I invoke-static {p0}, $MUSIC_LAYOUT->enableCompactDialog(I)I
move-result p0 move-result p0
""" """
) )
} }
} ?: return DialogSolidFingerprint.toErrorResult() } ?: return DialogSolidFingerprint.toErrorResult()
MusicSettingsPatch.addMusicPreference("navigation", "revanced_enable_compact_dialog", "true") MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_compact_dialog", "true")
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -16,9 +16,10 @@ import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.music.layout.floatingbutton.fingerprints.* import app.revanced.patches.music.layout.floatingbutton.fingerprints.*
import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_LAYOUT
@Patch @Patch
@Name("hide-new-playlist") @Name("hide-new-playlist")
@ -42,7 +43,7 @@ class NewPlaylistButtonPatch : BytecodePatch(
FloatingButtonFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let { FloatingButtonFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.mutableMethod?.let {
it.addInstructions( it.addInstructions(
1, """ 1, """
invoke-static {}, $MUSIC_SETTINGS_PATH->hideNewPlaylistButton()Z invoke-static {}, $MUSIC_LAYOUT->hideNewPlaylistButton()Z
move-result v0 move-result v0
if-eqz v0, :show if-eqz v0, :show
return-void return-void
@ -51,7 +52,7 @@ class NewPlaylistButtonPatch : BytecodePatch(
} ?: return FloatingButtonFingerprint.toErrorResult() } ?: return FloatingButtonFingerprint.toErrorResult()
} ?: return FloatingButtonParentFingerprint.toErrorResult() } ?: return FloatingButtonParentFingerprint.toErrorResult()
MusicSettingsPatch.addMusicPreference("navigation", "revanced_hide_new_playlist_button", "false") MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_hide_new_playlist_button", "false")
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -12,9 +12,10 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.minimizedplayer.fingerprints.MinimizedPlayerFingerprint import app.revanced.patches.music.layout.minimizedplayer.fingerprints.MinimizedPlayerFingerprint
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_LAYOUT
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Patch @Patch
@ -37,14 +38,14 @@ class MinimizedPlayerPatch : BytecodePatch(
addInstructions( addInstructions(
index, """ index, """
invoke-static {v$register}, $MUSIC_SETTINGS_PATH->enableForceMinimizedPlayer(Z)Z invoke-static {v$register}, $MUSIC_LAYOUT->enableForceMinimizedPlayer(Z)Z
move-result v$register move-result v$register
""" """
) )
} }
} ?: return MinimizedPlayerFingerprint.toErrorResult() } ?: return MinimizedPlayerFingerprint.toErrorResult()
MusicSettingsPatch.addMusicPreference("listening", "revanced_enable_force_minimized_player", "true") MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_force_minimized_player", "true")
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -15,10 +15,11 @@ import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.music.layout.miniplayercolor.fingerprints.MiniplayerColorFingerprint import app.revanced.patches.music.layout.miniplayercolor.fingerprints.MiniplayerColorFingerprint
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.patches.shared.fingerprints.MiniplayerColorParentFingerprint import app.revanced.patches.shared.fingerprints.MiniplayerColorParentFingerprint
import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_LAYOUT
import org.jf.dexlib2.iface.instruction.Instruction import org.jf.dexlib2.iface.instruction.Instruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.FieldReference import org.jf.dexlib2.iface.reference.FieldReference
@ -68,7 +69,7 @@ class MiniplayerColorPatch : BytecodePatch(
addInstructions( addInstructions(
insertIndex, """ insertIndex, """
invoke-static {}, $MUSIC_SETTINGS_PATH->enableColorMatchPlayer()Z invoke-static {}, $MUSIC_LAYOUT->enableColorMatchPlayer()Z
move-result v2 move-result v2
if-eqz v2, :off if-eqz v2, :off
iget v0, p0, ${type}->${firstReference.name}:${firstReference.type} iget v0, p0, ${type}->${firstReference.name}:${firstReference.type}
@ -92,7 +93,7 @@ class MiniplayerColorPatch : BytecodePatch(
} ?: return MiniplayerColorFingerprint.toErrorResult() } ?: return MiniplayerColorFingerprint.toErrorResult()
} ?: return MiniplayerColorParentFingerprint.toErrorResult() } ?: return MiniplayerColorParentFingerprint.toErrorResult()
MusicSettingsPatch.addMusicPreference("design", "revanced_enable_color_match_player", "true") MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_color_match_player", "true")
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -10,8 +10,9 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.misc.litho.patch.MusicLithoFilterPatch import app.revanced.patches.music.misc.litho.patch.MusicLithoFilterPatch
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.enum.CategoryType
@Patch @Patch
@Name("hide-playlist-card") @Name("hide-playlist-card")
@ -27,7 +28,7 @@ import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
class HidePlaylistCardPatch : BytecodePatch() { class HidePlaylistCardPatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
MusicSettingsPatch.addMusicPreference("navigation", "revanced_hide_playlist_card", "true") MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_hide_playlist_card", "false")
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -13,10 +13,11 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.zenmode.fingerprints.ZenModeFingerprint import app.revanced.patches.music.layout.zenmode.fingerprints.ZenModeFingerprint
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.patches.shared.fingerprints.MiniplayerColorParentFingerprint import app.revanced.patches.shared.fingerprints.MiniplayerColorParentFingerprint
import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_LAYOUT
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction
import org.jf.dexlib2.iface.reference.FieldReference import org.jf.dexlib2.iface.reference.FieldReference
@ -51,7 +52,7 @@ class ZenModePatch : BytecodePatch(
addInstructions( addInstructions(
insertIndex, """ insertIndex, """
invoke-static {}, $MUSIC_SETTINGS_PATH->enableZenMode()Z invoke-static {}, $MUSIC_LAYOUT->enableZenMode()Z
move-result v$dummyRegister move-result v$dummyRegister
if-eqz v$dummyRegister, :off if-eqz v$dummyRegister, :off
const v$dummyRegister, -0xfcfcfd const v$dummyRegister, -0xfcfcfd
@ -67,7 +68,7 @@ class ZenModePatch : BytecodePatch(
} ?: return ZenModeFingerprint.toErrorResult() } ?: return ZenModeFingerprint.toErrorResult()
} ?: return MiniplayerColorParentFingerprint.toErrorResult() } ?: return MiniplayerColorParentFingerprint.toErrorResult()
MusicSettingsPatch.addMusicPreference("design", "revanced_enable_zen_mode", "false") MusicSettingsPatch.addMusicPreference(CategoryType.LAYOUT, "revanced_enable_zen_mode", "false")
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.audio.codecs.fingerprints package app.revanced.patches.music.misc.codecs.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

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.audio.codecs.fingerprints package app.revanced.patches.music.misc.codecs.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

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.audio.codecs.fingerprints package app.revanced.patches.music.misc.codecs.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

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.audio.codecs.patch package app.revanced.patches.music.misc.codecs.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
@ -15,10 +15,11 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.music.audio.codecs.fingerprints.* import app.revanced.patches.music.misc.codecs.fingerprints.*
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH
import org.jf.dexlib2.iface.Method import org.jf.dexlib2.iface.Method
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@ -38,7 +39,7 @@ class CodecsUnlockPatch : BytecodePatch(
AllCodecsParentFingerprint.result?.let { parentResult -> AllCodecsParentFingerprint.result?.let { parentResult ->
AllCodecsFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { result -> AllCodecsFingerprint.also { it.resolve(context, parentResult.classDef) }.result?.let { result ->
allCodecsMethod = allCodecsMethod =
context.toMethodWalker(result.method) context.toMethodWalker(result.method)
.nextMethod(result.scanResult.patternScanResult!!.endIndex) .nextMethod(result.scanResult.patternScanResult!!.endIndex)
.getMethod() .getMethod()
@ -53,7 +54,7 @@ class CodecsUnlockPatch : BytecodePatch(
val register = (instruction(endIndex) as OneRegisterInstruction).registerA val register = (instruction(endIndex) as OneRegisterInstruction).registerA
addInstructions( addInstructions(
endIndex + 1, """ endIndex + 1, """
invoke-static {}, $MUSIC_SETTINGS_PATH->enableOpusCodec()Z invoke-static {}, $MUSIC_MISC_PATH/OpusCodecPatch;->enableOpusCodec()Z
move-result v7 move-result v7
if-eqz v7, :mp4a if-eqz v7, :mp4a
invoke-static {}, ${allCodecsMethod.definingClass}->${allCodecsMethod.name}()Ljava/util/Set; invoke-static {}, ${allCodecsMethod.definingClass}->${allCodecsMethod.name}()Ljava/util/Set;
@ -63,7 +64,7 @@ class CodecsUnlockPatch : BytecodePatch(
} }
} ?: return CodecsLockFingerprint.toErrorResult() } ?: return CodecsLockFingerprint.toErrorResult()
MusicSettingsPatch.addMusicPreference("listening", "revanced_enable_opus_codec", "true") MusicSettingsPatch.addMusicPreference(CategoryType.MISC, "revanced_enable_opus_codec", "true")
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.audio.exclusiveaudio.fingerprints package app.revanced.patches.music.misc.exclusiveaudio.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

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.audio.exclusiveaudio.patch package app.revanced.patches.music.misc.exclusiveaudio.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
@ -11,7 +11,7 @@ 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.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.audio.exclusiveaudio.fingerprints.AudioOnlyEnablerFingerprint import app.revanced.patches.music.misc.exclusiveaudio.fingerprints.AudioOnlyEnablerFingerprint
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
@Patch @Patch

View File

@ -5,10 +5,12 @@ import app.revanced.patcher.patch.annotations.RequiresIntegrations
import app.revanced.patches.music.misc.integrations.fingerprints.InitFingerprint import app.revanced.patches.music.misc.integrations.fingerprints.InitFingerprint
import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.integrations.Constants.MUSIC_INTEGRATIONS_PATH
@Name("music-integrations") @Name("music-integrations")
@YouTubeMusicCompatibility @YouTubeMusicCompatibility
@RequiresIntegrations @RequiresIntegrations
class MusicIntegrationsPatch : AbstractIntegrationsPatch( class MusicIntegrationsPatch : AbstractIntegrationsPatch(
"$MUSIC_INTEGRATIONS_PATH/utils/ReVancedUtils;",
listOf(InitFingerprint), listOf(InitFingerprint),
) )

View File

@ -11,7 +11,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.smali.ExternalLabel import app.revanced.patcher.util.smali.ExternalLabel
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.patches.shared.fingerprints.LithoFingerprint import app.revanced.patches.shared.fingerprints.LithoFingerprint
import app.revanced.util.integrations.Constants.ADS_PATH import app.revanced.util.integrations.Constants.MUSIC_ADS_PATH
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode
import org.jf.dexlib2.builder.instruction.BuilderInstruction21c import org.jf.dexlib2.builder.instruction.BuilderInstruction21c
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@ -60,7 +60,7 @@ class MusicLithoFilterPatch : BytecodePatch(
method.addInstructions( method.addInstructions(
insertIndex, // right after setting the component.pathBuilder field, insertIndex, // right after setting the component.pathBuilder field,
""" """
invoke-static {v$stringBuilderRegister, v$identifierRegister}, $ADS_PATH/MusicLithoFilterPatch;->filter(Ljava/lang/StringBuilder;Ljava/lang/String;)Z invoke-static {v$stringBuilderRegister, v$identifierRegister}, $MUSIC_ADS_PATH/MusicLithoFilterPatch;->filter(Ljava/lang/StringBuilder;Ljava/lang/String;)Z
move-result v$bufferRegister move-result v$bufferRegister
if-eqz v$bufferRegister, :not_an_ad if-eqz v$bufferRegister, :not_an_ad
move-object/from16 v$identifierRegister, p1 move-object/from16 v$identifierRegister, p1

View File

@ -9,7 +9,6 @@ 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.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.misc.clientspoof.patch.ClientSpoofMusicPatch
import app.revanced.patches.music.misc.microg.bytecode.fingerprints.* import app.revanced.patches.music.misc.microg.bytecode.fingerprints.*
import app.revanced.patches.music.misc.microg.resource.patch.MusicMicroGResourcePatch import app.revanced.patches.music.misc.microg.resource.patch.MusicMicroGResourcePatch
import app.revanced.patches.music.misc.microg.shared.Constants.MUSIC_PACKAGE_NAME import app.revanced.patches.music.misc.microg.shared.Constants.MUSIC_PACKAGE_NAME
@ -21,7 +20,6 @@ import app.revanced.util.microg.MicroGBytecodeHelper
@Patch @Patch
@DependsOn( @DependsOn(
[ [
ClientSpoofMusicPatch::class,
MusicMicroGResourcePatch::class, MusicMicroGResourcePatch::class,
PatchOptions::class PatchOptions::class
] ]

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.layout.minimizedplayback.fingerprints package app.revanced.patches.music.misc.minimizedplayback.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

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.layout.minimizedplayback.patch package app.revanced.patches.music.misc.minimizedplayback.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
@ -10,7 +10,7 @@ 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.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint import app.revanced.patches.music.misc.minimizedplayback.fingerprints.MinimizedPlaybackManagerFingerprint
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
@Patch @Patch

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.layout.premium.fingerprints package app.revanced.patches.music.misc.premium.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

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.layout.premium.patch package app.revanced.patches.music.misc.premium.patch
import app.revanced.extensions.findMutableMethodOf import app.revanced.extensions.findMutableMethodOf
import app.revanced.extensions.toErrorResult import app.revanced.extensions.toErrorResult
@ -14,7 +14,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.music.layout.premium.fingerprints.HideGetPremiumFingerprint import app.revanced.patches.music.misc.premium.fingerprints.HideGetPremiumFingerprint
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch import app.revanced.patches.shared.patch.mapping.ResourceMappingPatch
import org.jf.dexlib2.Opcode import org.jf.dexlib2.Opcode

View File

@ -0,0 +1,23 @@
package app.revanced.patches.music.misc.settings.bytecode.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object PreferenceFingerprint : MethodFingerprint(
returnType = "V",
parameters = listOf("Z"),
opcodes = listOf(
Opcode.RETURN_VOID,
Opcode.XOR_INT_LIT8,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT,
Opcode.IF_NE,
Opcode.RETURN_VOID,
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT,
Opcode.IGET_OBJECT,
Opcode.INVOKE_INTERFACE
),
customFingerprint = { it.definingClass == "Landroidx/preference/Preference;" }
)

View File

@ -0,0 +1,16 @@
package app.revanced.patches.music.misc.settings.bytecode.fingerprints
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import org.jf.dexlib2.Opcode
object SettingsHeadersFragmentFingerprint : MethodFingerprint(
returnType = "V",
parameters = listOf("L"),
opcodes = listOf(
Opcode.IGET_OBJECT,
Opcode.INVOKE_VIRTUAL,
Opcode.MOVE_RESULT_OBJECT
),
customFingerprint = { it.definingClass.endsWith("/SettingsHeadersFragment;") && it.name == "onCreate" }
)

View File

@ -0,0 +1,61 @@
package app.revanced.patches.music.misc.settings.bytecode.patch
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.instruction
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.patches.music.misc.integrations.patch.MusicIntegrationsPatch
import app.revanced.patches.music.misc.settings.bytecode.fingerprints.*
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.integrations.Constants.MUSIC_INTEGRATIONS_PATH
import org.jf.dexlib2.iface.instruction.FiveRegisterInstruction
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Name("music-settings-bytecode-patch")
@DependsOn([MusicIntegrationsPatch::class])
@YouTubeMusicCompatibility
@Version("0.0.1")
class MusicSettingsBytecodePatch : BytecodePatch(
listOf(
PreferenceFingerprint,
SettingsHeadersFragmentFingerprint
)
) {
override fun execute(context: BytecodeContext): PatchResult {
SettingsHeadersFragmentFingerprint.result?.let {
with(it.mutableMethod) {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
val targetRegister = (instruction(targetIndex) as OneRegisterInstruction).registerA
addInstruction(
targetIndex + 1,
"invoke-static {v$targetRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->setActivity(Ljava/lang/Object;)V"
)
}
} ?: return SettingsHeadersFragmentFingerprint.toErrorResult()
PreferenceFingerprint.result?.let {
with(it.mutableMethod) {
val targetIndex = it.scanResult.patternScanResult!!.endIndex
val keyRegister = (instruction(targetIndex) as FiveRegisterInstruction).registerD
val valueRegister = (instruction(targetIndex) as FiveRegisterInstruction).registerE
addInstruction(
targetIndex,
"invoke-static {v$keyRegister, v$valueRegister}, $INTEGRATIONS_CLASS_DESCRIPTOR->onPreferenceChanged(Ljava/lang/String;Z)V"
)
}
} ?: return PreferenceFingerprint.toErrorResult()
return PatchResultSuccess()
}
companion object {
const val INTEGRATIONS_CLASS_DESCRIPTOR =
"$MUSIC_INTEGRATIONS_PATH/settingsmenu/SharedPreferenceChangeListener;"
}
}

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.misc.settings.patch package app.revanced.patches.music.misc.settings.resource.patch
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name import app.revanced.patcher.annotation.Name
@ -7,18 +7,22 @@ import app.revanced.patcher.data.ResourceContext
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.patches.music.misc.integrations.patch.MusicIntegrationsPatch import app.revanced.patches.music.misc.settings.bytecode.patch.MusicSettingsBytecodePatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.patches.shared.patch.settings.AbstractSettingsResourcePatch import app.revanced.patches.shared.patch.settings.AbstractSettingsResourcePatch
import app.revanced.util.enum.CategoryType
import app.revanced.util.enum.CategoryType.*
import app.revanced.util.resources.MusicResourceHelper.addMusicPreference import app.revanced.util.resources.MusicResourceHelper.addMusicPreference
import app.revanced.util.resources.MusicResourceHelper.addMusicPreferenceAlt
import app.revanced.util.resources.MusicResourceHelper.addMusicPreferenceCategory import app.revanced.util.resources.MusicResourceHelper.addMusicPreferenceCategory
import app.revanced.util.resources.MusicResourceHelper.addMusicPreferenceWithIntent
import app.revanced.util.resources.MusicResourceHelper.addReVancedMusicPreference import app.revanced.util.resources.MusicResourceHelper.addReVancedMusicPreference
import app.revanced.util.resources.MusicResourceHelper.sortMusicPreferenceCategory import app.revanced.util.resources.MusicResourceHelper.sortMusicPreferenceCategory
import org.w3c.dom.Element import org.w3c.dom.Element
@Name("music-settings") @Name("music-settings")
@Description("Adds settings for ReVanced to YouTube Music.") @Description("Adds settings for ReVanced to YouTube Music.")
@DependsOn([MusicIntegrationsPatch::class]) @DependsOn([MusicSettingsBytecodePatch::class])
@YouTubeMusicCompatibility @YouTubeMusicCompatibility
@Version("0.0.1") @Version("0.0.1")
class MusicSettingsPatch : AbstractSettingsResourcePatch( class MusicSettingsPatch : AbstractSettingsResourcePatch(
@ -56,13 +60,39 @@ class MusicSettingsPatch : AbstractSettingsResourcePatch(
private lateinit var contexts: ResourceContext private lateinit var contexts: ResourceContext
internal fun addMusicPreference( internal fun addMusicPreference(
category: String, category: CategoryType,
key: String, key: String,
defaultValue: String defaultValue: String
) { ) {
contexts.addMusicPreferenceCategory(category) val categoryValue = category.value
contexts.sortMusicPreferenceCategory() contexts.addMusicPreferenceCategory(categoryValue)
contexts.addMusicPreference(category, key, defaultValue) contexts.addMusicPreference(categoryValue, key, defaultValue)
contexts.sortMusicPreferenceCategory(categoryValue)
}
internal fun addMusicPreferenceAlt(
category: CategoryType,
key: String,
defaultValue: String,
dependencyKey: String
) {
val categoryValue = category.value
contexts.addMusicPreferenceCategory(categoryValue)
contexts.addMusicPreferenceAlt(categoryValue, key, defaultValue, dependencyKey)
contexts.sortMusicPreferenceCategory(categoryValue)
}
internal fun addMusicPreferenceWithIntent(
category: CategoryType,
key: String,
dependencyKey: String
) {
val categoryValue = category.value
contexts.addMusicPreferenceCategory(categoryValue)
contexts.addMusicPreferenceWithIntent(categoryValue, key, dependencyKey)
contexts.sortMusicPreferenceCategory(categoryValue)
} }
} }
} }

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.layout.shuffle.fingerprints package app.revanced.patches.music.misc.shuffle.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

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.layout.shuffle.fingerprints package app.revanced.patches.music.misc.shuffle.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

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.layout.shuffle.fingerprints package app.revanced.patches.music.misc.shuffle.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

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.layout.shuffle.patch package app.revanced.patches.music.misc.shuffle.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.toErrorResult
import app.revanced.extensions.transformFields import app.revanced.extensions.transformFields
@ -16,13 +16,12 @@ import app.revanced.patcher.util.TypeUtil.traverseClassHierarchy
import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable import app.revanced.patcher.util.proxy.mutableTypes.MutableField.Companion.toMutable
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod.Companion.toMutable
import app.revanced.patcher.util.smali.toInstructions import app.revanced.patcher.util.smali.toInstructions
import app.revanced.patches.music.layout.shuffle.fingerprints.MusicPlaybackControlsFingerprint
import app.revanced.patches.music.layout.shuffle.fingerprints.ShuffleClassFingerprint
import app.revanced.patches.music.layout.shuffle.fingerprints.ShuffleClassReferenceFingerprint
import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch import app.revanced.patches.music.misc.resourceid.patch.SharedResourceIdPatch
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.music.misc.shuffle.fingerprints.*
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH
import org.jf.dexlib2.AccessFlags import org.jf.dexlib2.AccessFlags
import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference import org.jf.dexlib2.dexbacked.reference.DexBackedMethodReference
import org.jf.dexlib2.iface.instruction.ReferenceInstruction import org.jf.dexlib2.iface.instruction.ReferenceInstruction
@ -132,7 +131,7 @@ class EnforceShufflePatch : BytecodePatch(
null, null,
ImmutableMethodImplementation( ImmutableMethodImplementation(
5, """ 5, """
invoke-static {}, $MUSIC_SETTINGS_PATH->enableForceShuffle()Z invoke-static {}, $MUSIC_MISC_PATH/ForceShufflePatch;->enableForceShuffle()Z
move-result v0 move-result v0
if-eqz v0, :cond_0 if-eqz v0, :cond_0
new-instance v0, $SHUFFLE_CLASS new-instance v0, $SHUFFLE_CLASS
@ -158,7 +157,7 @@ class EnforceShufflePatch : BytecodePatch(
) )
} ?: return MusicPlaybackControlsFingerprint.toErrorResult() } ?: return MusicPlaybackControlsFingerprint.toErrorResult()
MusicSettingsPatch.addMusicPreference("listening", "revanced_enable_force_shuffle", "true") MusicSettingsPatch.addMusicPreference(CategoryType.MISC, "revanced_enable_force_shuffle", "true")
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.layout.tastebuilder.fingerprints package app.revanced.patches.music.misc.tastebuilder.fingerprints
import app.revanced.patcher.extensions.or import app.revanced.patcher.extensions.or
import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod import app.revanced.patcher.fingerprint.method.annotation.FuzzyPatternScanMethod

View File

@ -1,4 +1,4 @@
package app.revanced.patches.music.layout.tastebuilder.patch package app.revanced.patches.music.misc.tastebuilder.patch
import app.revanced.extensions.toErrorResult import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
@ -10,7 +10,7 @@ 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.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.layout.tastebuilder.fingerprints.TasteBuilderConstructorFingerprint import app.revanced.patches.music.misc.tastebuilder.fingerprints.TasteBuilderConstructorFingerprint
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import org.jf.dexlib2.iface.instruction.formats.Instruction22c import org.jf.dexlib2.iface.instruction.formats.Instruction22c
@ -33,7 +33,7 @@ class RemoveTasteBuilderPatch : BytecodePatch(
addInstructions( addInstructions(
insertIndex, """ insertIndex, """
const/16 v1, 0x8 const/16 v1, 0x8
invoke-virtual {v${register}, v1}, Landroid/view/View;->setVisibility(I)V invoke-virtual {v$register, v1}, Landroid/view/View;->setVisibility(I)V
""" """
) )
} }

View File

@ -9,7 +9,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.resources.ResourceHelper.addTranslations import app.revanced.util.resources.ResourceHelper.addTranslations

View File

@ -9,10 +9,11 @@ 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.patch.annotations.Patch import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patches.music.misc.settings.patch.MusicSettingsPatch import app.revanced.patches.music.misc.settings.resource.patch.MusicSettingsPatch
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.patches.shared.patch.versionspoof.GeneralVersionSpoofPatch import app.revanced.patches.shared.patch.versionspoof.GeneralVersionSpoofPatch
import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH import app.revanced.util.enum.CategoryType
import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH
@Patch @Patch
@Name("spoof-version") @Name("spoof-version")
@ -28,9 +29,9 @@ import app.revanced.util.integrations.Constants.MUSIC_SETTINGS_PATH
class SpoofAppVersionPatch : BytecodePatch() { class SpoofAppVersionPatch : BytecodePatch() {
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
GeneralVersionSpoofPatch.injectSpoof("$MUSIC_SETTINGS_PATH->spoofVersion(Ljava/lang/String;)Ljava/lang/String;") GeneralVersionSpoofPatch.injectSpoof("$MUSIC_MISC_PATH/SpoofAppVersionPatch;->getVersionOverride(Ljava/lang/String;)Ljava/lang/String;")
MusicSettingsPatch.addMusicPreference("navigation", "revanced_enable_spoof_version", "false") MusicSettingsPatch.addMusicPreference(CategoryType.MISC, "revanced_spoof_app_version", "false")
return PatchResultSuccess() return PatchResultSuccess()
} }

View File

@ -12,7 +12,7 @@ import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod import app.revanced.patcher.util.proxy.mutableTypes.MutableMethod
import app.revanced.patches.music.misc.videoid.fingerprint.MusicVideoIdFingerprint import app.revanced.patches.music.misc.videoid.fingerprint.MusicVideoIdFingerprint
import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility import app.revanced.patches.shared.annotation.YouTubeMusicCompatibility
import app.revanced.util.integrations.Constants.VIDEO_PATH import app.revanced.util.integrations.Constants.MUSIC_UTILS_PATH
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction import org.jf.dexlib2.iface.instruction.OneRegisterInstruction
@Name("music-video-id-hook") @Name("music-video-id-hook")
@ -42,7 +42,7 @@ class MusicVideoIdPatch : BytecodePatch(
} }
companion object { companion object {
const val INTEGRATIONS_CLASS_DESCRIPTOR = "$VIDEO_PATH/VideoInformation;" const val INTEGRATIONS_CLASS_DESCRIPTOR = "$MUSIC_UTILS_PATH/VideoInformation;"
private var offset = 0 private var offset = 0

View File

@ -1,5 +1,6 @@
package app.revanced.patches.shared.patch.integrations package app.revanced.patches.shared.patch.integrations
import app.revanced.extensions.toErrorResult
import app.revanced.patcher.annotation.Description import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Version import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.BytecodeContext import app.revanced.patcher.data.BytecodeContext
@ -9,13 +10,13 @@ import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultError import app.revanced.patcher.patch.PatchResultError
import app.revanced.patcher.patch.PatchResultSuccess import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.extensions.toErrorResult import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch.IntegrationsFingerprint.RegisterResolver
import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH
import org.jf.dexlib2.iface.Method import org.jf.dexlib2.iface.Method
@Description("Applies mandatory patches to implement the ReVanced integrations into the application.") @Description("Applies mandatory patches to implement the ReVanced integrations into the application.")
@Version("0.0.1") @Version("0.0.1")
abstract class AbstractIntegrationsPatch( abstract class AbstractIntegrationsPatch(
private val integrationsDescriptor: String,
private val hooks: Iterable<IntegrationsFingerprint> private val hooks: Iterable<IntegrationsFingerprint>
) : BytecodePatch(hooks) { ) : BytecodePatch(hooks) {
/** /**
@ -29,14 +30,15 @@ abstract class AbstractIntegrationsPatch(
customFingerprint: ((methodDef: Method) -> Boolean)? = null, customFingerprint: ((methodDef: Method) -> Boolean)? = null,
private val contextRegisterResolver: (Method) -> Int = object : RegisterResolver {} private val contextRegisterResolver: (Method) -> Int = object : RegisterResolver {}
) : MethodFingerprint(strings = strings, customFingerprint = customFingerprint) { ) : MethodFingerprint(strings = strings, customFingerprint = customFingerprint) {
fun invoke(): PatchResult {
fun invoke(integrationsDescriptor: String): PatchResult {
result?.mutableMethod?.let { method -> result?.mutableMethod?.let { method ->
val contextRegister = contextRegisterResolver(method) val contextRegister = contextRegisterResolver(method)
method.addInstruction( method.addInstruction(
0, 0,
"sput-object v$contextRegister, " + "sput-object v$contextRegister, " +
"$INTEGRATIONS_CLASS_DESCRIPTOR->context:Landroid/content/Context;" "$integrationsDescriptor->context:Landroid/content/Context;"
) )
} ?: return toErrorResult() } ?: return toErrorResult()
return PatchResultSuccess() return PatchResultSuccess()
@ -48,9 +50,9 @@ abstract class AbstractIntegrationsPatch(
} }
override fun execute(context: BytecodeContext): PatchResult { override fun execute(context: BytecodeContext): PatchResult {
if (context.findClass(INTEGRATIONS_CLASS_DESCRIPTOR) == null) return MISSING_INTEGRATIONS if (context.findClass(integrationsDescriptor) == null) return MISSING_INTEGRATIONS
for (hook in hooks) hook.invoke().let { for (hook in hooks) hook.invoke(integrationsDescriptor).let {
if (it is PatchResultError) return it if (it is PatchResultError) return it
} }
@ -58,8 +60,6 @@ abstract class AbstractIntegrationsPatch(
} }
private companion object { private companion object {
const val INTEGRATIONS_CLASS_DESCRIPTOR =
"$INTEGRATIONS_PATH/utils/ReVancedUtils;"
val MISSING_INTEGRATIONS = PatchResultError( val MISSING_INTEGRATIONS = PatchResultError(
"Integrations have not been merged yet. " + "Integrations have not been merged yet. " +
"This patch can not succeed without merging the integrations." "This patch can not succeed without merging the integrations."

View File

@ -5,10 +5,12 @@ import app.revanced.patcher.patch.annotations.RequiresIntegrations
import app.revanced.patches.shared.annotation.YouTubeCompatibility import app.revanced.patches.shared.annotation.YouTubeCompatibility
import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch import app.revanced.patches.shared.patch.integrations.AbstractIntegrationsPatch
import app.revanced.patches.youtube.misc.integrations.fingerprints.* import app.revanced.patches.youtube.misc.integrations.fingerprints.*
import app.revanced.util.integrations.Constants.INTEGRATIONS_PATH
@Name("integrations") @Name("integrations")
@YouTubeCompatibility @YouTubeCompatibility
@RequiresIntegrations @RequiresIntegrations
class IntegrationsPatch : AbstractIntegrationsPatch( class IntegrationsPatch : AbstractIntegrationsPatch(
"$INTEGRATIONS_PATH/utils/ReVancedUtils;",
listOf(InitFingerprint, StandalonePlayerFingerprint, ServiceFingerprint), listOf(InitFingerprint, StandalonePlayerFingerprint, ServiceFingerprint),
) )

View File

@ -0,0 +1,7 @@
package app.revanced.util.enum
internal enum class CategoryType(val value: String) {
ADS("ads"),
LAYOUT("layout"),
MISC("misc")
}

View File

@ -5,9 +5,7 @@ internal object Constants {
const val PATCHES_PATH = "$INTEGRATIONS_PATH/patches" const val PATCHES_PATH = "$INTEGRATIONS_PATH/patches"
const val ADS_PATH = "$PATCHES_PATH/ads" const val ADS_PATH = "$PATCHES_PATH/ads"
const val SWIPE_PATH = "$PATCHES_PATH/swipe" const val SWIPE_PATH = "$PATCHES_PATH/swipe"
const val BOTTOM_PLAYER = "$PATCHES_PATH/layout/BottomPlayerPatch;" const val BOTTOM_PLAYER = "$PATCHES_PATH/layout/BottomPlayerPatch;"
const val FLYOUT_PANEL = "$PATCHES_PATH/layout/FlyoutPanelPatch;" const val FLYOUT_PANEL = "$PATCHES_PATH/layout/FlyoutPanelPatch;"
const val FULLSCREEN = "$PATCHES_PATH/layout/FullscreenPatch;" const val FULLSCREEN = "$PATCHES_PATH/layout/FullscreenPatch;"
@ -16,15 +14,16 @@ internal object Constants {
const val PLAYER = "$PATCHES_PATH/layout/PlayerPatch;" const val PLAYER = "$PATCHES_PATH/layout/PlayerPatch;"
const val SEEKBAR = "$PATCHES_PATH/layout/SeekBarPatch;" const val SEEKBAR = "$PATCHES_PATH/layout/SeekBarPatch;"
const val SHORTS = "$PATCHES_PATH/layout/ShortsPatch;" const val SHORTS = "$PATCHES_PATH/layout/ShortsPatch;"
const val MISC_PATH = "$PATCHES_PATH/misc" const val MISC_PATH = "$PATCHES_PATH/misc"
const val MUSIC_PATH = "$PATCHES_PATH/music"
const val BUTTON_PATH = "$PATCHES_PATH/button" const val BUTTON_PATH = "$PATCHES_PATH/button"
const val VIDEO_PATH = "$PATCHES_PATH/video" const val VIDEO_PATH = "$PATCHES_PATH/video"
const val UTILS_PATH = "$PATCHES_PATH/utils" const val UTILS_PATH = "$PATCHES_PATH/utils"
const val MUSIC_SETTINGS_PATH = "$INTEGRATIONS_PATH/settings/MusicSettings;" const val MUSIC_INTEGRATIONS_PATH = "Lapp/revanced/music"
private const val MUSIC_PATCHES_PATH = "$MUSIC_INTEGRATIONS_PATH/patches"
const val MUSIC_ADS_PATH = "$MUSIC_PATCHES_PATH/ads"
const val MUSIC_LAYOUT = "$MUSIC_PATCHES_PATH/layout/LayoutPatch;"
const val MUSIC_MISC_PATH = "$MUSIC_PATCHES_PATH/misc"
const val MUSIC_UTILS_PATH = "$MUSIC_PATCHES_PATH/utils"
} }

View File

@ -34,8 +34,17 @@ internal object MusicResourceHelper {
private const val YOUTUBE_MUSIC_PREFERENCE_TAG_NAME = "com.google.android.apps.youtube.music.ui.preference.SwitchCompatPreference" private const val YOUTUBE_MUSIC_PREFERENCE_TAG_NAME = "com.google.android.apps.youtube.music.ui.preference.SwitchCompatPreference"
private const val YOUTUBE_MUSIC_PREFERENCE_TARGET_CLASS = "com.google.android.libraries.strictmode.penalties.notification.FullStackTraceActivity"
private var currentMusicPreferenceCategory = emptyArray<String>() private var currentMusicPreferenceCategory = emptyArray<String>()
private var targetPackage = "com.google.android.apps.youtube.music"
internal fun ResourceContext.setMicroG (newPackage: String) {
targetPackage = newPackage
replacePackageName()
}
private fun setMusicPreferenceCategory (newCategory: String) { private fun setMusicPreferenceCategory (newCategory: String) {
currentMusicPreferenceCategory += listOf(newCategory) currentMusicPreferenceCategory += listOf(newCategory)
} }
@ -59,20 +68,27 @@ internal object MusicResourceHelper {
} }
} }
internal fun ResourceContext.sortMusicPreferenceCategory() { internal fun ResourceContext.sortMusicPreferenceCategory(
category: String
) {
this.xmlEditor[YOUTUBE_MUSIC_SETTINGS_PATH].use { editor -> this.xmlEditor[YOUTUBE_MUSIC_SETTINGS_PATH].use { editor ->
editor.file.doRecursively loop@{ editor.file.doRecursively loop@{
if (it !is Element) return@loop if (it !is Element) return@loop
currentMusicPreferenceCategory.forEach { category -> it.getAttributeNode("android:key")?.let { attribute ->
it.getAttributeNode("android:key")?.let { attribute -> if (attribute.textContent == "revanced_settings_$category") {
if (attribute.textContent == "revanced_settings_$category") { it.cloneNodes(it.parentNode)
it.cloneNodes(it.parentNode)
}
} }
} }
} }
} }
replacePackageName()
}
private fun ResourceContext.replacePackageName(){
this[YOUTUBE_MUSIC_SETTINGS_PATH].writeText(
this[YOUTUBE_MUSIC_SETTINGS_PATH].readText().replace("\"com.google.android.apps.youtube.music", "\"" + targetPackage)
)
} }
internal fun ResourceContext.addMusicPreference( internal fun ResourceContext.addMusicPreference(
@ -95,6 +111,54 @@ internal object MusicResourceHelper {
} }
} }
internal fun ResourceContext.addMusicPreferenceAlt(
category: String,
key: String,
defaultValue: String,
dependencyKey: String
) {
this.xmlEditor[YOUTUBE_MUSIC_SETTINGS_PATH].use { editor ->
val tags = editor.file.getElementsByTagName(YOUTUBE_MUSIC_CATEGORY_TAG_NAME)
List(tags.length) { tags.item(it) as Element }
.filter { it.getAttribute("android:key").contains("revanced_settings_$category") }
.forEach {
it.adoptChild(YOUTUBE_MUSIC_PREFERENCE_TAG_NAME) {
setAttribute("android:title", "@string/$key" + "_title")
setAttribute("android:summaryOn", "@string/$key" + "_summary_on")
setAttribute("android:summaryOff", "@string/$key" + "_summary_off")
setAttribute("android:key", key)
setAttribute("android:defaultValue", defaultValue)
setAttribute("android:dependency", dependencyKey)
}
}
}
}
internal fun ResourceContext.addMusicPreferenceWithIntent(
category: String,
key: String,
dependencyKey: String
) {
this.xmlEditor[YOUTUBE_MUSIC_SETTINGS_PATH].use { editor ->
val tags = editor.file.getElementsByTagName(YOUTUBE_MUSIC_CATEGORY_TAG_NAME)
List(tags.length) { tags.item(it) as Element }
.filter { it.getAttribute("android:key").contains("revanced_settings_$category") }
.forEach {
it.adoptChild("Preference") {
setAttribute("android:title", "@string/$key" + "_title")
setAttribute("android:summary", "@string/$key" + "_summary")
setAttribute("android:key", key)
setAttribute("android:dependency", dependencyKey)
this.adoptChild("intent") {
setAttribute("android:targetPackage", targetPackage)
setAttribute("android:data", key)
setAttribute("android:targetClass", YOUTUBE_MUSIC_PREFERENCE_TARGET_CLASS)
}
}
}
}
}
internal fun ResourceContext.addReVancedMusicPreference() { internal fun ResourceContext.addReVancedMusicPreference() {
this.xmlEditor[YOUTUBE_MUSIC_SETTINGS_PATH].use { editor -> this.xmlEditor[YOUTUBE_MUSIC_SETTINGS_PATH].use { editor ->
with (editor.file) { with (editor.file) {