Archived:MIDlet cannot power down GPS module with an existing satellite fix (Known Issue)
When using Location API's (JSR-179) methods to get a proper provider, it is not possible to stop GPS module location activity if there is a GPS satellite fix, resulting in reduced battery life.
Location API's getInstance(Criteria criteria) method selects the location provider based on the defined criteria, where the value null indicates the least restrictive criteria with default values.
Example usage for acquiring location provider information with JSR-179:
locProvider = LocationProvider.getInstance(null);
locProvider.setLocationListener(this, -1, 0, 0); //setting listener for LocationProvider updates
When acquiring location provider information as defined above, the Location API does not stop GPS module location activity if there is a GPS satellite fix. When the location listener is stopped and the location provider is reset, the actual receiver does not stop and it does not power down (regardless of whether the satellite fix continues to be available or not):
locProvider.setLocationListener(null, -1, 0, 0); // setting registered listener cancelled
locProvider.reset(); // resetting LocationProvider by aborting all pending synchronous requests
As a result, battery life is reduced to below 10 hours.
How to reproduce
Download and install Nokia Energy Profiler.
Implement a test MIDlet using this source code.
- Launch Nokia Energy Profiler. From Options, choose Start to begin measurement and check the initial battery level in the top right corner.
- Leave Nokia Energy Profiler running and exit it by pressing the Menu key.
- Launch the test MIDlet. The MIDlet starts searching for a fix. After a fix has been found, press Stop GPS. Leave the MIDlet running and exit it by pressing the Menu key.
- Resume to the Nokia Energy Profiler and check the battery level. It is now reduced to below 10 hours.
- Repeat step 2.
- Resume to the running MIDlet and close it by pressing Exit.
- Repeat step 4. The battery level will be slowly resumed. Close the Profiler by pressing Exit. Relaunch the Profiler and start the measurement again to view the improved battery level.
Exiting the MIDlet results in improved battery level on S60 3rd Edition, Feature Pack 1 devices. On Symbian Anna devices, this issue has been fixed, so stopping listening to location updates from within the application, results in reduced battery power consumption. See also Best practises for listening to location updates with Java ME.