generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat:
hide-premium-nav-bar
patch (#589)
- Loading branch information
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
.../revanced/patches/spotify/premium_navbar_tab/annotations/PremiumNavbarTabCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package app.revanced.patches.spotify.premium_navbar_tab.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility([Package("com.spotify.music")]) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class PremiumNavbarTabCompatibility |
13 changes: 13 additions & 0 deletions
13
...evanced/patches/spotify/premium_navbar_tab/fingerprints/AddPremiumNavbarTabFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package app.revanced.patches.spotify.premium_navbar_tab.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.spotify.premium_navbar_tab.annotations.PremiumNavbarTabCompatibility | ||
|
||
@Name("premium-navbar-fingerprint") | ||
@Version("0.0.1") | ||
@PremiumNavbarTabCompatibility | ||
object AddPremiumNavbarTabFingerprint : MethodFingerprint( | ||
parameters = listOf("L", "L", "L", "L", "L", "L") | ||
) |
14 changes: 14 additions & 0 deletions
14
.../revanced/patches/spotify/premium_navbar_tab/fingerprints/DebugMenuActivityFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package app.revanced.patches.spotify.premium_navbar_tab.fingerprints | ||
|
||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.spotify.premium_navbar_tab.annotations.PremiumNavbarTabCompatibility | ||
|
||
@Name("debug-menu-activity-fingerprint") | ||
@Version("0.0.1") | ||
@PremiumNavbarTabCompatibility | ||
object DebugMenuActivityFingerprint : MethodFingerprint( | ||
strings = listOf("com.spotify.app.music.debugtools.menu.DebugMenuActivity"), | ||
parameters = listOf("L", "L"), | ||
) |
56 changes: 56 additions & 0 deletions
56
...ain/kotlin/app/revanced/patches/spotify/premium_navbar_tab/patch/PremiumNavbarTabPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package app.revanced.patches.spotify.premium_navbar_tab.patch | ||
|
||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.data.impl.BytecodeData | ||
import app.revanced.patcher.extensions.addInstructions | ||
import app.revanced.patcher.extensions.removeInstruction | ||
import app.revanced.patcher.extensions.replaceInstruction | ||
import app.revanced.patcher.fingerprint.method.utils.MethodFingerprintUtils.resolve | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.DependsOn | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patcher.patch.impl.BytecodePatch | ||
import app.revanced.patches.spotify.premium_navbar_tab.annotations.PremiumNavbarTabCompatibility | ||
import app.revanced.patches.spotify.premium_navbar_tab.fingerprints.AddPremiumNavbarTabFingerprint | ||
import app.revanced.patches.spotify.premium_navbar_tab.fingerprints.DebugMenuActivityFingerprint | ||
import app.revanced.patches.youtube.misc.mapping.patch.ResourceIdMappingProviderResourcePatch | ||
import org.jf.dexlib2.Opcode | ||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction | ||
|
||
@Patch | ||
@Name("hide-premium-nav-bar") | ||
@Description("Removes the premium tab from the navbar.") | ||
@PremiumNavbarTabCompatibility | ||
@Version("0.0.1") | ||
@DependsOn([ResourceIdMappingProviderResourcePatch::class]) | ||
class PremiumNavbarTabPatch : BytecodePatch( | ||
listOf( | ||
DebugMenuActivityFingerprint | ||
) | ||
) { | ||
override fun execute(data: BytecodeData): PatchResult { | ||
val parentResult = DebugMenuActivityFingerprint.result!! | ||
AddPremiumNavbarTabFingerprint.resolve(data, parentResult.classDef) | ||
|
||
val result = AddPremiumNavbarTabFingerprint.result!! | ||
val method = result.mutableMethod | ||
|
||
val premiumTabId = ResourceIdMappingProviderResourcePatch.resourceMappings.single{it.type == "id" && it.name == "premium_tab"}.id.toInt() | ||
|
||
val methodInstructions = method.implementation!!.instructions | ||
|
||
for ((i, instruction) in methodInstructions.asReversed().withIndex()) { | ||
if (instruction.opcode.ordinal != Opcode.CONST.ordinal) continue | ||
if ((instruction as OneRegisterInstruction).registerA != premiumTabId) continue | ||
val constIdx = methodInstructions.size - i | ||
val methodIdx = constIdx + 8 | ||
method.removeInstruction(methodIdx) | ||
break | ||
} | ||
|
||
return PatchResultSuccess() | ||
} | ||
} |