mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 13:17:46 +02:00
fix(Hide settings menu): do not use strings for filtering
This commit is contained in:
@ -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