@@ -78,7 +78,7 @@ internal fun baseCustomBrandingPatch(
7878 originalLauncherIconName : String ,
7979 originalAppName : String ,
8080 originalAppPackageName : String ,
81- copyExistingIntentsToAliases : Boolean ,
81+ isYouTubeMusic : Boolean ,
8282 numberOfPresetAppNames : Int ,
8383 mainActivityOnCreateFingerprint : Fingerprint ,
8484 mainActivityName : String ,
@@ -130,15 +130,23 @@ internal fun baseCustomBrandingPatch(
130130 numberOfPresetAppNamesExtensionFingerprint.method.returnEarly(numberOfPresetAppNames)
131131
132132 notificationFingerprint.method.apply {
133- // Find the field name of the notification builder. Field is an Object type.
134- val builderCastIndex = indexOfFirstInstructionOrThrow {
135- val reference = getReference<TypeReference >()
136- opcode == Opcode .CHECK_CAST &&
137- reference?.type == " Landroid/app/Notification\$ Builder;"
138- }
139- val getBuilderIndex = indexOfFirstInstructionReversedOrThrow(builderCastIndex) {
140- getReference<FieldReference >()?.type == " Ljava/lang/Object;"
133+ val getBuilderIndex = if (isYouTubeMusic) {
134+ // YT Music the field is not a plain object type.
135+ indexOfFirstInstructionOrThrow {
136+ getReference<FieldReference >()?.type == " Landroid/app/Notification\$ Builder;"
137+ }
138+ } else {
139+ // Find the field name of the notification builder. Field is an Object type.
140+ val builderCastIndex = indexOfFirstInstructionOrThrow {
141+ val reference = getReference<TypeReference >()
142+ opcode == Opcode .CHECK_CAST &&
143+ reference?.type == " Landroid/app/Notification\$ Builder;"
144+ }
145+ indexOfFirstInstructionReversedOrThrow(builderCastIndex) {
146+ getReference<FieldReference >()?.type == " Ljava/lang/Object;"
147+ }
141148 }
149+
142150 val builderFieldName = getInstruction<ReferenceInstruction >(getBuilderIndex)
143151 .getReference<FieldReference >()
144152
@@ -282,13 +290,7 @@ internal fun baseCustomBrandingPatch(
282290 alias.setAttribute(" android:targetActivity" , mainActivityName)
283291
284292 // Copy all intents from the original alias so long press actions still work.
285- if (copyExistingIntentsToAliases) {
286- for (i in 0 until intents.length) {
287- alias.appendChild(
288- intents.item(i).cloneNode(true )
289- )
290- }
291- } else {
293+ if (isYouTubeMusic) {
292294 val intentFilter = document.createElement(" intent-filter" ).apply {
293295 val action = document.createElement(" action" )
294296 action.setAttribute(" android:name" , " android.intent.action.MAIN" )
@@ -299,6 +301,12 @@ internal fun baseCustomBrandingPatch(
299301 appendChild(category)
300302 }
301303 alias.appendChild(intentFilter)
304+ } else {
305+ for (i in 0 until intents.length) {
306+ alias.appendChild(
307+ intents.item(i).cloneNode(true )
308+ )
309+ }
302310 }
303311
304312 return alias
0 commit comments