mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 05:07:41 +02:00
fix(Hide settings menu): do not use strings for filtering
This commit is contained in:
@ -2,7 +2,6 @@ package app.revanced.patches.music.ads.general
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patches.music.ads.general.MusicAdsPatch.hookLithoFullscreenAds
|
||||
import app.revanced.patches.music.ads.general.MusicAdsPatch.hookNonLithoFullscreenAds
|
||||
@ -10,8 +9,6 @@ import app.revanced.patches.music.ads.general.fingerprints.AccountMenuFooterFing
|
||||
import app.revanced.patches.music.ads.general.fingerprints.FloatingLayoutFingerprint
|
||||
import app.revanced.patches.music.ads.general.fingerprints.GetPremiumTextViewFingerprint
|
||||
import app.revanced.patches.music.ads.general.fingerprints.InterstitialsContainerFingerprint
|
||||
import app.revanced.patches.music.ads.general.fingerprints.MembershipSettingsFingerprint
|
||||
import app.revanced.patches.music.ads.general.fingerprints.MembershipSettingsParentFingerprint
|
||||
import app.revanced.patches.music.ads.general.fingerprints.NotifierShelfFingerprint
|
||||
import app.revanced.patches.music.ads.general.fingerprints.ShowDialogCommandFingerprint
|
||||
import app.revanced.patches.music.navigation.components.NavigationBarComponentsPatch
|
||||
@ -55,7 +52,6 @@ object AdsPatch : BaseBytecodePatch(
|
||||
FloatingLayoutFingerprint,
|
||||
GetPremiumTextViewFingerprint,
|
||||
InterstitialsContainerFingerprint,
|
||||
MembershipSettingsParentFingerprint,
|
||||
NotifierShelfFingerprint,
|
||||
ShowDialogCommandFingerprint
|
||||
)
|
||||
@ -163,20 +159,6 @@ object AdsPatch : BaseBytecodePatch(
|
||||
}
|
||||
}
|
||||
|
||||
// premium membership menu in settings
|
||||
MembershipSettingsFingerprint.resolve(
|
||||
context,
|
||||
MembershipSettingsParentFingerprint.resultOrThrow().classDef
|
||||
)
|
||||
MembershipSettingsFingerprint.resultOrThrow().mutableMethod.addInstructions(
|
||||
0, """
|
||||
const/4 v0, 0x0
|
||||
return-object v0
|
||||
"""
|
||||
)
|
||||
|
||||
// endregion
|
||||
|
||||
LithoFilterPatch.addFilter(ADS_FILTER_CLASS_DESCRIPTOR)
|
||||
|
||||
SettingsPatch.addSwitchPreference(
|
||||
|
@ -1,11 +0,0 @@
|
||||
package app.revanced.patches.music.ads.general.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal object MembershipSettingsFingerprint : MethodFingerprint(
|
||||
returnType = "Ljava/lang/CharSequence;",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = emptyList()
|
||||
)
|
@ -1,12 +0,0 @@
|
||||
package app.revanced.patches.music.ads.general.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal object MembershipSettingsParentFingerprint : MethodFingerprint(
|
||||
returnType = "L",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = emptyList(),
|
||||
strings = listOf("SPmanage_red")
|
||||
)
|
@ -15,7 +15,9 @@ import app.revanced.patches.music.general.components.fingerprints.FloatingButton
|
||||
import app.revanced.patches.music.general.components.fingerprints.HistoryMenuItemFingerprint
|
||||
import app.revanced.patches.music.general.components.fingerprints.HistoryMenuItemOfflineTabFingerprint
|
||||
import app.revanced.patches.music.general.components.fingerprints.MediaRouteButtonFingerprint
|
||||
import app.revanced.patches.music.general.components.fingerprints.ParentToolMenuFingerprint
|
||||
import app.revanced.patches.music.general.components.fingerprints.PlayerOverlayChipFingerprint
|
||||
import app.revanced.patches.music.general.components.fingerprints.PreferenceScreenFingerprint
|
||||
import app.revanced.patches.music.general.components.fingerprints.SearchBarFingerprint
|
||||
import app.revanced.patches.music.general.components.fingerprints.SearchBarParentFingerprint
|
||||
import app.revanced.patches.music.general.components.fingerprints.SoundSearchFingerprint
|
||||
@ -26,6 +28,7 @@ import app.revanced.patches.music.general.components.fingerprints.TopBarMenuItem
|
||||
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.music.utils.integrations.Constants.COMPONENTS_PATH
|
||||
import app.revanced.patches.music.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.music.utils.integrations.Constants.GENERAL_PATH
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.MusicTasteBuilderShelf
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.PlayerOverlayChip
|
||||
@ -62,7 +65,9 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
HistoryMenuItemFingerprint,
|
||||
HistoryMenuItemOfflineTabFingerprint,
|
||||
MediaRouteButtonFingerprint,
|
||||
ParentToolMenuFingerprint,
|
||||
PlayerOverlayChipFingerprint,
|
||||
PreferenceScreenFingerprint,
|
||||
SearchBarParentFingerprint,
|
||||
SoundSearchFingerprint,
|
||||
TasteBuilderConstructorFingerprint,
|
||||
@ -70,9 +75,10 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
TopBarMenuItemImageViewFingerprint
|
||||
)
|
||||
) {
|
||||
private const val INTEGRATIONS_SETTINGS_MENU_DESCRIPTOR =
|
||||
"$GENERAL_PATH/SettingsMenuPatch;"
|
||||
private const val CUSTOM_FILTER_CLASS_DESCRIPTOR =
|
||||
"$COMPONENTS_PATH/CustomFilter;"
|
||||
|
||||
private const val LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR =
|
||||
"$COMPONENTS_PATH/LayoutComponentsFilter;"
|
||||
|
||||
@ -194,6 +200,35 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for hide setting menus
|
||||
|
||||
PreferenceScreenFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
addInstructions(
|
||||
implementation!!.instructions.lastIndex, """
|
||||
invoke-virtual/range {p0 .. p0}, Lcom/google/android/apps/youtube/music/settings/fragment/SettingsHeadersFragment;->getPreferenceScreen()Landroidx/preference/PreferenceScreen;
|
||||
move-result-object v0
|
||||
invoke-static {v0}, $INTEGRATIONS_SETTINGS_MENU_DESCRIPTOR->hideSettingsMenu(Landroidx/preference/PreferenceScreen;)V
|
||||
"""
|
||||
)
|
||||
}
|
||||
|
||||
// The lowest version supported by the patch does not have parent tool settings
|
||||
ParentToolMenuFingerprint.result?.let {
|
||||
it.mutableMethod.apply {
|
||||
val index = it.scanResult.patternScanResult!!.startIndex + 1
|
||||
val register = getInstruction<FiveRegisterInstruction>(index).registerD
|
||||
|
||||
addInstructions(
|
||||
index, """
|
||||
invoke-static {v$register}, $INTEGRATIONS_SETTINGS_MENU_DESCRIPTOR->hideParentToolsMenu(Z)Z
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for hide sound search button
|
||||
|
||||
SoundSearchFingerprint.result?.let {
|
||||
@ -299,16 +334,6 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
"revanced_custom_filter_strings",
|
||||
"revanced_custom_filter"
|
||||
)
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.GENERAL,
|
||||
"revanced_hide_settings_menu",
|
||||
"false"
|
||||
)
|
||||
SettingsPatch.addPreferenceWithIntent(
|
||||
CategoryType.GENERAL,
|
||||
"revanced_hide_settings_menu_filter_strings",
|
||||
"revanced_hide_settings_menu"
|
||||
)
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.GENERAL,
|
||||
"revanced_hide_button_shelf",
|
||||
@ -373,5 +398,66 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
"revanced_hide_voice_search_button",
|
||||
"false"
|
||||
)
|
||||
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.SETTINGS,
|
||||
"revanced_hide_settings_menu_parent_tools",
|
||||
"false",
|
||||
false
|
||||
)
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.SETTINGS,
|
||||
"revanced_hide_settings_menu_general",
|
||||
"false",
|
||||
false
|
||||
)
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.SETTINGS,
|
||||
"revanced_hide_settings_menu_playback",
|
||||
"false",
|
||||
false
|
||||
)
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.SETTINGS,
|
||||
"revanced_hide_settings_menu_data_saving",
|
||||
"false",
|
||||
false
|
||||
)
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.SETTINGS,
|
||||
"revanced_hide_settings_menu_downloads_and_storage",
|
||||
"false",
|
||||
false
|
||||
)
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.SETTINGS,
|
||||
"revanced_hide_settings_menu_notification",
|
||||
"false",
|
||||
false
|
||||
)
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.SETTINGS,
|
||||
"revanced_hide_settings_menu_privacy_and_location",
|
||||
"false",
|
||||
false
|
||||
)
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.SETTINGS,
|
||||
"revanced_hide_settings_menu_recommendations",
|
||||
"false",
|
||||
false
|
||||
)
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.SETTINGS,
|
||||
"revanced_hide_settings_menu_paid_memberships",
|
||||
"true",
|
||||
false
|
||||
)
|
||||
SettingsPatch.addSwitchPreference(
|
||||
CategoryType.SETTINGS,
|
||||
"revanced_hide_settings_menu_about",
|
||||
"false",
|
||||
false
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package app.revanced.patches.music.general.components.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal object ParentToolMenuFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
opcodes = listOf(
|
||||
Opcode.CONST_4,
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.IGET,
|
||||
),
|
||||
strings = listOf("pref_key_parent_tools"),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.name == "onSettingsLoaded"
|
||||
}
|
||||
)
|
@ -0,0 +1,11 @@
|
||||
package app.revanced.patches.music.general.components.fingerprints
|
||||
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
|
||||
internal object PreferenceScreenFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass == "Lcom/google/android/apps/youtube/music/settings/fragment/SettingsHeadersFragment;" &&
|
||||
methodDef.name == "onCreatePreferences"
|
||||
}
|
||||
)
|
@ -136,6 +136,7 @@ object VisualPreferencesIconsPatch : BaseResourcePatch(
|
||||
"revanced_preference_screen_general",
|
||||
"revanced_preference_screen_navigation",
|
||||
"revanced_preference_screen_player",
|
||||
"revanced_preference_screen_settings",
|
||||
"revanced_preference_screen_video",
|
||||
"revanced_preference_screen_ryd",
|
||||
"revanced_preference_screen_sb",
|
||||
|
@ -8,6 +8,7 @@ enum class CategoryType(val value: String, var added: Boolean) {
|
||||
GENERAL("general", false),
|
||||
NAVIGATION("navigation", false),
|
||||
PLAYER("player", false),
|
||||
SETTINGS("settings", false),
|
||||
VIDEO("video", false),
|
||||
RETURN_YOUTUBE_DISLIKE("ryd", false),
|
||||
SPONSOR_BLOCK("sb", false),
|
||||
|
@ -1,42 +1,43 @@
|
||||
package app.revanced.patches.shared.settingmenu
|
||||
|
||||
import app.revanced.patcher.data.BytecodeContext
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.patch.BytecodePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patches.shared.integrations.Constants.PATCHES_PATH
|
||||
import app.revanced.patches.shared.settingmenu.fingerprints.SettingsMenuFingerprint
|
||||
import app.revanced.patches.shared.viewgroup.ViewGroupMarginLayoutParamsHookPatch
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionOrThrow
|
||||
import app.revanced.util.resultOrThrow
|
||||
import com.android.tools.smali.dexlib2.iface.instruction.TwoRegisterInstruction
|
||||
import com.android.tools.smali.dexlib2.iface.reference.FieldReference
|
||||
import app.revanced.patches.shared.settingmenu.fingerprints.FindPreferenceFingerprint
|
||||
import app.revanced.patches.shared.settingmenu.fingerprints.RemovePreferenceFingerprint
|
||||
import app.revanced.util.findMethodOrThrow
|
||||
import app.revanced.util.getMethodCall
|
||||
|
||||
@Patch(
|
||||
description = "Hide the settings menu for YouTube or YouTube Music.",
|
||||
dependencies = [ViewGroupMarginLayoutParamsHookPatch::class]
|
||||
)
|
||||
object SettingsMenuPatch : BytecodePatch(
|
||||
setOf(SettingsMenuFingerprint)
|
||||
setOf(
|
||||
FindPreferenceFingerprint,
|
||||
RemovePreferenceFingerprint
|
||||
)
|
||||
) {
|
||||
private const val INTEGRATIONS_CLASS_DESCRIPTOR =
|
||||
"$PATCHES_PATH/SettingsMenuPatch;"
|
||||
"$PATCHES_PATH/BaseSettingsMenuPatch;"
|
||||
|
||||
override fun execute(context: BytecodeContext) {
|
||||
|
||||
SettingsMenuFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val insertIndex = indexOfFirstInstructionOrThrow {
|
||||
getReference<FieldReference>()?.type == "Landroid/support/v7/widget/RecyclerView;"
|
||||
}
|
||||
val insertRegister = getInstruction<TwoRegisterInstruction>(insertIndex).registerA
|
||||
val findPreferenceMethodCall = FindPreferenceFingerprint.getMethodCall()
|
||||
val removePreferenceMethodCall = RemovePreferenceFingerprint.getMethodCall()
|
||||
|
||||
addInstruction(
|
||||
insertIndex,
|
||||
"invoke-static {v$insertRegister}, " +
|
||||
"$INTEGRATIONS_CLASS_DESCRIPTOR->hideSettingsMenu(Landroid/support/v7/widget/RecyclerView;)V"
|
||||
)
|
||||
}
|
||||
context.findMethodOrThrow(INTEGRATIONS_CLASS_DESCRIPTOR) {
|
||||
name == "removePreference"
|
||||
}.addInstructionsWithLabels(
|
||||
0, """
|
||||
invoke-virtual {p0, p1}, $findPreferenceMethodCall
|
||||
move-result-object v0
|
||||
if-eqz v0, :ignore
|
||||
invoke-virtual {p0, v0}, $removePreferenceMethodCall
|
||||
:ignore
|
||||
return-void
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package app.revanced.patches.shared.settingmenu.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
|
||||
internal object FindPreferenceFingerprint : MethodFingerprint(
|
||||
returnType = "Landroidx/preference/Preference;",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Ljava/lang/CharSequence;"),
|
||||
strings = listOf("Key cannot be null"),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.definingClass == "Landroidx/preference/PreferenceGroup;"
|
||||
}
|
||||
)
|
@ -0,0 +1,19 @@
|
||||
package app.revanced.patches.shared.settingmenu.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal object RemovePreferenceFingerprint : MethodFingerprint(
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("Landroidx/preference/Preference;"),
|
||||
opcodes = listOf(Opcode.INVOKE_VIRTUAL),
|
||||
customFingerprint = custom@{ methodDef, _ ->
|
||||
if (methodDef.definingClass != "Landroidx/preference/PreferenceGroup;") {
|
||||
return@custom false
|
||||
}
|
||||
val instructions = methodDef.implementation?.instructions ?: return@custom false
|
||||
instructions.elementAt(0).opcode == Opcode.INVOKE_DIRECT
|
||||
}
|
||||
)
|
@ -1,8 +0,0 @@
|
||||
package app.revanced.patches.shared.settingmenu.fingerprints
|
||||
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
|
||||
internal object SettingsMenuFingerprint : LiteralValueFingerprint(
|
||||
returnType = "Landroid/view/View;",
|
||||
literalSupplier = { 16908351 },
|
||||
)
|
@ -5,6 +5,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||
import app.revanced.patcher.extensions.InstructionExtensions.removeInstruction
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.util.smali.ExternalLabel
|
||||
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||
@ -19,11 +20,13 @@ import app.revanced.patches.youtube.general.components.fingerprints.AppBlockingC
|
||||
import app.revanced.patches.youtube.general.components.fingerprints.BottomUiContainerFingerprint
|
||||
import app.revanced.patches.youtube.general.components.fingerprints.FloatingMicrophoneFingerprint
|
||||
import app.revanced.patches.youtube.general.components.fingerprints.PiPNotificationFingerprint
|
||||
import app.revanced.patches.youtube.general.components.fingerprints.PreferenceScreenFingerprint
|
||||
import app.revanced.patches.youtube.general.components.fingerprints.TooltipContentFullscreenFingerprint
|
||||
import app.revanced.patches.youtube.general.components.fingerprints.TooltipContentViewFingerprint
|
||||
import app.revanced.patches.youtube.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.COMPONENTS_PATH
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_CLASS_DESCRIPTOR
|
||||
import app.revanced.patches.youtube.utils.integrations.Constants.GENERAL_PATH
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch
|
||||
import app.revanced.patches.youtube.utils.resourceid.SharedResourceIdPatch.AccountSwitcherAccessibility
|
||||
import app.revanced.patches.youtube.utils.settings.SettingsPatch
|
||||
@ -60,10 +63,13 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
BottomUiContainerFingerprint,
|
||||
FloatingMicrophoneFingerprint,
|
||||
PiPNotificationFingerprint,
|
||||
PreferenceScreenFingerprint,
|
||||
TooltipContentFullscreenFingerprint,
|
||||
TooltipContentViewFingerprint
|
||||
)
|
||||
) {
|
||||
private const val INTEGRATIONS_SETTINGS_MENU_DESCRIPTOR =
|
||||
"$GENERAL_PATH/SettingsMenuPatch;"
|
||||
private const val CUSTOM_FILTER_CLASS_DESCRIPTOR =
|
||||
"$COMPONENTS_PATH/CustomFilter;"
|
||||
private const val LAYOUT_COMPONENTS_FILTER_CLASS_DESCRIPTOR =
|
||||
@ -193,6 +199,29 @@ object LayoutComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for hide setting menus
|
||||
|
||||
PreferenceScreenFingerprint.resultOrThrow().mutableMethod.apply {
|
||||
val targetIndex =
|
||||
PreferenceScreenFingerprint.indexOfPreferenceScreenInstruction(this)
|
||||
val targetRegister = getInstruction<FiveRegisterInstruction>(targetIndex).registerC
|
||||
val targetReference = getInstruction<ReferenceInstruction>(targetIndex).reference
|
||||
|
||||
val insertIndex = implementation!!.instructions.lastIndex
|
||||
|
||||
addInstructions(
|
||||
insertIndex + 1, """
|
||||
invoke-virtual {v$targetRegister}, $targetReference
|
||||
move-result-object v$targetRegister
|
||||
invoke-static {v$targetRegister}, $INTEGRATIONS_SETTINGS_MENU_DESCRIPTOR->hideSettingsMenu(Landroidx/preference/PreferenceScreen;)V
|
||||
return-void
|
||||
"""
|
||||
)
|
||||
removeInstruction(insertIndex)
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
// region patch for hide snack bar
|
||||
|
||||
BottomUiContainerFingerprint.resultOrThrow().let {
|
||||
|
@ -0,0 +1,30 @@
|
||||
package app.revanced.patches.youtube.general.components.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
import app.revanced.patches.youtube.general.components.fingerprints.PreferenceScreenFingerprint.indexOfPreferenceScreenInstruction
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.indexOfFirstInstructionReversed
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
import com.android.tools.smali.dexlib2.iface.Method
|
||||
import com.android.tools.smali.dexlib2.iface.reference.MethodReference
|
||||
|
||||
internal object PreferenceScreenFingerprint : MethodFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = emptyList(),
|
||||
strings = listOf(":android:show_fragment_args"),
|
||||
customFingerprint = { methodDef, classDef ->
|
||||
AccessFlags.SYNTHETIC.isSet(classDef.accessFlags) &&
|
||||
indexOfPreferenceScreenInstruction(methodDef) >= 0
|
||||
}
|
||||
) {
|
||||
fun indexOfPreferenceScreenInstruction(methodDef: Method) =
|
||||
methodDef.indexOfFirstInstructionReversed {
|
||||
val reference = getReference<MethodReference>()
|
||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||
reference?.returnType == "Landroidx/preference/PreferenceScreen;" &&
|
||||
reference.parameterTypes.size == 0
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user