From 23bfdc98fbbcc8ecf0ffbf8704f58dd2272e4af2 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 16 May 2025 14:14:26 -0300 Subject: [PATCH] feat(Spotify): Add `Fix third party launchers widgets` patch (#4893) Co-authored-by: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> --- patches/api/patches.api | 4 ++++ .../spotify/misc/widgets/Fingerprints.kt | 10 ++++++++++ .../widgets/FixThirdPartyLaunchersWidgets.kt | 17 +++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 patches/src/main/kotlin/app/revanced/patches/spotify/misc/widgets/Fingerprints.kt create mode 100644 patches/src/main/kotlin/app/revanced/patches/spotify/misc/widgets/FixThirdPartyLaunchersWidgets.kt diff --git a/patches/api/patches.api b/patches/api/patches.api index f8acb38ca..62abd88f7 100644 --- a/patches/api/patches.api +++ b/patches/api/patches.api @@ -876,6 +876,10 @@ public final class app/revanced/patches/spotify/misc/privacy/SanitizeSharingLink public static final fun getSanitizeSharingLinksPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } +public final class app/revanced/patches/spotify/misc/widgets/FixThirdPartyLaunchersWidgetsKt { + public static final fun getFixThirdPartyLaunchersWidgets ()Lapp/revanced/patcher/patch/BytecodePatch; +} + public final class app/revanced/patches/spotify/navbar/PremiumNavbarTabPatchKt { public static final fun getPremiumNavbarTabPatch ()Lapp/revanced/patcher/patch/BytecodePatch; } diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/widgets/Fingerprints.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/widgets/Fingerprints.kt new file mode 100644 index 000000000..0fc536047 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/widgets/Fingerprints.kt @@ -0,0 +1,10 @@ +package app.revanced.patches.spotify.misc.widgets + +import app.revanced.patcher.fingerprint +import app.revanced.util.indexOfFirstInstruction +import com.android.tools.smali.dexlib2.Opcode + +internal val canBindAppWidgetPermissionFingerprint = fingerprint { + strings("android.permission.BIND_APPWIDGET") + opcodes(Opcode.AND_INT_LIT8) +} diff --git a/patches/src/main/kotlin/app/revanced/patches/spotify/misc/widgets/FixThirdPartyLaunchersWidgets.kt b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/widgets/FixThirdPartyLaunchersWidgets.kt new file mode 100644 index 000000000..f0ec93bb6 --- /dev/null +++ b/patches/src/main/kotlin/app/revanced/patches/spotify/misc/widgets/FixThirdPartyLaunchersWidgets.kt @@ -0,0 +1,17 @@ +package app.revanced.patches.spotify.misc.widgets + +import app.revanced.patcher.patch.bytecodePatch +import app.revanced.util.returnEarly + +@Suppress("unused") +val fixThirdPartyLaunchersWidgets = bytecodePatch( + name = "Fix third party launchers widgets", + description = "Fixes Spotify widgets not working in third party launchers, like Nova Launcher.", +) { + execute { + // Only system app launchers are granted the BIND_APPWIDGET permission. + // Override the method that checks for it to always return true, as this permission is not actually required + // for the widgets to work. + canBindAppWidgetPermissionFingerprint.method.returnEarly(true) + } +}