08-06-2008 12:10 PM
I spent most of yesterday chasing down a LocationProvider deadlock problem and it l seems that tjhings are locking up GPSFirewallImpl. Here's the scenario... I start a background thread that gets a LocationProvider with "CELL_SITE" criteria and then does a getLocation(). If the program hasn't been run before, the permissions dialog pops up. In the mean time, another thread gets a LocationProvider with "AUTONOMOUS" criteria and attempts to call setLocationListener which also causes an attempt to show the permissions dialog. Deadlock on GPSFilrewallImpl. It took me a while to find it because it's only reproducable on real devices and I have debug files for only 1 device (a verizon 8830 running 18.104.22.168). It does happen on other devices and OS's though.
So, this begs another question... What is safe do do with LocationProviders in a multi-threaded environment? I know that in my situation I get 2 instances of the same provider but they definitely interact. When I call getLocation() on one, it resets the other to the same criteria. I'd really like to have a listener on each instance but the documentation isn't really clear on what "there can be only one listener per Location Provider" means. LocationProvider class or instance?
08-07-2008 06:34 PM
Some additional info in the docs would also be helpful...
I just leaned today that callbacks related to RadioStatusListener are executed in the event thread (so you can't call getLocation()) where callbacks related to LocationListener are dispatched in a background thread.
08-11-2008 09:33 AM
When you experience the deadlock, do you see the firewall prompt asking for permission? Are you creating a application that extends from UiApplication or Application?
A BlackBerry is only able to operate in one GPS mode at a time. So it can not run in both cell site and autonomous at the same time.
08-11-2008 12:00 PM
Yes, the firewall prompt is displayed. If the app already has the proper permissions, the deadlock doesn't happen.
The app is a UiApplication.
08-12-2008 02:54 PM
You should be able to work around this by using the ApplicationsPermissions class. Your application could query to see if it has permission to access GPS and if it doesn't, request it from the user.