From a7d0cd81eec69358eeb83d72637f82b0c1c4b015 Mon Sep 17 00:00:00 2001 From: LisoUseInAIKyrios <118716522+LisoUseInAIKyrios@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:23:59 +0400 Subject: [PATCH] fix: Use activity fingerprint for YT Music, so GmsCore can show a dialog --- .../patches/music/misc/gms/GmsCoreSupportPatch.kt | 6 +----- .../fingerprints/MusicActivityOnCreateFingerprint.kt | 11 +++++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 src/main/kotlin/app/revanced/patches/music/misc/gms/fingerprints/MusicActivityOnCreateFingerprint.kt diff --git a/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt b/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt index 28a86b8236..3c99992fce 100644 --- a/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt +++ b/src/main/kotlin/app/revanced/patches/music/misc/gms/GmsCoreSupportPatch.kt @@ -5,7 +5,6 @@ import app.revanced.patches.music.misc.gms.Constants.REVANCED_MUSIC_PACKAGE_NAME import app.revanced.patches.music.misc.gms.GmsCoreSupportResourcePatch.gmsCoreVendorGroupIdOption import app.revanced.patches.music.misc.gms.fingerprints.* import app.revanced.patches.music.misc.integrations.IntegrationsPatch -import app.revanced.patches.music.misc.integrations.fingerprints.ApplicationInitFingerprint import app.revanced.patches.shared.fingerprints.CastContextFetchFingerprint import app.revanced.patches.shared.misc.gms.BaseGmsCoreSupportPatch @@ -21,10 +20,7 @@ object GmsCoreSupportPatch : BaseGmsCoreSupportPatch( CastDynamiteModuleV2Fingerprint, CastContextFetchFingerprint, ), - // This fingerprint could be improved by using a main Activity, - // as that allows showing a dialog if GmsCore is not whitelisted for battery optimizations. - // Because using this fingerprint only allows showing a brief toast and then opening a website. - mainActivityOnCreateFingerprint = ApplicationInitFingerprint, + mainActivityOnCreateFingerprint = MusicActivityOnCreateFingerprint, integrationsPatchDependency = IntegrationsPatch::class, gmsCoreSupportResourcePatch = GmsCoreSupportResourcePatch, compatiblePackages = setOf(CompatiblePackage("com.google.android.apps.youtube.music")), diff --git a/src/main/kotlin/app/revanced/patches/music/misc/gms/fingerprints/MusicActivityOnCreateFingerprint.kt b/src/main/kotlin/app/revanced/patches/music/misc/gms/fingerprints/MusicActivityOnCreateFingerprint.kt new file mode 100644 index 0000000000..2e46df2d96 --- /dev/null +++ b/src/main/kotlin/app/revanced/patches/music/misc/gms/fingerprints/MusicActivityOnCreateFingerprint.kt @@ -0,0 +1,11 @@ +package app.revanced.patches.music.misc.gms.fingerprints + +import app.revanced.patcher.fingerprint.MethodFingerprint + +internal object MusicActivityOnCreateFingerprint : MethodFingerprint( + returnType = "V", + parameters = listOf("Landroid/os/Bundle;"), + customFingerprint = { methodDef, classDef -> + methodDef.name == "onCreate" && classDef.type.endsWith("/MusicActivity;") + } +) \ No newline at end of file