From 0787678c1274f573e1072ba7e013d0a7aae19d47 Mon Sep 17 00:00:00 2001 From: Leodyver Semilla <124951048+leodyversemilla07@users.noreply.github.com> Date: Tue, 7 Jul 2026 18:43:14 +0800 Subject: [PATCH] Don't use GMS to detect if GMS is available (#3525) Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> --- CHANGELOG.md | 3 +++ .../kotlin/mihon/telemetry/TelemetryConfig.kt | 13 ++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a978f5b6..2748503f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co - Display authors and description in Shikimori search results ([@MajorTanya](https://github.com/MajorTanya)) ([#3499](https://github.com/mihonapp/mihon/pull/3499)) - Invalidate download cache after backup restore ([@leodyversemilla07](https://github.com/leodyversemilla07)) ([#3096](https://github.com/mihonapp/mihon/pull/3096)) +### Changed +- Don't use GMS to detect if GMS is available ([@leodyversemilla07](https://github.com/leodyversemilla07)) ([#3525](https://github.com/mihonapp/mihon/pull/3525)) + ### Improved - Show usernames in Tracking settings ([@MajorTanya](https://github.com/MajorTanya)) ([#3533](https://github.com/mihonapp/mihon/pull/3533)) diff --git a/telemetry/src/firebase/kotlin/mihon/telemetry/TelemetryConfig.kt b/telemetry/src/firebase/kotlin/mihon/telemetry/TelemetryConfig.kt index 86a21ddc9..277a772fa 100644 --- a/telemetry/src/firebase/kotlin/mihon/telemetry/TelemetryConfig.kt +++ b/telemetry/src/firebase/kotlin/mihon/telemetry/TelemetryConfig.kt @@ -1,8 +1,7 @@ package mihon.telemetry import android.content.Context -import com.google.android.gms.common.ConnectionResult -import com.google.android.gms.common.GoogleApiAvailability +import android.content.pm.PackageManager import com.google.firebase.FirebaseApp import com.google.firebase.analytics.FirebaseAnalytics import com.google.firebase.crashlytics.FirebaseCrashlytics @@ -34,11 +33,11 @@ object TelemetryConfig { private fun isGooglePlayServicesAvailable(context: Context): Boolean { return try { - val availability = GoogleApiAvailability.getInstance() - val resultCode = availability.isGooglePlayServicesAvailable(context) - resultCode == ConnectionResult.SUCCESS - } catch (e: Exception) { - logcat(LogPriority.WARN, e) { "Unable to check Google Play Services availability" } + context.packageManager + .getPackageInfo("com.google.android.gms", PackageManager.GET_META_DATA) + .applicationInfo + ?.enabled == true + } catch (e: PackageManager.NameNotFoundException) { false } }