Android: fix location permission check


Commit 4d02ca5c364f36ed77d1960ff42a775b9d44a4eb reworked the Android
backend so that it does only permission checks instead of premission
requests. While doing this fix, the request of Precise permission
was replaced with the check of the same permission.

However, that might now work incorrect, because not all of
QtPositioning features require precise location. For example, the
user can request approximate location, and still should be able to
retrieve the current position using the data from mobile network.
However, satellite information would be unavailable in such case.
But currently even position requests would fail, because the code
always checks for precise location.

To fix the issue, update the hasPositioningPermission() helper
function to take a mask of possible permission, and check for
all of them.

Note that the possible permissions flags are very similar to
QGeoPositionInfoSource::PreferredMethods, but still decoupled
from them for a couple of reasons:
* according to the docs, the PreferredMethods act like a hint for
  the backend, so the users would not necessarily get what they
  requested. Also, the backend implementation might change in
  future.
* the new permission flags are used not only for position requests,
  but also for satellite updates. So, a separate enum that does
  not depend on QGeoPositionInfoSource makes more sense.

This also requires some adjustments of the code in the Java
implementation, because a SecurityException can now be a valid
case. For example, when the user has preferredPositioningMethods
set to AllPositioningMethods, but at the same time requested
only approximate location.

The patch was tested on Android 9, Android 11, and Android 14
with various permissions in AndroidManifest.xml and various
permissions requested via the Qt APIs.

Fixes: QTBUG-127847
Pick-to: 6.8 6.7
Change-Id: I7f20afba3baa369dcedb8b838cbf5a7d271be8a4
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
commit693d6d5bb34546a251f2df46c9ec667167808cad
parent22c046168daa51599eb06350246765a34b71e368
authorIvan Solovev <ivan.solovev@qt.io>
committerIvan Solovev <ivan.solovev@qt.io>
commit timeMon, 2 Sep 2024 18:42:14 +0200