GmsCore icon indicating copy to clipboard operation
GmsCore copied to clipboard

GoogleApiAvailability.isGooglePlayServicesAvailable(Context context) always return SUCCESS

Open papjul opened this issue 1 year ago • 6 comments

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_MISSING if com.google.android.gms is not installed
  • ConnectionResult.SERVICE_UPDATING if ̀com.google.android.gms is currently updating and is not available
  • ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED if the lib version by the app is incompatible with com.google.android.gms version (must handle both microG and Google Play versions).
  • ConnectionResult.SERVICE_DISABLED if user has disabled com.google.android.gms package
  • ConnectionResult.SERVICE_INVALID for example if the signature of the com.google.android.gms package is not Google or microG signature, if failed to parse Manifest, etc
  • ConnectionResult.SUCCESS finally, if com.google.android.gms succeeded 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

papjul avatar Apr 10 '24 14:04 papjul

@fynngodau implemented this dummy implementation in https://github.com/microg/GmsCore/pull/1398 3 years ago...

CoelacanthusHex avatar Apr 10 '24 15:04 CoelacanthusHex

That's not the same thing, we use isGooglePlayServicesAvailable (Context context), not isGooglePlayServicesAvailable (Context context, int minApkVersion)

papjul avatar Apr 10 '24 15:04 papjul

Oh, my bad. I don't notice the different parameters.

CoelacanthusHex avatar Apr 10 '24 15:04 CoelacanthusHex

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?

Atemu avatar Nov 14 '24 08:11 Atemu

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.

papjul avatar Nov 14 '24 08:11 papjul

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.

CoelacanthusHex avatar Nov 15 '24 14:11 CoelacanthusHex