tags:

views:

81

answers:

5

Are there any "best practices" for writing a power-efficient background application in Symbian?

Specifically, is there any way (i.e. API) for a Symbian app to hint the OS regarding its current state in order to reduce battery consumption? In Android, for instance, there is the notion of Wake Locks, which prevents the device from going into standby mode - Is there anything similar in Symbian?

EDIT:
Are there any implications when running code as a separate thread with the Open-C library, and not as "native" Symbian C++, using Active Objects etc.? (the Open-C code is blocking on IO most of the time).

A: 

Hi, Power management is an very most important issue while developing application.

In Symbian it depends on what you are using to run background activities .

Whether you are using Thread or ActiveX control.

For Eg. you are developing application browser that you want the browser to download something then that downloading activity should go in background and able activity starts and when to show progress and when it finishes it should again come to fore end.

It depends on how you are managing thread if you are using thread. You can do like which thread to pause when the long time taking activity starts and when to resume when background activity has finishes execution..

In fact this is the very good topic u have come across

Rakesh Gondaliya
+1  A: 

I have not come across anything special in Symbain to keep the device out of stand-by mode. Basically the "best practices" would be the same as all mobile devices:

  • Don't loop waiting for things, always use whatever signaling services avaialble on the platform, for Symbain ActiveObjects / User::WaitForXxx
  • Limit the number of background threads (currently all mobile devices are still only 1 CPU...)
  • Don't hang onto system services, close them ASAP (this is normally my main battery drain in my mobile applications, sometimes trying to find which system service causes the most battery drain can be a real pain, WinMo is very bad for this).

For me, I find that it mostly comes down to a tradeoff between battery life and performance / responsiveness for the application. Unfortunately power that be always seem to side with the performance / responsiveness side and damn the battery drain.....

Shane Powell
A: 

There used to be an inactivity timer which could be reset by the application. This would prevent the screen from going into any screen saver mode.

If you use the various asynchronous function in Symbian, your app will run when appropriate.

One of these methods should work depending on your needs. If you describe what you want to achieve in more detail it would be easier to help you.

Ola
+3  A: 
  1. You can check user (in-)activity with a RTimer::Inactivity() method. This way is described in Forum Nokia Wiki page. There it's also described how you can reset inactivity timer.
  2. You can check whether device screen is turned on or off using HAL API. See classes HAL and HALData. You may use such a call:

TInt displayState; HAL::Get(HALData::EDisplayState, displayState); And the displayState will hold either 0 if display is turned off or 1 in other case.

With these APIs you will know whether user is active now, so you'll be able to change behavior of your background service to reduce its power consumption.

You can also use Nokia Energy Profiler application to record power consumption of handset, with different power saving options of your background service. Also please refer to Nokia's document describing best practices to save power of device. This document is quite straightforward, but useful nonetheless.

Hope this helps.

EDIT: About separate thread and Open C. As far as I know, Open C is just a plugin and deep down all the implementations are still "native Symbian". So, as far as you avoid periodic polling of some resource and just use usual blocking IO, your code is quite same economical on power as standard Symbian Active Objects techniques (which use Symbian-specific semaphores to block threads).

Haspemulator
+1  A: 

Give your application low priority (see RProcess and RThread classes). Your approach will really depend on what your background application does. These things consume most battery: radio (GSM/3G/WIFI/BlueTooth), screen backlight, file accesses.

Symbian OS will always try to put your application to sleep, you don't need to tell it to do this. Just make sure your approach gives it the opportunity to put it to sleep.

James