feat(YouTube Music - Hide action bar components): Limit the available versions of the Override Download action button setting to 7.16.53

This commit is contained in:
inotia00
2024-12-21 11:49:18 +09:00
parent 8e02716d95
commit f894327f0d
3 changed files with 10 additions and 111 deletions

View File

@ -1,7 +1,6 @@
package app.revanced.patches.music.actionbar.components
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
@ -24,7 +23,6 @@ import app.revanced.patches.music.utils.settings.settingsPatch
import app.revanced.patches.music.video.information.videoInformationPatch
import app.revanced.patches.shared.litho.addLithoFilter
import app.revanced.patches.shared.litho.lithoFilterPatch
import app.revanced.util.findMethodOrThrow
import app.revanced.util.fingerprint.matchOrThrow
import app.revanced.util.fingerprint.methodOrThrow
import app.revanced.util.getReference
@ -58,32 +56,6 @@ val actionBarComponentsPatch = bytecodePatch(
execute {
if (is_7_17_or_greater) {
browseSectionListReloadEndpointFingerprint.methodOrThrow().apply {
val targetIndex = indexOfGetLithoViewFromMapInstruction(this)
val targetReference = getInstruction<ReferenceInstruction>(targetIndex).reference
findMethodOrThrow(ACTIONBAR_CLASS_DESCRIPTOR) {
name == "getLithoViewFromMap"
}.addInstructions(
0, """
invoke-static {p0, p1, p2}, $targetReference
move-result-object p1
return-object p1
"""
)
}
offlineVideoEndpointFingerprint.methodOrThrow().apply {
addInstructionsWithLabels(
0, """
invoke-static {p2}, $ACTIONBAR_CLASS_DESCRIPTOR->inAppDownloadButtonOnClick(Ljava/util/Map;)Z
move-result v0
if-eqz v0, :ignore
return-void
""", ExternalLabel("ignore", getInstruction(0))
)
}
addLithoFilter(FILTER_CLASS_DESCRIPTOR)
}
@ -223,17 +195,17 @@ val actionBarComponentsPatch = bytecodePatch(
"revanced_hide_action_button_label",
"false"
)
addSwitchPreference(
CategoryType.ACTION_BAR,
"revanced_external_downloader_action",
"false"
)
addPreferenceWithIntent(
CategoryType.ACTION_BAR,
"revanced_external_downloader_package_name",
"revanced_external_downloader_action"
)
}
addSwitchPreference(
CategoryType.ACTION_BAR,
"revanced_external_downloader_action",
"false"
)
addPreferenceWithIntent(
CategoryType.ACTION_BAR,
"revanced_external_downloader_package_name",
"revanced_external_downloader_action"
)
updatePatchStatus(HIDE_ACTION_BAR_COMPONENTS)

View File

@ -2,13 +2,9 @@ package app.revanced.patches.music.actionbar.components
import app.revanced.patches.music.utils.resourceid.likeDislikeContainer
import app.revanced.util.fingerprint.legacyFingerprint
import app.revanced.util.getReference
import app.revanced.util.indexOfFirstInstruction
import app.revanced.util.or
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 val actionBarComponentFingerprint = legacyFingerprint(
name = "actionBarComponentFingerprint",
@ -26,40 +22,9 @@ internal val actionBarComponentFingerprint = legacyFingerprint(
literals = listOf(99180L),
)
internal val browseSectionListReloadEndpointFingerprint = legacyFingerprint(
name = "browseSectionListReloadEndpointFingerprint",
returnType = "V",
parameters = listOf("L", "Ljava/util/Map;"),
strings = listOf("request_mutator"),
customFingerprint = { method, _ ->
indexOfGetLithoViewFromMapInstruction(method) >= 0
}
)
internal fun indexOfGetLithoViewFromMapInstruction(method: Method) =
method.indexOfFirstInstruction {
val reference = getReference<MethodReference>()
opcode == Opcode.INVOKE_STATIC &&
reference?.returnType == "Ljava/lang/Object;" &&
reference.parameterTypes ==
listOf(
"Ljava/util/Map;",
"Ljava/lang/Object;",
"Ljava/lang/Class;"
)
}
internal val likeDislikeContainerFingerprint = legacyFingerprint(
name = "likeDislikeContainerFingerprint",
returnType = "V",
accessFlags = AccessFlags.PUBLIC or AccessFlags.CONSTRUCTOR,
literals = listOf(likeDislikeContainer)
)
internal val offlineVideoEndpointFingerprint = legacyFingerprint(
name = "offlineVideoEndpointFingerprint",
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
returnType = "V",
parameters = listOf("L", "Ljava/util/Map;"),
strings = listOf("Object is not an offlineable video: %s")
)