diff --git a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/ConnectionTrackerFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/ConnectionTrackerFingerprint.kt deleted file mode 100644 index 2a02b4e3c..000000000 --- a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/ConnectionTrackerFingerprint.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.revanced.patches.music.misc.sharebuttonhook.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import com.android.tools.smali.dexlib2.Opcode - -object ConnectionTrackerFingerprint : MethodFingerprint( - returnType = "Z", - opcodes = listOf(Opcode.THROW), - strings = listOf("ConnectionTracker") -) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/FullStackTraceActivityFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/FullStackTraceActivityFingerprint.kt deleted file mode 100644 index f4a4efb7a..000000000 --- a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/FullStackTraceActivityFingerprint.kt +++ /dev/null @@ -1,7 +0,0 @@ -package app.revanced.patches.music.misc.sharebuttonhook.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint - -object FullStackTraceActivityFingerprint : MethodFingerprint( - customFingerprint = { methodDef, _ -> methodDef.definingClass.endsWith("/FullStackTraceActivity;") && methodDef.name == "onCreate" } -) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/SharePanelFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/SharePanelFingerprint.kt deleted file mode 100644 index 9a799fa0e..000000000 --- a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/SharePanelFingerprint.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.revanced.patches.music.misc.sharebuttonhook.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import com.android.tools.smali.dexlib2.Opcode - -object SharePanelFingerprint : MethodFingerprint( - returnType = "V", - opcodes = listOf(Opcode.INVOKE_VIRTUAL), - strings = listOf("share/get_share_panel") -) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/ShowToastFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/ShowToastFingerprint.kt deleted file mode 100644 index 98278499a..000000000 --- a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/fingerprints/ShowToastFingerprint.kt +++ /dev/null @@ -1,10 +0,0 @@ -package app.revanced.patches.music.misc.sharebuttonhook.fingerprints - -import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint -import com.android.tools.smali.dexlib2.Opcode - -object ShowToastFingerprint : MethodFingerprint( - returnType = "V", - parameters = listOf("Landroid/content/Context;", "Ljava/lang/CharSequence;", "I"), - opcodes = listOf(Opcode.IF_EQZ) -) diff --git a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/patch/ShareButtonHookPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/patch/ShareButtonHookPatch.kt deleted file mode 100644 index a119fcc7d..000000000 --- a/src/main/kotlin/app/revanced/patches/music/misc/sharebuttonhook/patch/ShareButtonHookPatch.kt +++ /dev/null @@ -1,96 +0,0 @@ -package app.revanced.patches.music.misc.sharebuttonhook.patch - -import app.revanced.extensions.exception -import app.revanced.patcher.annotation.Description -import app.revanced.patcher.annotation.Name -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.addInstructionsWithLabels -import app.revanced.patcher.extensions.InstructionExtensions.getInstruction -import app.revanced.patcher.patch.BytecodePatch -import app.revanced.patcher.patch.annotations.DependsOn -import app.revanced.patcher.patch.annotations.Patch -import app.revanced.patcher.util.smali.ExternalLabel -import app.revanced.patches.music.misc.sharebuttonhook.fingerprints.ConnectionTrackerFingerprint -import app.revanced.patches.music.misc.sharebuttonhook.fingerprints.FullStackTraceActivityFingerprint -import app.revanced.patches.music.misc.sharebuttonhook.fingerprints.SharePanelFingerprint -import app.revanced.patches.music.misc.sharebuttonhook.fingerprints.ShowToastFingerprint -import app.revanced.patches.music.utils.annotations.MusicCompatibility -import app.revanced.patches.music.utils.settings.resource.patch.SettingsPatch -import app.revanced.patches.music.utils.videoid.patch.VideoIdPatch -import app.revanced.util.enum.CategoryType -import app.revanced.util.integrations.Constants.MUSIC_INTEGRATIONS_PATH -import app.revanced.util.integrations.Constants.MUSIC_MISC_PATH - -@Patch -@Name("Share button hook") -@Description("Replace share button with external download button.") -@DependsOn( - [ - SettingsPatch::class, - VideoIdPatch::class - ] -) -@MusicCompatibility -class ShareButtonHookPatch : BytecodePatch( - listOf( - ConnectionTrackerFingerprint, - FullStackTraceActivityFingerprint, - SharePanelFingerprint, - ShowToastFingerprint - ) -) { - override fun execute(context: BytecodeContext) { - SharePanelFingerprint.result?.let { - it.mutableMethod.apply { - val targetIndex = it.scanResult.patternScanResult!!.startIndex - - addInstructionsWithLabels( - targetIndex, """ - invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->shouldHookShareButton()Z - move-result p1 - if-eqz p1, :default - invoke-static {}, $INTEGRATIONS_CLASS_DESCRIPTOR->startDownloadActivity()V - return-void - """, ExternalLabel("default", getInstruction(targetIndex)) - ) - } - } ?: throw SharePanelFingerprint.exception - - ConnectionTrackerFingerprint.result?.mutableMethod?.addInstruction( - 0, - "sput-object p1, $INTEGRATIONS_CLASS_DESCRIPTOR->context:Landroid/content/Context;" - ) ?: throw ConnectionTrackerFingerprint.exception - - ShowToastFingerprint.result?.mutableMethod?.addInstructions( - 0, """ - invoke-static {p0}, $INTEGRATIONS_CLASS_DESCRIPTOR->dismissContext(Landroid/content/Context;)Landroid/content/Context; - move-result-object p0 - """ - ) ?: throw ShowToastFingerprint.exception - - FullStackTraceActivityFingerprint.result?.mutableMethod?.addInstructions( - 1, """ - invoke-static {p0}, $MUSIC_INTEGRATIONS_PATH/settingsmenu/SharedPreferenceChangeListener;->initializeSettings(Landroid/app/Activity;)V - return-void - """ - ) ?: throw FullStackTraceActivityFingerprint.exception - - SettingsPatch.addMusicPreference( - CategoryType.MISC, - "revanced_hook_share_button", - "false" - ) - SettingsPatch.addMusicPreferenceWithIntent( - CategoryType.MISC, - "revanced_external_downloader_package_name", - "revanced_hook_share_button" - ) - - } - - private companion object { - const val INTEGRATIONS_CLASS_DESCRIPTOR = "$MUSIC_MISC_PATH/HookShareButtonPatch;" - } -} diff --git a/src/main/resources/music/settings/host/values/strings.xml b/src/main/resources/music/settings/host/values/strings.xml index b15c795b5..f63f3ae2d 100644 --- a/src/main/resources/music/settings/host/values/strings.xml +++ b/src/main/resources/music/settings/host/values/strings.xml @@ -63,8 +63,6 @@ Hide playlist card Hides the sample button in navigation bar. Hide sample button - Replace share button with external download button. - Hook share button (Experimental Flags) Refresh and restart Reset Changing default mobile data quality to: