fix(Spotify - Unlock Premium): Override additional attributes (#4651)

Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com>
This commit is contained in:
xC3FFF0E
2025-03-28 18:52:23 +08:00
committed by GitHub
parent 5f4c42bfa9
commit 568b40da96
7 changed files with 82 additions and 26 deletions

View File

@ -10,6 +10,7 @@ import org.w3c.dom.Element
val customThemePatch = resourcePatch(
name = "Custom theme",
description = "Applies a custom theme.",
use = false,
) {
compatibleWith("com.spotify.music")

View File

@ -4,9 +4,12 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstruction
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
import app.revanced.patcher.patch.bytecodePatch
import app.revanced.patches.spotify.misc.extension.sharedExtensionPatch
import com.android.tools.smali.dexlib2.AccessFlags
import com.android.tools.smali.dexlib2.iface.instruction.OneRegisterInstruction
private const val EXTENSION_CLASS_DESCRIPTOR = "Lapp/revanced/extension/spotify/misc/UnlockPremiumPatch;"
@Suppress("unused")
val unlockPremiumPatch = bytecodePatch(
name = "Unlock Spotify Premium",
@ -14,11 +17,12 @@ val unlockPremiumPatch = bytecodePatch(
) {
compatibleWith("com.spotify.music")
extendWith("extensions/spotify.rve")
dependsOn(sharedExtensionPatch)
execute {
// Make _value accessible so that it can be overridden in the extension.
accountAttributeFingerprint.classDef.fields.first { it.name == "value_" }.apply {
// Add public flag and remove private.
accessFlags = accessFlags.or(AccessFlags.PUBLIC.value).and(AccessFlags.PRIVATE.value.inv())
}
@ -28,7 +32,7 @@ val unlockPremiumPatch = bytecodePatch(
productStateProtoFingerprint.method.addInstruction(
instantiateUnmodifiableMapIndex,
"invoke-static { v$attributesMapRegister }," +
"Lapp/revanced/extension/spotify/misc/UnlockPremiumPatch;->overrideAttribute(Ljava/util/Map;)V",
"$EXTENSION_CLASS_DESCRIPTOR->overrideAttribute(Ljava/util/Map;)V",
)
// Add the query parameter trackRows to show popular tracks in the artist page.

View File

@ -0,0 +1,5 @@
package app.revanced.patches.spotify.misc.extension
import app.revanced.patches.shared.misc.extension.sharedExtensionPatch
val sharedExtensionPatch = sharedExtensionPatch("spotify", spotifyMainActivityOnCreate)

View File

@ -0,0 +1,10 @@
package app.revanced.patches.spotify.misc.extension
import app.revanced.patches.shared.misc.extension.extensionHook
internal val spotifyMainActivityOnCreate = extensionHook {
custom { method, classDef ->
classDef.type == "Lcom/spotify/music/SpotifyMainActivity;" &&
method.name == "onCreate"
}
}