02-13-2013 10:50 AM
Hello all,
i'm using QGeoPositionInfoSource::createDefaultSource(
If the user has revoked the permisson for "read_geolocation", a call to PositionInfo::requestUpdate() will fail with an error in console.
I get no signals if this happens and i haven't found a way to check if the permission is granted.
Maybe somone knows a solution for this problem.
Thanks.
Solved! Go to Solution.
02-13-2013 04:11 PM
02-14-2013 03:32 AM
02-14-2013 04:23 AM - edited 02-14-2013 04:24 AM
I found this check in the API
if ( !positionInfoSource->property("locationServicesEna bled").toBool() ) {
}
You can find more at this link
https://developer.blackberry.com/cascades/referenc
You can use Ctrl+F and search for 'locationServicesEnabled'. You can find some more info about that property.
02-14-2013 04:48 AM
02-15-2013 05:53 AM - edited 02-15-2013 10:09 AM
The geolocation_request_events() function starts to deliver geolocation change events to your application using BPS. If the application does not have the read_geolocation capability, this function will fail. Events will be posted to the currently active channel.
so the following code should do it:
int geolocation_enabled = 0;
{
int err = geolocation_request_events(0);
geolocation_stop_events(0);
// based on the request; flag if it has been enabled or not.
if (err == BPS_SUCCESS) geolocation_enabled = 1;
}
this should do exactly what you need.
02-15-2013 08:53 AM
02-15-2013 10:09 AM
could it be that the geolocation_stop_events() messes up the BPS sub-system when called on failure? ![]()
int geolocation_enabled = 0;
{
int err = geolocation_request_events(0);
// based on the request; flag if it has been enabled or not.
if (err == BPS_SUCCESS)
{
geolocation_enabled = 1;
geolocation_stop_events(0);
}
}
would that make a difference?
you should never call geolocation_stop_events() if the first failed. alternatively; the documentation states that if the permission isn't available there either.. it'll fail. you could simplify the whole process down to:
int geolocation_enabled = 0;
{
int err = geolocation_stop_events(0);
// based on the request; flag if it has been enabled or not.
if (err == BPS_SUCCESS) geolocation_enabled = 1;
}
of course; this could be a complete underlying issue altogether and a bug in the way these are handled. if you could verify; that would be great and if it is a bug, a PR/bug report can be filed documenting that this isn't working as it should be.
02-15-2013 12:01 PM - edited 02-15-2013 12:03 PM
int geoAllowed = 0;
{
int err1 = geolocation_request_events(0);
LOG << "1: " << err1 << LOG_EOL;
if(err1 == BPS_SUCCESS)
{
geoAllowed = 1;
int err2 = geolocation_stop_events(0);
LOG << "2: " << err2 << LOG_EOL;
}
}
case 1: Start with permission granted
OUTPUT:
1: 0
2: -1
Revoke permission
OUTPUT:
1: 0
2: -1
case 2: Start with permission revoked
OUTPUT:
1: -1
Grant permission
OUTPUT:
1: 0
2: -1
geolocation_stop_events always returns -1.
if a call to geolocation_request_events was successfull, it seems to always return SUCESS.
02-16-2013 04:45 AM
so it is clear that it geolocation_request_events(0) only returns an error once; if the permission is not granted.. was this with subsequent runs or during the same execution process? it could be that the value is cached and hence any subsequent calls to the function doesn't check to see if the permission has been revoked while the process is actually running - if that is the case; it is a bug and a bug report should be generated.