diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/Fingerprints.kt index abe67ad15..3be19dcce 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/Fingerprints.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/Fingerprints.kt @@ -11,6 +11,22 @@ internal val loadOrbitLibraryFingerprint = fingerprint { strings("/liborbit-jni-spotify.so") } +internal val setClientIdFingerprint = fingerprint { + parameters("Ljava/lang/String;") + custom { method, classDef -> + classDef.type == "Lcom/spotify/connectivity/ApplicationScopeConfiguration;" + && method.name == "setClientId" + } +} + +internal val setUserAgentFingerprint = fingerprint { + parameters("Ljava/lang/String;") + custom { method, classDef -> + classDef.type == "Lcom/spotify/connectivity/ApplicationScopeConfiguration;" + && method.name == "setDefaultHTTPUserAgent" + } +} + internal val extensionFixConstantsFingerprint = fingerprint { custom { _, classDef -> classDef.type == "Lapp/revanced/extension/spotify/misc/fix/Constants;" } } diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/SpoofClientPatch.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/SpoofClientPatch.kt index 49bb19704..b5d5bf22c 100644 --- a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/SpoofClientPatch.kt +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/SpoofClientPatch.kt @@ -1,5 +1,6 @@ package app.revanced.patches.spotify.misc.fix +import app.revanced.patcher.extensions.InstructionExtensions.addInstruction import app.revanced.patcher.extensions.InstructionExtensions.addInstructions import app.revanced.patcher.patch.bytecodePatch import app.revanced.patcher.patch.intOption @@ -72,7 +73,29 @@ val spoofClientPatch = bytecodePatch( compatibleWith("com.spotify.music") execute { - // region Spoof client. + val clientVersion = clientVersion!! + val hardwareMachine = hardwareMachine!! + val systemVersion = systemVersion!! + + // region Spoof login request. + + val version = clientVersion + .substringAfter('-') + .substringBeforeLast('.') + .substringBeforeLast('.') + + setUserAgentFingerprint.method.addInstruction( + 0, + "const-string p1, \"Spotify/$version iOS/$systemVersion ($hardwareMachine)\"" + ) + + setClientIdFingerprint.method.addInstruction( + 0, "const-string p1, \"58bd3c95768941ea9eb4350aaa033eb3\"" + ) + + // endregion + + // region Spoof client-token request. loadOrbitLibraryFingerprint.method.addInstructions( 0, @@ -83,9 +106,9 @@ val spoofClientPatch = bytecodePatch( ) mapOf( - "getClientVersion" to clientVersion!!, - "getSystemVersion" to systemVersion!!, - "getHardwareMachine" to hardwareMachine!! + "getClientVersion" to clientVersion, + "getSystemVersion" to systemVersion, + "getHardwareMachine" to hardwareMachine ).forEach { (methodName, value) -> extensionFixConstantsFingerprint.classDef.methods.single { it.name == methodName }.returnEarly(value) }