mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-03 08:04:36 +02:00
chore(YouTube Music): replace with a fingerprint that supports a wider range of versions
This commit is contained in:
parent
6af5fdba70
commit
486a0074b7
@ -6,9 +6,10 @@ 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.util.smali.ExternalLabel
|
||||
import app.revanced.patches.music.flyoutmenu.components.fingerprints.DialogSolidFingerprint
|
||||
import app.revanced.patches.music.flyoutmenu.components.fingerprints.EndButtonsContainerFingerprint
|
||||
import app.revanced.patches.music.flyoutmenu.components.fingerprints.MenuItemFingerprint
|
||||
import app.revanced.patches.music.flyoutmenu.components.fingerprints.ScreenWidthFingerprint
|
||||
import app.revanced.patches.music.flyoutmenu.components.fingerprints.ScreenWidthParentFingerprint
|
||||
import app.revanced.patches.music.flyoutmenu.components.fingerprints.SleepTimerFingerprint
|
||||
import app.revanced.patches.music.flyoutmenu.components.fingerprints.TouchOutsideFingerprint
|
||||
import app.revanced.patches.music.flyoutmenu.components.fingerprints.TrimSilenceConfigFingerprint
|
||||
@ -25,6 +26,7 @@ import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.patches.music.utils.videotype.VideoTypeHookPatch
|
||||
import app.revanced.patches.music.video.information.VideoInformationPatch
|
||||
import app.revanced.patches.shared.litho.LithoFilterPatch
|
||||
import app.revanced.util.alsoResolve
|
||||
import app.revanced.util.findMethodOrThrow
|
||||
import app.revanced.util.getReference
|
||||
import app.revanced.util.getWalkerMethod
|
||||
@ -55,9 +57,9 @@ object FlyoutMenuComponentsPatch : BaseBytecodePatch(
|
||||
),
|
||||
compatiblePackages = COMPATIBLE_PACKAGE,
|
||||
fingerprints = setOf(
|
||||
DialogSolidFingerprint,
|
||||
EndButtonsContainerFingerprint,
|
||||
MenuItemFingerprint,
|
||||
ScreenWidthParentFingerprint,
|
||||
SleepTimerFingerprint,
|
||||
TouchOutsideFingerprint,
|
||||
TrimSilenceConfigFingerprint,
|
||||
@ -72,15 +74,20 @@ object FlyoutMenuComponentsPatch : BaseBytecodePatch(
|
||||
|
||||
// region patch for enable compact dialog
|
||||
|
||||
DialogSolidFingerprint.resultOrThrow().let {
|
||||
val walkerMethod =
|
||||
it.getWalkerMethod(context, it.scanResult.patternScanResult!!.endIndex)
|
||||
walkerMethod.addInstructions(
|
||||
2, """
|
||||
invoke-static {p0}, $FLYOUT_CLASS_DESCRIPTOR->enableCompactDialog(I)I
|
||||
move-result p0
|
||||
"""
|
||||
)
|
||||
ScreenWidthFingerprint.alsoResolve(
|
||||
context, ScreenWidthParentFingerprint
|
||||
).let {
|
||||
it.mutableMethod.apply {
|
||||
val index = it.scanResult.patternScanResult!!.startIndex
|
||||
val register = getInstruction<TwoRegisterInstruction>(index).registerA
|
||||
|
||||
addInstructions(
|
||||
index, """
|
||||
invoke-static {v$register}, $FLYOUT_CLASS_DESCRIPTOR->enableCompactDialog(I)I
|
||||
move-result v$register
|
||||
"""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
@ -1,20 +0,0 @@
|
||||
package app.revanced.patches.music.flyoutmenu.components.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patches.music.utils.resourceid.SharedResourceIdPatch.DialogSolid
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.AccessFlags
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal object DialogSolidFingerprint : LiteralValueFingerprint(
|
||||
returnType = "V",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.FINAL,
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(
|
||||
Opcode.INVOKE_VIRTUAL,
|
||||
Opcode.MOVE_RESULT_OBJECT,
|
||||
Opcode.INVOKE_STATIC
|
||||
),
|
||||
literalSupplier = { DialogSolid },
|
||||
)
|
||||
|
@ -0,0 +1,11 @@
|
||||
package app.revanced.patches.music.flyoutmenu.components.fingerprints
|
||||
|
||||
import app.revanced.util.fingerprint.LiteralValueFingerprint
|
||||
import com.android.tools.smali.dexlib2.Opcode
|
||||
|
||||
internal object ScreenWidthFingerprint : LiteralValueFingerprint(
|
||||
returnType = "Z",
|
||||
parameters = listOf("L"),
|
||||
opcodes = listOf(Opcode.IF_LT),
|
||||
literalSupplier = { 600 },
|
||||
)
|
@ -0,0 +1,22 @@
|
||||
package app.revanced.patches.music.flyoutmenu.components.fingerprints
|
||||
|
||||
import app.revanced.patcher.extensions.or
|
||||
import app.revanced.patcher.fingerprint.MethodFingerprint
|
||||
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.reference.MethodReference
|
||||
|
||||
internal object ScreenWidthParentFingerprint : MethodFingerprint(
|
||||
returnType = "Landroid/graphics/Bitmap;",
|
||||
accessFlags = AccessFlags.PUBLIC or AccessFlags.STATIC,
|
||||
parameters = listOf("Landroid/app/Activity;", "I"),
|
||||
customFingerprint = { methodDef, _ ->
|
||||
methodDef.indexOfFirstInstructionReversed {
|
||||
opcode == Opcode.INVOKE_VIRTUAL &&
|
||||
getReference<MethodReference>()?.name == "destroyDrawingCache"
|
||||
} >= 0
|
||||
}
|
||||
)
|
||||
|
@ -6,6 +6,7 @@ import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.booleanPat
|
||||
import app.revanced.patcher.patch.options.PatchOption.PatchExtensions.stringPatchOption
|
||||
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
|
||||
import app.revanced.patches.music.utils.settings.ResourceUtils.setIconType
|
||||
import app.revanced.patches.music.utils.settings.SettingsPatch
|
||||
import app.revanced.util.ResourceGroup
|
||||
import app.revanced.util.Utils.trimIndentMultiline
|
||||
import app.revanced.util.copyResources
|
||||
@ -15,6 +16,7 @@ import app.revanced.util.underBarOrThrow
|
||||
import org.w3c.dom.Element
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.StandardCopyOption
|
||||
|
||||
@Suppress("DEPRECATION", "unused")
|
||||
object CustomBrandingIconPatch : BaseResourcePatch(
|
||||
@ -22,6 +24,8 @@ object CustomBrandingIconPatch : BaseResourcePatch(
|
||||
description = "Changes the YouTube Music app icon to the icon specified in options.json.",
|
||||
compatiblePackages = COMPATIBLE_PACKAGE
|
||||
) {
|
||||
private const val ADAPTIVE_ICON_BACKGROUND_FILE_NAME = "adaptiveproduct_youtube_music_background_color_108"
|
||||
private const val ADAPTIVE_ICON_FOREGROUND_FILE_NAME = "adaptiveproduct_youtube_music_foreground_color_108"
|
||||
private const val DEFAULT_ICON = "revancify_blue"
|
||||
|
||||
private val availableIcon = mapOf(
|
||||
@ -60,8 +64,8 @@ object CustomBrandingIconPatch : BaseResourcePatch(
|
||||
private val mipmapDirectories = sizeArray.map { "mipmap-$it" }
|
||||
|
||||
private val launcherIconResourceFileNames = arrayOf(
|
||||
"adaptiveproduct_youtube_music_background_color_108",
|
||||
"adaptiveproduct_youtube_music_foreground_color_108",
|
||||
ADAPTIVE_ICON_BACKGROUND_FILE_NAME,
|
||||
ADAPTIVE_ICON_FOREGROUND_FILE_NAME,
|
||||
"ic_launcher_release"
|
||||
).map { "$it.png" }.toTypedArray()
|
||||
|
||||
@ -224,5 +228,50 @@ object CustomBrandingIconPatch : BaseResourcePatch(
|
||||
|
||||
setIconType(appIcon)
|
||||
}
|
||||
|
||||
// region fix app icon
|
||||
|
||||
if (!SettingsPatch.upward0723) {
|
||||
return
|
||||
}
|
||||
|
||||
fun getAdaptiveIconResourceFile(tag: String): String {
|
||||
context.xmlEditor["res/mipmap-anydpi/ic_launcher_release.xml"].use { editor ->
|
||||
val adaptiveIcon = editor
|
||||
.file
|
||||
.getElementsByTagName("adaptive-icon")
|
||||
.item(0) as Element
|
||||
|
||||
val childNodes = adaptiveIcon.childNodes
|
||||
for (i in 0 until childNodes.length) {
|
||||
val node = childNodes.item(i)
|
||||
if (node is Element && node.tagName == tag && node.hasAttribute("android:drawable")) {
|
||||
return node.getAttribute("android:drawable").split("/")[1]
|
||||
}
|
||||
}
|
||||
throw PatchException("Element not found: $tag")
|
||||
}
|
||||
}
|
||||
|
||||
mapOf(
|
||||
ADAPTIVE_ICON_BACKGROUND_FILE_NAME to getAdaptiveIconResourceFile("background"),
|
||||
ADAPTIVE_ICON_FOREGROUND_FILE_NAME to getAdaptiveIconResourceFile("foreground")
|
||||
).forEach { (oldIconResourceFile, newIconResourceFile) ->
|
||||
mipmapDirectories.forEach {
|
||||
val mipmapDirectory = context["res"].resolve(it)
|
||||
Files.move(
|
||||
mipmapDirectory
|
||||
.resolve("$oldIconResourceFile.png")
|
||||
.toPath(),
|
||||
mipmapDirectory
|
||||
.resolve("$newIconResourceFile.png")
|
||||
.toPath(),
|
||||
StandardCopyOption.REPLACE_EXISTING
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
var ColorGrey = -1L
|
||||
var DarkBackground = -1L
|
||||
var DesignBottomSheetDialog = -1L
|
||||
var DialogSolid = -1L
|
||||
var EndButtonsContainer = -1L
|
||||
var FloatingLayout = -1L
|
||||
var HistoryMenuItem = -1L
|
||||
@ -68,7 +67,6 @@ object SharedResourceIdPatch : ResourcePatch() {
|
||||
ColorGrey = getId(COLOR, "ytm_color_grey_12")
|
||||
DarkBackground = getId(ID, "dark_background")
|
||||
DesignBottomSheetDialog = getId(LAYOUT, "design_bottom_sheet_dialog")
|
||||
DialogSolid = getId(STYLE, "Theme.YouTubeMusic.Dialog.Solid")
|
||||
EndButtonsContainer = getId(ID, "end_buttons_container")
|
||||
FloatingLayout = getId(ID, "floating_layout")
|
||||
HistoryMenuItem = getId(ID, "history_menu_item")
|
||||
|
@ -44,6 +44,7 @@ object SettingsPatch : BaseResourcePatch(
|
||||
internal var upward0706 = false
|
||||
internal var upward0718 = false
|
||||
internal var upward0720 = false
|
||||
internal var upward0723 = false
|
||||
|
||||
override fun execute(context: ResourceContext) {
|
||||
|
||||
@ -142,6 +143,7 @@ object SettingsPatch : BaseResourcePatch(
|
||||
upward0706 = 242499000 <= playServicesVersion
|
||||
upward0718 = 243699000 <= playServicesVersion
|
||||
upward0720 = 243899000 <= playServicesVersion
|
||||
upward0723 = 244199000 <= playServicesVersion
|
||||
|
||||
break
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user