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

Resolves Issue #5413 Crash when opening Nearby when location permission hasn't been granted yet #5418

Merged
merged 2 commits into from
Jan 27, 2024

Conversation

ShashwatKedia
Copy link
Contributor

Description (required)

Fixes #5413

What changes did you make and why?
I saw that the app crashed because a function inside ActivityResultCallback, was being called even without the user giving/denying permission. Also, the code was using RequestMultiplePermissions when, in reality, we were requesting only one permission, so I updated the code to RequestPermission, which also solved the above problem. Moreover, when location permission was not given, in the getMapCenter, mapCenter was null when trying to extract latitude from it, so I assigned mapCenter to lastKnownLocation (after retrieving it) to prevent the exception, if null.

This can also happen with getMapFocus and getLastMapFocus, as even mapView and lastMapFocus are not being checked for a null value, but I did not change that, as I felt it was out of the scope of this exception.

Tests performed (required)

Tested betaDebug on OnePlus Nord CE 2 Lite with API level 31 and Emulator Pixel 7 Pro with API level 34.

@nicolas-raoul nicolas-raoul changed the title Resolves Issue #5413 Resolves Issue #5413 Crash when opening Nearby when location permission hasn't been granted yet Jan 15, 2024
@sivaraam
Copy link
Member

Hey @ShashwatKedia! Thanks for working on this. 🙂

I gave the change in this MR a try and could confirm that the app no longer crashes with the steps described in the issue. Let me check a bit more and let you know if there's anything left to do.

@ShashwatKedia
Copy link
Contributor Author

@sivaraam or @nicolas-raoul , if all is good, could you merge this PR? It seems that this particular bug is causing a lot of problems in testing for other issues, especially while testing the nearby fragment.

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

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

I confirm the crash happens in main but not on this branch.
Code looks OK to me.

@nicolas-raoul nicolas-raoul merged commit 8222c4a into commons-app:main Jan 27, 2024
1 check passed
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.

[Bug]: Crash when opening Nearby when location permission hasn't been granted yet
3 participants