Skip to content

Commit 886b9dd

Browse files
committed
Clean up
1 parent d36ba9d commit 886b9dd

File tree

4 files changed

+25
-14
lines changed

4 files changed

+25
-14
lines changed

patches/src/main/kotlin/app/revanced/patches/spotify/lite/ondemand/OnDemandPatch.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ import app.revanced.patcher.patch.bytecodePatch
66
@Suppress("unused")
77
val onDemandPatch = bytecodePatch(
88
description = "Enables listening to songs on-demand, allowing to play any song from playlists, albums or artists without limitations. This does not remove ads.",
9-
) {}
9+
)

patches/src/main/kotlin/app/revanced/patches/spotify/misc/Fingerprints.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ internal val contextFromJsonFingerprint = fingerprint {
7777
)
7878
custom { method, classDef ->
7979
method.name == "fromJson" &&
80-
classDef.endsWith("voiceassistants/playermodels/ContextJsonAdapter;")
80+
classDef.type.endsWith("voiceassistants/playermodels/ContextJsonAdapter;")
8181
}
8282
}
8383

8484
internal val readPlayerOptionOverridesFingerprint = fingerprint {
8585
custom { method, classDef ->
8686
method.name == "readPlayerOptionOverrides" &&
87-
classDef.endsWith("voiceassistants/playermodels/PreparePlayOptionsJsonAdapter;")
87+
classDef.type.endsWith("voiceassistants/playermodels/PreparePlayOptionsJsonAdapter;")
8888
}
8989
}
9090

@@ -106,21 +106,21 @@ internal val abstractProtobufListEnsureIsMutableFingerprint = fingerprint {
106106

107107
internal fun structureGetSectionsFingerprint(className: String) = fingerprint {
108108
custom { method, classDef ->
109-
classDef.endsWith(className) && method.indexOfFirstInstruction {
109+
classDef.type.endsWith(className) && method.indexOfFirstInstruction {
110110
opcode == Opcode.IGET_OBJECT && getReference<FieldReference>()?.name == "sections_"
111111
} >= 0
112112
}
113113
}
114114

115115
internal val homeSectionFingerprint = fingerprint {
116-
custom { _, classDef -> classDef.endsWith("homeapi/proto/Section;") }
116+
custom { _, classDef -> classDef.type.endsWith("homeapi/proto/Section;") }
117117
}
118118

119119
internal val homeStructureGetSectionsFingerprint =
120120
structureGetSectionsFingerprint("homeapi/proto/HomeStructure;")
121121

122122
internal val browseSectionFingerprint = fingerprint {
123-
custom { _, classDef-> classDef.endsWith("browsita/v1/resolved/Section;") }
123+
custom { _, classDef-> classDef.type.endsWith("browsita/v1/resolved/Section;") }
124124
}
125125

126126
internal val browseStructureGetSectionsFingerprint =

patches/src/main/kotlin/app/revanced/patches/spotify/misc/lyrics/ChangeLyricsProviderPatch.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ val changeLyricsProviderPatch = bytecodePatch(
5959
val httpClientBuilderMethod = httpClientBuilderFingerprint.originalMethod
6060

6161
// region Create a modified copy of the HTTP client builder method with the custom lyrics provider host.
62+
6263
val patchedHttpClientBuilderMethod = with(httpClientBuilderMethod) {
6364
val invokeBuildUrlIndex = indexOfFirstInstructionOrThrow {
6465
getReference<MethodReference>()?.returnType == "Lokhttp3/HttpUrl;"
@@ -81,9 +82,11 @@ val changeLyricsProviderPatch = bytecodePatch(
8182
httpClientBuilderFingerprint.classDef.methods.add(this)
8283
}
8384
}
85+
8486
//endregion
8587

8688
// region Replace the call to the HTTP client builder method used exclusively for lyrics by the modified one.
89+
8790
getLyricsHttpClientFingerprint(httpClientBuilderMethod).method.apply {
8891
val getLyricsHttpClientIndex = indexOfFirstInstructionOrThrow {
8992
getReference<MethodReference>() == httpClientBuilderMethod
@@ -110,6 +113,7 @@ val changeLyricsProviderPatch = bytecodePatch(
110113
)
111114
)
112115
}
116+
113117
//endregion
114118
}
115119
}

patches/src/main/kotlin/app/revanced/patches/spotify/misc/privacy/SanitizeSharingLinksPatch.kt

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ val sanitizeSharingLinksPatch = bytecodePatch(
2626
val extensionMethodDescriptor = "$EXTENSION_CLASS_DESCRIPTOR->" +
2727
"sanitizeUrl(Ljava/lang/String;)Ljava/lang/String;"
2828

29-
val copyMethod = shareCopyUrlFingerprint.methodOrNull ?: oldShareCopyUrlFingerprint.method
29+
val copyFingerprint = if (shareCopyUrlFingerprint.originalMethodOrNull != null) {
30+
shareCopyUrlFingerprint
31+
} else {
32+
oldShareCopyUrlFingerprint
33+
}
3034

31-
copyMethod.apply {
35+
copyFingerprint.method.apply {
3236
val newPlainTextInvokeIndex = indexOfFirstInstructionOrThrow {
3337
getReference<MethodReference>()?.name == "newPlainText"
3438
}
@@ -44,22 +48,25 @@ val sanitizeSharingLinksPatch = bytecodePatch(
4448
}
4549

4650
// Android native share sheet is used for all other quick share types (X, WhatsApp, etc).
47-
var shareUrlParameter = ""
48-
val shareSheetMethod = formatAndroidShareSheetUrlFingerprint.methodOrNull?.also {
49-
val methodAccessFlags = formatAndroidShareSheetUrlFingerprint.originalMethod.accessFlags
50-
shareUrlParameter = if (AccessFlags.STATIC.isSet(methodAccessFlags)) {
51+
val shareUrlParameter: String
52+
val shareSheetFingerprint = if (formatAndroidShareSheetUrlFingerprint.originalMethodOrNull != null) {
53+
val methodAccessFlags = formatAndroidShareSheetUrlFingerprint.originalMethod
54+
shareUrlParameter = if (AccessFlags.STATIC.isSet(methodAccessFlags.accessFlags)) {
5155
// In newer implementations the method is static, so p0 is not `this`.
5256
"p1"
5357
} else {
5458
// In older implementations the method is not static, making it so p0 is `this`.
5559
// For that reason, add one to the parameter register.
5660
"p2"
5761
}
58-
} ?: oldFormatAndroidShareSheetUrlFingerprint.method.also {
62+
63+
formatAndroidShareSheetUrlFingerprint
64+
} else {
5965
shareUrlParameter = "p2"
66+
oldFormatAndroidShareSheetUrlFingerprint
6067
}
6168

62-
shareSheetMethod.addInstructions(
69+
shareSheetFingerprint.method.addInstructions(
6370
0,
6471
"""
6572
invoke-static { $shareUrlParameter }, $extensionMethodDescriptor

0 commit comments

Comments
 (0)