GmsCore
GmsCore copied to clipboard
GoogleApiAvailability.isGooglePlayServicesAvailable(Context context) always return SUCCESS
Describe the bug
As a library used as a substitute for Google libraries, the function should have the expect behavior. Currently, this return SUCCESS on devices with neither Google Play Services or microG services.
To Reproduce See the code, it's self-speaking: https://github.com/microg/GmsCore/blob/v0.3.1.240913/play-services-base/src/main/java/com/google/android/gms/common/GoogleApiAvailability.java#L160-L164
Expected behavior The function should return one of the following:
ConnectionResult.SERVICE_MISSINGifcom.google.android.gmsis not installedConnectionResult.SERVICE_UPDATINGif ̀com.google.android.gmsis currently updating and is not availableConnectionResult.SERVICE_VERSION_UPDATE_REQUIREDif the lib version by the app is incompatible withcom.google.android.gmsversion (must handle both microG and Google Play versions).ConnectionResult.SERVICE_DISABLEDif user has disabledcom.google.android.gmspackageConnectionResult.SERVICE_INVALIDfor example if the signature of thecom.google.android.gmspackage is not Google or microG signature, if failed to parse Manifest, etcConnectionResult.SUCCESSfinally, ifcom.google.android.gmssucceeded in all checks, this is what should be returned
I think the most important things to do in priority are: package is installed, not disabled and signature is valid.
Additional context
I intend to use play-services-location as a subtitle library in Breezy Weather, see breezy-weather/breezy-weather#901
@fynngodau implemented this dummy implementation in https://github.com/microg/GmsCore/pull/1398 3 years ago...
That's not the same thing, we use isGooglePlayServicesAvailable (Context context), not isGooglePlayServicesAvailable (Context context, int minApkVersion)
Oh, my bad. I don't notice the different parameters.
I hit this bug in https://github.com/organicmaps/organicmaps/pull/9575 too.
We don't need a full implementation for this to work for @papjul and my purposes, we just need a yes/no check to see whether GMS is usable or not. Would that be acceptable?
FYI, I remember hitting other issues of many unimplemented functions with this lib, so I'm not sure this can be used in an app.
I was mostly using GMS for the FUSED provider, which I found out to be available in the native SDK without any dependency on Android 12+, so I no longer use any Google lib.
Android versions lower than 12 are EoL, so falling back to NETWORK, GPS or PASSIVE for them was acceptable for my use case.
I think it's enough for most cases if we implement ConnectionResult.SERVICE_DISABLED and ConnectionResult.SERVICE_MISSING check. It's simple to implement.
ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED is difficult to check and return SUCCESS is fine in many cases.
ConnectionResult.SERVICE_INVALID and ConnectionResult.SERVICE_UPDATING are hard to meet.