Skip to content

Commit 8d045bc

Browse files
committed
fix(YouTube Music - Custom header): Not working on YouTube Music 7.25.53 inotia00/ReVanced_Extended#2612
1 parent 87a6aec commit 8d045bc

File tree

4 files changed

+76
-22
lines changed

4 files changed

+76
-22
lines changed

patches/src/main/kotlin/app/revanced/patches/music/layout/header/ChangeHeaderPatch.kt

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import app.revanced.patcher.patch.resourcePatch
55
import app.revanced.patcher.patch.stringOption
66
import app.revanced.patches.music.utils.compatibility.Constants.COMPATIBLE_PACKAGE
77
import app.revanced.patches.music.utils.patch.PatchList.CUSTOM_HEADER_FOR_YOUTUBE_MUSIC
8+
import app.revanced.patches.music.utils.playservice.is_7_06_or_greater
9+
import app.revanced.patches.music.utils.playservice.versionCheckPatch
10+
import app.revanced.patches.music.utils.resourceid.actionBarLogo
11+
import app.revanced.patches.music.utils.resourceid.actionBarLogoRingo2
12+
import app.revanced.patches.music.utils.resourceid.sharedResourceIdPatch
13+
import app.revanced.patches.music.utils.resourceid.ytmLogo
14+
import app.revanced.patches.music.utils.resourceid.ytmLogoRingo2
815
import app.revanced.patches.music.utils.settings.ResourceUtils.getIconType
916
import app.revanced.patches.music.utils.settings.ResourceUtils.updatePatchStatus
1017
import app.revanced.patches.music.utils.settings.settingsPatch
@@ -13,8 +20,7 @@ import app.revanced.util.Utils.printWarn
1320
import app.revanced.util.Utils.trimIndentMultiline
1421
import app.revanced.util.copyFile
1522
import app.revanced.util.copyResources
16-
import app.revanced.util.fingerprint.injectLiteralInstructionBooleanCall
17-
import app.revanced.util.fingerprint.resolvable
23+
import app.revanced.util.replaceLiteralInstructionCall
1824
import app.revanced.util.underBarOrThrow
1925
import app.revanced.util.valueOrThrow
2026

@@ -100,24 +106,31 @@ private val getDescription = {
100106
private val changeHeaderBytecodePatch = bytecodePatch(
101107
description = "changeHeaderBytecodePatch"
102108
) {
109+
dependsOn(
110+
sharedResourceIdPatch,
111+
versionCheckPatch,
112+
)
113+
103114
execute {
115+
104116
/**
105117
* New Header has been added from YouTube Music v7.04.51.
106118
*
107-
* The new header's file names are 'action_bar_logo_ringo2.png' and 'ytm_logo_ringo2.png'.
119+
* The new header's file names are 'action_bar_logo_ringo2.png' and 'ytm_logo_ringo2.png'.
108120
* The only difference between the existing header and the new header is the dimensions of the image.
109121
*
110122
* The affected patch is [changeHeaderPatch].
111-
*
112-
* TODO: Add a new header image file to [changeHeaderPatch] later.
113123
*/
114-
if (!headerSwitchConfigFingerprint.resolvable()) {
124+
if (!is_7_06_or_greater) {
115125
return@execute
116126
}
117-
headerSwitchConfigFingerprint.injectLiteralInstructionBooleanCall(
118-
45617851L,
119-
"0x0"
120-
)
127+
128+
listOf(
129+
actionBarLogoRingo2 to actionBarLogo,
130+
ytmLogoRingo2 to ytmLogo,
131+
).forEach { (originalResource, replacementResource) ->
132+
replaceLiteralInstructionCall(originalResource, replacementResource)
133+
}
121134
}
122135
}
123136

patches/src/main/kotlin/app/revanced/patches/music/layout/header/Fingerprints.kt

Lines changed: 0 additions & 12 deletions
This file was deleted.

patches/src/main/kotlin/app/revanced/patches/music/utils/resourceid/SharedResourceIdPatch.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import app.revanced.patcher.patch.resourcePatch
44
import app.revanced.patches.shared.mapping.ResourceType.BOOL
55
import app.revanced.patches.shared.mapping.ResourceType.COLOR
66
import app.revanced.patches.shared.mapping.ResourceType.DIMEN
7+
import app.revanced.patches.shared.mapping.ResourceType.DRAWABLE
78
import app.revanced.patches.shared.mapping.ResourceType.ID
89
import app.revanced.patches.shared.mapping.ResourceType.LAYOUT
910
import app.revanced.patches.shared.mapping.ResourceType.STRING
@@ -14,6 +15,10 @@ import app.revanced.patches.shared.mapping.resourceMappings
1415

1516
var accountSwitcherAccessibility = -1L
1617
private set
18+
var actionBarLogo = -1L
19+
private set
20+
var actionBarLogoRingo2 = -1L
21+
private set
1722
var bottomSheetRecyclerView = -1L
1823
private set
1924
var buttonContainer = -1L
@@ -94,6 +99,10 @@ var trimSilenceSwitch = -1L
9499
private set
95100
var varispeedUnavailableTitle = -1L
96101
private set
102+
var ytmLogo = -1L
103+
private set
104+
var ytmLogoRingo2 = -1L
105+
private set
97106

98107
internal val sharedResourceIdPatch = resourcePatch(
99108
description = "sharedResourceIdPatch"
@@ -105,6 +114,14 @@ internal val sharedResourceIdPatch = resourcePatch(
105114
STRING,
106115
"account_switcher_accessibility_label",
107116
]
117+
actionBarLogo = resourceMappings[
118+
DRAWABLE,
119+
"action_bar_logo",
120+
]
121+
actionBarLogoRingo2 = resourceMappings[
122+
DRAWABLE,
123+
"action_bar_logo_ringo2",
124+
]
108125
bottomSheetRecyclerView = resourceMappings[
109126
LAYOUT,
110127
"bottom_sheet_recycler_view"
@@ -265,5 +282,13 @@ internal val sharedResourceIdPatch = resourcePatch(
265282
STRING,
266283
"varispeed_unavailable_title"
267284
]
285+
ytmLogo = resourceMappings[
286+
DRAWABLE,
287+
"ytm_logo",
288+
]
289+
ytmLogoRingo2 = resourceMappings[
290+
DRAWABLE,
291+
"ytm_logo_ringo2",
292+
]
268293
}
269294
}

patches/src/main/kotlin/app/revanced/util/BytecodeUtils.kt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,34 @@ fun MutableMethod.injectLiteralInstructionViewCall(
263263
)
264264
}
265265

266+
fun BytecodePatchContext.replaceLiteralInstructionCall(
267+
originalLiteral: Long,
268+
replaceLiteral: Long
269+
) {
270+
classes.forEach { classDef ->
271+
classDef.methods.forEach { method ->
272+
method.implementation.apply {
273+
this?.instructions?.forEachIndexed { _, instruction ->
274+
if (instruction.opcode != Opcode.CONST)
275+
return@forEachIndexed
276+
if ((instruction as Instruction31i).wideLiteral != originalLiteral)
277+
return@forEachIndexed
278+
279+
proxy(classDef)
280+
.mutableClass
281+
.findMutableMethodOf(method).apply {
282+
val index = indexOfFirstLiteralInstructionOrThrow(originalLiteral)
283+
val register =
284+
(instruction as OneRegisterInstruction).registerA
285+
286+
replaceInstruction(index, "const v$register, $replaceLiteral")
287+
}
288+
}
289+
}
290+
}
291+
}
292+
}
293+
266294
fun BytecodePatchContext.replaceLiteralInstructionCall(
267295
literal: Long,
268296
smaliInstruction: String

0 commit comments

Comments
 (0)