Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Developer
Posts: 319
Registered: ‎07-20-2008
My Device: Not Specified

Possible deadlock in GPSFirewallImpl and other LocationProvider threading questions

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 4.2.2.123).   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?

 

Any thoughts?

 

 

Developer
Developer
Posts: 319
Registered: ‎07-20-2008
My Device: Not Specified

Re: Possible deadlock in GPSFirewallImpl and other LocationProvider threading questions

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.  

 

 

New Developer
Posts: 10
Registered: ‎08-01-2008
My Device: Not Specified

Re: Possible deadlock in GPSFirewallImpl and other LocationProvider threading questions

You've been able to do GPS stuff on a Verizon device? :smileyhappy:  How...

 

I thought it was entirely locked down.

Developer
Developer
Posts: 319
Registered: ‎07-20-2008
My Device: Not Specified

Re: Possible deadlock in GPSFirewallImpl and other LocationProvider threading questions

It is, but in this case the deadlock happens before reaching the "verizon black hole". :smileyhappy:

 

 

 

BlackBerry Development Advisor
Posts: 15,083
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Possible deadlock in GPSFirewallImpl and other LocationProvider threading questions

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.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Developer
Posts: 319
Registered: ‎07-20-2008
My Device: Not Specified

Re: Possible deadlock in GPSFirewallImpl and other LocationProvider threading questions

Yes, the firewall prompt is displayed.  If the app already has the proper permissions, the deadlock doesn't happen.

 

The app is a UiApplication.

 

BlackBerry Development Advisor
Posts: 15,083
Registered: ‎07-09-2008
My Device: BlackBerry Passport
My Carrier: Bell

Re: Possible deadlock in GPSFirewallImpl and other LocationProvider threading questions

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.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Developer
Posts: 319
Registered: ‎07-20-2008
My Device: Not Specified

Re: Possible deadlock in GPSFirewallImpl and other LocationProvider threading questions

Yeah, it's not quite as good a user experience however.

 

Thanks.