Don't use GMS to detect if GMS is available (#3525)

Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
This commit is contained in:
Leodyver Semilla
2026-07-07 18:43:14 +08:00
committed by GitHub
parent d0c79399b9
commit 0787678c12
2 changed files with 9 additions and 7 deletions
+3
View File
@@ -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)) - 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)) - 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 ### Improved
- Show usernames in Tracking settings ([@MajorTanya](https://github.com/MajorTanya)) ([#3533](https://github.com/mihonapp/mihon/pull/3533)) - Show usernames in Tracking settings ([@MajorTanya](https://github.com/MajorTanya)) ([#3533](https://github.com/mihonapp/mihon/pull/3533))
@@ -1,8 +1,7 @@
package mihon.telemetry package mihon.telemetry
import android.content.Context import android.content.Context
import com.google.android.gms.common.ConnectionResult import android.content.pm.PackageManager
import com.google.android.gms.common.GoogleApiAvailability
import com.google.firebase.FirebaseApp import com.google.firebase.FirebaseApp
import com.google.firebase.analytics.FirebaseAnalytics import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.crashlytics.FirebaseCrashlytics import com.google.firebase.crashlytics.FirebaseCrashlytics
@@ -34,11 +33,11 @@ object TelemetryConfig {
private fun isGooglePlayServicesAvailable(context: Context): Boolean { private fun isGooglePlayServicesAvailable(context: Context): Boolean {
return try { return try {
val availability = GoogleApiAvailability.getInstance() context.packageManager
val resultCode = availability.isGooglePlayServicesAvailable(context) .getPackageInfo("com.google.android.gms", PackageManager.GET_META_DATA)
resultCode == ConnectionResult.SUCCESS .applicationInfo
} catch (e: Exception) { ?.enabled == true
logcat(LogPriority.WARN, e) { "Unable to check Google Play Services availability" } } catch (e: PackageManager.NameNotFoundException) {
false false
} }
} }