11package app.revanced.patches.music.layout.branding
22
3- import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
3+ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
44import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
55import app.revanced.patcher.patch.bytecodePatch
6- import app.revanced.patcher.util.smali.ExternalLabel
76import app.revanced.patches.music.misc.extension.sharedExtensionPatch
87import app.revanced.patches.music.misc.gms.Constants.MUSIC_MAIN_ACTIVITY_NAME
98import app.revanced.patches.music.misc.gms.Constants.MUSIC_PACKAGE_NAME
109import app.revanced.patches.music.misc.gms.musicActivityOnCreateFingerprint
1110import app.revanced.patches.music.misc.settings.PreferenceScreen
11+ import app.revanced.patches.shared.layout.branding.EXTENSION_CLASS_DESCRIPTOR
1212import app.revanced.patches.shared.layout.branding.baseCustomBrandingPatch
1313import app.revanced.patches.shared.misc.mapping.get
1414import app.revanced.patches.shared.misc.mapping.resourceMappingPatch
1515import app.revanced.patches.shared.misc.mapping.resourceMappings
1616import app.revanced.util.getReference
1717import app.revanced.util.indexOfFirstInstructionOrThrow
18- import app.revanced.util.indexOfFirstInstructionReversed
1918import app.revanced.util.indexOfFirstLiteralInstructionOrThrow
2019import com.android.tools.smali.dexlib2.Opcode
21- import com.android.tools.smali.dexlib2.iface.reference.MethodReference
20+ import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
21+ import com.android.tools.smali.dexlib2.iface.reference.TypeReference
2222
2323private val disableSplashAnimationPatch = bytecodePatch {
2424
@@ -33,23 +33,22 @@ private val disableSplashAnimationPatch = bytecodePatch {
3333 // but the animation is not always the same size as the launch screen and it's still
3434 // barely shown. Instead turn off the animation entirely (app will also launch a little faster).
3535 cairoSplashAnimationConfigFingerprint.method.apply {
36- val mainActivityLaunchAnimation = resourceMappings[" layout" , " main_activity_launch_animation" ]
3736 val literalIndex = indexOfFirstLiteralInstructionOrThrow(
38- mainActivityLaunchAnimation
37+ resourceMappings[ " layout " , " main_activity_launch_animation " ]
3938 )
40- val insertIndex = indexOfFirstInstructionReversed(literalIndex) {
41- this .opcode == Opcode .INVOKE_VIRTUAL &&
42- getReference<MethodReference >()?.name == " setContentView"
43- } + 1
44- val jumpIndex = indexOfFirstInstructionOrThrow(insertIndex) {
45- opcode == Opcode .INVOKE_VIRTUAL &&
46- getReference<MethodReference >()?.parameterTypes?.firstOrNull() == " Ljava/lang/Runnable;"
47- } + 1
39+ val checkCastIndex = indexOfFirstInstructionOrThrow(literalIndex) {
40+ opcode == Opcode .CHECK_CAST &&
41+ getReference<TypeReference >()?.type == " Lcom/airbnb/lottie/LottieAnimationView;"
42+ }
43+ val register = getInstruction<OneRegisterInstruction >(checkCastIndex).registerA
4844
49- addInstructionsWithLabels(
50- insertIndex,
51- " goto :skip_animation" ,
52- ExternalLabel (" skip_animation" , getInstruction(jumpIndex))
45+ // If using a custom icon then set the lottie animation view to null to bypasses the startup animation.
46+ addInstructions(
47+ checkCastIndex,
48+ """
49+ invoke-static { v$register }, $EXTENSION_CLASS_DESCRIPTOR ->getLottieViewOrNull(Landroid/view/View;)Landroid/view/View;
50+ move-result-object v$register
51+ """
5352 )
5453 }
5554 }
0 commit comments