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
New Contributor
Posts: 8
Registered: ‎09-09-2013
My Device: 9900
My Carrier: *
Accepted Solution

App freeze after install with the Trust permissions dialog in the background

[ Edited ]

Hi,

My application has 2 entry points - one is the default which raises the UI of the application and the other one is a background engine which receives the argument "engine", and is marked as Auto-run on startup (and "Do not display on home screen").

When installing the application OTA the background engine starts working automatically and since no permissions are granted yet, it triggers the system's "Application permissions" dialog asking the user "Would you like to grant XXX Trusted application status?" (lets call it Trusted dialog).

After pressing "Yes" I get the "The application was successfully installed" dialog allowing "Run" or "Ok" buttons, which allow me to run the UI entry point (lets call this one Run dialog).

Sometimes I don't get the Trusted dialog, just the Run dialog, but when that happens my UI part is waiting for the engine entry point to start but it never responds.

Querying the ApplicationManager I can see that the engine part is running, although, it doesn't respond to either global events or runtime storage communication.

My guess is that the Trusted dialog did open, but it is now somehow in the background, possibly pushed back by the Run dialog, and it is stuck till the user presses either "Yes" or "No". I also tried a code that if found tries to push the engine to foreground but it didn't work.

At this point my only solution is to reboot the device.

This behavior was observed on Bold 9900 7.1 and 7.0 but I believe it can happen on other devices as well. There is also no specific scenario that reproduces it, it can happen randomly.

 

Did anyone come across this problem?

Does anyone have any idea how can I resolve this?

 

Thanks,

Shahar

Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: App freeze after install with the Trust permissions dialog in the background

welcome to the support forums.

i did several things to avoid this behavior:
- ensure that the startup is completed
- use an Application instance (extend Application or UiApplication)

for step 1, see
http://supportforums.blackberry.com/t5/Java-Development/Display-a-GUI-when-the-BlackBerry-device-sta...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: App freeze after install with the Trust permissions dialog in the background

I got sick of trying to debug this kind of issue, now my background processing stops immediately if the app has not been through Setup, and the Ui will always take the user through Setup including checking for permissions.  

 

This means that you can ask the user questions during Setup that influence the way the background processing works. 

 

Seems to work for me. YMMV.

New Contributor
Posts: 8
Registered: ‎09-09-2013
My Device: 9900
My Carrier: *

Re: App freeze after install with the Trust permissions dialog in the background

Thanks 

 

My engine entry point does have a inStartup() loop, but it only helps after device boot.

My problem happens after OTA installation where the device is already up and running.

As for an Application instance, both of my entry points instanciate a UIApplication.

But according to logs i have, the engine part doesn't even get it's main() to be called. The freeze happens before any of my code has a chance of being run.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: App freeze after install with the Trust permissions dialog in the background

Remember that your background processing will be invoked immediately when your app is installed OTA.  instartUp() will be false, so the processing will continue.  I am guessing that this will then try to run the permissions dialog. 

 

You say the background processing extends a UiApplication - so how do you stop this displaying a UI?  Can the user task switch to this UI?

 

Remember also your application has only one main routine, there is not a separate main for each of your UiApplications. 

New Contributor
Posts: 8
Registered: ‎09-09-2013
My Device: 9900
My Carrier: *

Re: App freeze after install with the Trust permissions dialog in the background

The background process is indeed invoked immediately, but as far as i can tell, its main() is not called (i have a log output there).
My guess is that the Trust dialog, which is a modal dialog, is blocking its execution.
The problem is that I can't see this dialog.
For the background process i tried to extend both UiApplication and Application, but i get the same result. It doesn't appear in the task switch menu because i set the acceptsForeground() to return false, and it doesn't show any screen.
But, again, i think it doesn't matter what it does because the main() is never called.

Both UI and background processes use the same main. They are distinguished by their command line arguments.

I found out how i can reproduce this in almost 100%:
It seems that if I lock the screen just at the end of the OTA download, and wait a reasonable time until the Trust or Run dialog should appear, it is most likely that the Run dialog will appear meaning the Trust dialog is hidden, and the background process is blocked.
Of course, in some unforeseen situations the device "remembers" the permissions settings from the previous install somehow, and the scenario is not reproduced.

In some of my logs i saw a print of the background process ApplicationDescriptor, and there was no trace of its main().
If I could only kill it or make it go to foreground it could fix my problem.
Developer
Posts: 16,999
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: App freeze after install with the Trust permissions dialog in the background

you can try requestForeground.
if you want to do that from the UI process you can send a global event to your background service which calls requestForeground on that event.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: App freeze after install with the Trust permissions dialog in the background

"For the background process i tried to extend both UiApplication and Application, but i get the same result. It doesn't appear in the task switch menu because i set the acceptsForeground() to return false, and it doesn't show any screen."

 

As a test, don't set this to false for your background process. 

 

New Contributor
Posts: 8
Registered: ‎09-09-2013
My Device: 9900
My Carrier: *

Re: App freeze after install with the Trust permissions dialog in the background

requestForeground is exactly what i tried when searching for a running instance of my background process, but it didn't work.
Sending a global event doesn't work either. I tried that as well, before i came to realize that its main is never called, and therefore the global event listener is never registered.

To me, this whole thing looks like a bug in the framework. I'm just puzzled why i'm the only one complaining about it.
Highlighted
New Contributor
Posts: 8
Registered: ‎09-09-2013
My Device: 9900
My Carrier: *

Re: App freeze after install with the Trust permissions dialog in the background

peter_strange,
Just tried acceptsForeground() to return true, but i get the same results.
I'm afraid it just proves my assumption that the main is not called, so there is no UiApplication instance, so it doesn't matter what acceptsForeground() returns.