Monday, April 5, 2010

Battery Issues for the Shaker App

People have been noting some battery issues resulting from the Shaker app, and I wanted to explain what might be causing this and what I am doing to reduce the battery use.

I just recently updated my Droid to 2.1 and for the first time today, I started noticing some battery issues as well.  Before that, it had always been fine on my phone and a couple of others I tested.  Not all users may be impacted by the battery performance.

Normally, when the screen turns off and the phone goes idle, the phone goes into a lower power state where apps basically stop running until the screen turns back on.  This is a problem for the Shaker app whenever a shaker is defined to respond when the screen turns off (for example, when the shaker is supposed to turn the screen back on).  The app needs to stay active to wait for the user to shake the phone.  Therefore, I am forced to prevent the phone from going into the low power state (using what is called a wake lock for anyone who might be interested).  I will admit that this is normally considered bad practice as it can have a bad impact on battery drain, as we are seeing.  I am looking for alternative ways of handling this, but it might take a bit longer to find an alternative to this with the current release of the Android Operating System.

I am working on some other ways of reducing the power as well.  The next version will have the ability to disable Wifi when the screen turns off, which the phone should do anyway.  Also, I may look into managing other applications I think may be using the battery while the shaker app is keeping the phone in its normal power state.  For example, I think the live wallpapers are having an impact, so I might look to stop it from running when the screen turns off, and then turn it back on once the screen comes back on.

The last thing I have to say about the battery issues is that I will be asking for users to agree for the app to automatically send usage statistics back to me for analysis.  Each user will be prompted in the next update to agree or decline.  I will be gathering stats about the shakers that are set up, what is using the battery (and how much), information about running processes and apps, and general phone version information.  Hopefully people will agree to send this information so I can continue to improve the battery situation.

If anyone out there has any tips, I am all ears!

3 comments:

  1. After some further research, it is looking more and more like there will not be a fix for this battery issue in Android 2.1. I will continue looking for ways to get around this problem, but in the mean time I will look for more ways to manage it as best as possible and to warn users specifically about what aspects of the Shaker app could have a significant impact on their battery life.

    ReplyDelete
  2. Jonathan,
    Good luck with your research and work. It's a great program so hopefully you'll eventually figure it out. I know some of the devs over at droidforums.net have some low voltage kernels etc. Perhaps if you reached out to one of them they could offer some help. Anyways I'll keep checking back to see if you come up with anything. Good luck and thanks for your time and hard work on this.

    ReplyDelete
  3. I just wanted to clear a couple things up from my post above...

    1) I decided not to annoy users with any more messages than I felt necessary, so users are not prompted to send usage stats. Instead, users can select to share them in the settings page.

    2) I am not going to mess with other running apps. Live wallpapers are not the issue and the other apps that run in the background are not likely to be the issue either.

    Having said all that, I think I may be on to some significant improvements for the next release. Basically, what I am trying to do is detect when the phone screen is near another object (e.g. in a pocket, face down on a desk, etc.) OR is laying horizontally on a surface. If any of these conditions exist, the app will not hold a wake lock until one of these conditions no longer exists.

    The one last thing I am trying to work out is to make sure that the sensor detecting the device to be laying on a surface will stay awake while the phone goes into its low power state.

    I think I am pretty close to accomplishing this, and if I can get this to do what I want, I just need to test the impact of running these sensors on the battery.

    ReplyDelete