Skip to content

Commit 2269423

Browse files
committed
More clean up
1 parent ad1ae76 commit 2269423

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

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

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -167,25 +167,25 @@ val unlockPremiumPatch = bytecodePatch(
167167
// Overwrite the context menu items list with a filtered version which does not include items which are
168168
// Premium ads.
169169
if (oldContextMenuViewModelAddItemFingerprint.matchOrNull(contextMenuViewModelClassDef) == null) {
170-
val contextMenuItemInterfaceClassDef = browsePodcastsContextMenuItemClassFingerprint
171-
.originalClassDef
172-
.interfaces
173-
.firstOrNull()
174-
?.let { interfaceName -> classes.find { it.type == interfaceName } }
175-
?: throw PatchException("Could not find context menu item interface.")
176-
177-
val contextMenuItemInterfaceName = contextMenuItemInterfaceClassDef.type
178-
179-
val contextMenuItemViewModelClassName = getViewModelFingerprint
180-
.matchOrNull(contextMenuItemInterfaceClassDef)
181-
?.originalMethod
182-
?.returnType
183-
?: throw PatchException("Could not find context menu item view model class.")
184-
185170
// Replace the placeholder context menu item interface name and the return value of getViewModel to the
186171
// minified names used at runtime. The instructions need to match the original names so we can call the
187172
// method in the extension.
188173
extensionFilterContextMenuItemsFingerprint.method.apply {
174+
val contextMenuItemInterfaceClassDef = browsePodcastsContextMenuItemClassFingerprint
175+
.originalClassDef
176+
.interfaces
177+
.firstOrNull()
178+
?.let { interfaceName -> classes.find { it.type == interfaceName } }
179+
?: throw PatchException("Could not find context menu item interface.")
180+
181+
val contextMenuItemInterfaceName = contextMenuItemInterfaceClassDef.type
182+
183+
val contextMenuItemViewModelClassName = getViewModelFingerprint
184+
.matchOrNull(contextMenuItemInterfaceClassDef)
185+
?.originalMethod
186+
?.returnType
187+
?: throw PatchException("Could not find context menu item view model class.")
188+
189189
val castContextMenuItemStubIndex = indexOfFirstInstructionOrThrow {
190190
getReference<TypeReference>()?.type == CONTEXT_MENU_ITEM_PLACEHOLDER_CLASS_NAME
191191
}
@@ -208,16 +208,18 @@ val unlockPremiumPatch = bytecodePatch(
208208
)
209209
}
210210

211-
val filterContextMenuItemsDescriptor =
212-
"$EXTENSION_CLASS_DESCRIPTOR->filterContextMenuItems(Ljava/util/List;)Ljava/util/List;"
211+
contextMenuViewModelConstructorFingerprint.match(contextMenuViewModelClassDef).method.apply {
212+
val filterContextMenuItemsDescriptor =
213+
"$EXTENSION_CLASS_DESCRIPTOR->filterContextMenuItems(Ljava/util/List;)Ljava/util/List;"
213214

214-
contextMenuViewModelConstructorFingerprint.match(contextMenuViewModelClassDef).method.addInstructions(
215-
0,
216-
"""
217-
invoke-static { p3 }, $filterContextMenuItemsDescriptor
218-
move-result-object p3
219-
"""
220-
)
215+
addInstructions(
216+
0,
217+
"""
218+
invoke-static { p3 }, $filterContextMenuItemsDescriptor
219+
move-result-object p3
220+
"""
221+
)
222+
}
221223
}
222224

223225

patches/src/main/kotlin/app/revanced/patches/spotify/misc/fix/SpoofClientPatch.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ val spoofClientPatch = bytecodePatch(
117117
val openLoginWebViewDescriptor =
118118
"$EXTENSION_CLASS_DESCRIPTOR->launchLogin(Landroid/view/LayoutInflater;)V"
119119

120-
addInstruction(
120+
addInstructions(
121121
0,
122-
"invoke-static/range { p1 .. p1 }, $openLoginWebViewDescriptor"
122+
"""
123+
invoke-static/range { p1 .. p1 }, $openLoginWebViewDescriptor
124+
"""
123125
)
124126
}
125127

0 commit comments

Comments
 (0)