Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

I am reading an article about Background Applications and wish to have some details clarified. https://brewx.qualcomm.com/bws/content/gi/common/appseng/en/knowledgebase/docs/bg_apps.pdf Under "Starting/Ending", the article describes how background applications are started: ---------------------- ...To place itself into the background, an application must modify the dwParam when it handles the EVT_APP_STOP event... ----------------------

When I read the Brew API Reference (3.1.5) I see that background applications can also be created by the functions ISHELL_StartBackgroundApplet() and ISHELL_SendEvent(). QUESTION 1: Are there any differences between background applications created by the method described in the article or the two other methods not mentioned in the article? Are applications created by either method equivalent? 

 

I don't understand the text about terminating a background application at all: ---------------------- Terminating a background application poses a greater challenge. As they are unable to receive key events directly, it is necessary for the background application to either terminate itself upon successful completion of a designated task or listen to events generated by a separate façade application. The application may be terminated through three methods: 1. Another application sends an event (with eCode >= EVT_USER) signaling the background application to terminate through ISHELL_SendEvent() or ISHELL_PostEvent() 2. Background application terminates itself with ISHELL_CloseApplet() upon completion of a specific task. Note that according to the API references, calling ISHELL_CloseApplet(pIShell, TRUE) from the active application will close all other executing applications and return to the idle screen; however, when called by the active application this operation will not affect other programs not in the application stack 3. Background application activates itself by calling ISHELL_StartApplet(), at which point it may receive user events ----------------------

I interpret the sentence "The application may be terminated through three methods" as there are three separate methods that can be used to terminate the application. However, method 1 and 3 does not explain how the application is terminated, but only how (1) make the background application execute or (3) how to make the background application "active"? Method 2 suggests that the application is terminated if it executes the ISHELL_CloseApplet() function. Can the application call this function while in background? Will it receive a EVT_APP_STOP event if doing so? Exactly when will all resources held by a background application be completely released? After it has processed an EVT_APP_STOP event (without modifying dwParam)? QUESTION 2: How do I stop a background application? Are there several methods?

When reading the Brew API Reference (3.1.5) there is a list of AEEEvent codes an application can receive. Unfortunately, the description is often lacking. It is not described what events a background application can receive, what causes the events to be sent, or what the background application is expected to do when the event is received. Which events can be ignored? I am interested in the following events: EVT_APP_START - What would cause a background application to receive this event? Or is it guaranteed that it will never see this? EVT_APP_STOP - What would cause a background application to receive this event? What is the BGapp expected to do? EVT_APP_TERMINATE - What would cause a background application to receive this event? What is the BGapp expected to do? EVT_EXIT - What would cause a background application to receive this event? What is the BGapp expected to do? EVT_APP_RESTART - What would cause a background application to receive this event? What is the BGapp expected to do? What happens if it ignores this event? EVT_APP_START_BACKGROUND - What would cause a background application to receive this event? What is the BGapp expected to do? QUESTION 3: Which of these events must the BG app respond to? Why? What causes them to be sent? 

The text reads: ---------------------- Additionally, handsets running background applications will experience increased power drain due to the inability to enter standby mode ----------------------

QUESTION 4: Can you confirm that the handset will not enter standby mode if a background app is active? Is there a way for a BG app to know when standby mode is desired so that it can quit? Considering ISHELL_SendEvent() creates a BG app, will using this function disable standby mode?

Answer 1:- Both are used in different scenarios: 1.) Sending currently running application to background. This can be achive by an application must modify the dwParam when it handles the EVT_APP_STOP event. The dwParam for this event represents a pointer to a boolean value. If the boolean value is FALSE, the application will be placed in the background after handling the EVT_APP_STOP. This can be accomplished through the statement *((boolean*) dwParam) = FALSE. 2.) Sending another application to background from currently running application Lets say current app A is running and you want to send another app B in background then call ISHELL_Startbackgroundapplet(),in this case, the app B receives the EVT_APP_START_BACKGROUND event instead of the EVT_APP_START event.You have to call initappdata() of app B when receving EVT_APP_START_BACKGROUND. Note:- ISHELL_Startbackgroundapplet() was introduced in BREW 3.1.4. Answer 2: 1.) Lets say your app B is already running in background and you want to close this application, right? You have to post an user defined event(EVT-USER >=) to application B (background application) from foreground application A using ISHELL_POSTEVENT(), when receiving the user defined event by back ground app B, you can call ISHELL_Closeapplet() to stop the application. 2.) Lets say you send the currently running app to background then after completion of specific task, this can be closed by calling ISHELL_CloseApplet(pIShell, TRUE). 3.) Background application can come from background to foreground by calling Ishell_startapplet() so that it can recive key events, you can then close the application now. Answer 3: As per your requirement, you have to take care of below scenarios whatever fits to your application 1.) If you want to send the currently foreground app to go to background then on EVT_APP_STOP, app must set *dwParam to FALSE. 2.) if you want to send app B to background by calling ISHELL_Startbackgroundapplet() from from foreground app A, then B will recive EVT_APP_START_BACKGROUND instead of EVT_APP_START, you have to call initappdata of App B upon receving EVT_APP_START_BACKGROUND.Ans 4.It completly depends on the application how it consuming the resources.

Answer 1:- Both are used in different scenarios: 1.) Sending currently running application to background. This can be achive by an application must modify the dwParam when it handles the EVT_APP_STOP event. The dwParam for this event represents a pointer to a boolean value. If the boolean value is FALSE, the application will be placed in the background after handling the EVT_APP_STOP. This can be accomplished through the statement *((boolean*) dwParam) = FALSE. 2.) Sending another application to background from currently running application Lets say current app A is running and you want to send another app B in background then call ISHELL_Startbackgroundapplet(),in this case, the app B receives the EVT_APP_START_BACKGROUND event instead of the EVT_APP_START event.You have to call initappdata() of app B when receving EVT_APP_START_BACKGROUND. Note:- ISHELL_Startbackgroundapplet() was introduced in BREW 3.1.4. Answer 2: 1.) Lets say your app B is already running in background and you want to close this application, right? You have to post an user defined event(EVT-USER >=) to application B (background application) from foreground application A using ISHELL_POSTEVENT(), when receiving the user defined event by back ground app B, you can call ISHELL_Closeapplet() to stop the application. 2.) Lets say you send the currently running app to background then after completion of specific task, this can be closed by calling ISHELL_CloseApplet(pIShell, TRUE). 3.) Background application can come from background to foreground by calling Ishell_startapplet() so that it can recive key events, you can then close the application now. Answer 3: As per your requirement, you have to take care of below scenarios whatever fits to your application 1.) If you want to send the currently foreground app to go to background then on EVT_APP_STOP, app must set *dwParam to FALSE. 2.) if you want to send app B to background by calling ISHELL_Startbackgroundapplet() from from foreground app A, then B will recive EVT_APP_START_BACKGROUND instead of EVT_APP_START, you have to call initappdata of App B upon receving EVT_APP_START_BACKGROUND.Ans 4.It completly depends on the application how it consuming the resources.