Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Play Service error handle #2900

Closed

Conversation

anandwana001
Copy link
Collaborator

Copy link

codecov bot commented Dec 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.52%. Comparing base (9ef90ad) to head (685d5e6).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #2900   +/-   ##
=========================================
  Coverage     62.52%   62.52%           
  Complexity     1203     1203           
=========================================
  Files           267      267           
  Lines          6357     6357           
  Branches        881      881           
=========================================
  Hits           3975     3975           
  Misses         1831     1831           
  Partials        551      551           

Copy link
Collaborator

@gino-m gino-m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a first pass, @shobhitagarwal1612 PTAL as well?

} catch (e: Exception) {
Timber.e(
e,
"Failed to handle activity result for requestCode: $requestCode. Exception details: ${e.message}",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message and stack trace are already logged by Timber.e, no need to add it to the message as well.

@@ -37,29 +38,31 @@ constructor(
* Displays a dialog to install Google Play Services, if missing. Throws an error if install not
* possible or cancelled.
*/
suspend fun installGooglePlayServices() {
suspend fun installGooglePlayServices(): Boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a Boolean return value means the caller needs to address both return value and thrown exceptions as failure states. Since we need to catch exceptions anyway, why not rely on those for error states?

}

private fun startResolution(status: Int, requestCode: Int, throwable: Throwable) {
if (!googleApiAvailability.isUserResolvableError(status)) throw throwable
private suspend fun startResolution(status: Int, requestCode: Int): Boolean {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here.

@@ -29,7 +29,10 @@ internal constructor(

/** Checks & installs Google Play Services and initializes the login flow. */
suspend fun initializeLogin() {
googleApiManager.installGooglePlayServices()
val isGooglePlayServicesAvailable = googleApiManager.installGooglePlayServices()
if (!isGooglePlayServicesAvailable) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here. This entire condition goes away if installGooglePlayServices throws an exception.

# Conflicts:
#	ground/src/main/java/com/google/android/ground/system/GoogleApiManager.kt
#	ground/src/main/java/com/google/android/ground/ui/startup/StartupFragment.kt
@anandwana001
Copy link
Collaborator Author

Closing as it is fixed at #2924

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GoogleApiManager$GooglePlayServicesMissingException - Google play services not available
4 participants