To gain a better understanding of the issue, we will look at what wakelocks are when it comes to Android and how we can detect and fix the issue for better battery life.
What Are Wakelocks?
When you press the power button on your phone to lock the screen, you assume that the phone will go to sleep. But that’s not always the case. There are apps that run in the background, using the device’s resources and restricting the phone from going into deep sleep mode. Because of these, the phone’s processor is constantly working, which drains the battery life even when you’re not using it. Most of these wakelocks are caused because apps want to sync data in the background or use location services. Therefore, the apps that keep your CPU running even after your phone is in sleep mode are called wakelock apps. However, these apps are not entirely to be blamed. These wakelocks are necessary if you wish to see an updated email inbox in the morning. Apps use the permission to sync data to the servers, which sometimes only lasts a few minutes. The problem starts when some apps use this permission for as long as an hour and cause your phone’s CPU to function all the time. Take Google Play Services, for example. If you have your location enabled, the service will keep your phone’s CPU awake almost all night and reduce the battery life drastically. So now that we know what wakelocks are, let’s see how we can detect the apps that are causing it. Note: As we’ll be needing elevated permissions to retrieve this data, root access is necessary. Without root permissions on your device, I am afraid there’s not much you can do about the wakelock issue. But getting a device rooted is easy nowadays, so don’t forget to bookmark this page and come back to it once you have figured out how to root your Android (and rooted it too).
Detecting Apps that Cause Wakelocks
Detecting wakelocks is pretty easy once you have a rooted phone. Fully charge your battery to 100% and install an app, called Wakelock Detector, on the device. Having done that, reboot your phone once and launch the app. Wakelock Detector will ask for root access and run in the background collecting data. Come back to the app after a few hours and you will be able to see the total amount of time your apps have kept the CPU running in the background. You can also check the number of times an app triggered wakelock.
Resolving the Problem
So now that we know the apps that are causing these wakelocks, one of the most straightforward options would be to uninstall the app and find a better alternative on the Play Store. But then there are system apps like Google Play Services that you cannot uninstall. These apps are necessary for the phone to function. To keep a check on such apps, you can install an Xposed module called Amplify. Amplify is basically a battery saving app for Android, but unlike others, it has a module to restrict wakelock requests from different apps installed on your system. Select the Wakelock option from the right-hand side navigation bar. Select the permission you wish to restrict and designate a favorable time period. The app also provides a recommended setting to fix the issue.
Conclusion
That was pretty much everything about wakelocks on Android and how to fix the battery trouble they may cause. People who experience high drain due to Google Location Services running in the background must try it out. In case of any confusion or for further explanation, just drop a comment and we’ll be happy to help.