mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
feat(music) delete share-button-hook
patch
This commit is contained in:
@ -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")
|
|
||||||
)
|
|
@ -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" }
|
|
||||||
)
|
|
@ -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")
|
|
||||||
)
|
|
@ -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)
|
|
||||||
)
|
|
@ -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;"
|
|
||||||
}
|
|
||||||
}
|
|
@ -63,8 +63,6 @@
|
|||||||
<string name="revanced_hide_playlist_card_title">Hide playlist card</string>
|
<string name="revanced_hide_playlist_card_title">Hide playlist card</string>
|
||||||
<string name="revanced_hide_sample_button_summary">Hides the sample button in navigation bar.</string>
|
<string name="revanced_hide_sample_button_summary">Hides the sample button in navigation bar.</string>
|
||||||
<string name="revanced_hide_sample_button_title">Hide sample button</string>
|
<string name="revanced_hide_sample_button_title">Hide sample button</string>
|
||||||
<string name="revanced_hook_share_button_summary">Replace share button with external download button.</string>
|
|
||||||
<string name="revanced_hook_share_button_title">Hook share button (Experimental Flags)</string>
|
|
||||||
<string name="revanced_reboot_message">Refresh and restart</string>
|
<string name="revanced_reboot_message">Refresh and restart</string>
|
||||||
<string name="revanced_reset">Reset</string>
|
<string name="revanced_reset">Reset</string>
|
||||||
<string name="revanced_save_video_quality_mobile">Changing default mobile data quality to:</string>
|
<string name="revanced_save_video_quality_mobile">Changing default mobile data quality to:</string>
|
||||||
|
Reference in New Issue
Block a user