17

I have been facing a severe battery drain issue on my official Cyanogenmod custom ROM. After discussing it on community forums, it was suggested that I use logcat for troubleshooting the problem.

Problem:
Every time I disconnect my device after a complete charge, it drains battery rapidly. It loses almost 50% in 15-20 mins. As mentioned above, I am planning to use logcat to try and capture the issue. I am planning to run adb logcat immediately after unplugging the phone from power. However, I have used logcat in the past and found it very very difficult to extract specific data from the large output. I already went through the official logcat help page and Reading and Writing Logs to see if I could find something useful, but I could not find a solution for my problem.

Question:

  • Is there anyway to use filters or some other feature where I can limit the logcat output to the stats which are only related to battery usage?
  • Can something like adb shell dumpsys batterystats > batterystats.txt be of better use to me? If so, how do I use it to get what I want?

Battery Graph1 Usage Pattern shows nothing Battery Graph 2

UPDATE:
BatteryStats for my drain can now be found here at Patebin. Also this is my Battery Historian Chart:
Battery Historian Chart

  • Let us continue this discussion in chat. – theHeman Mar 20 '16 at 19:39
  • 1
    From the discharge graph I'd rather assume a faulty battery here than an app (especially if it always happens that way). Maybe you try a new battery (provided your device supports replacing it)? – Izzy Mar 20 '16 at 20:58
  • I think the problem is with the battery, not an app. Try to borrow the battery of someone with the same device, and test if the same error occours with the newer battery. If it doesn't you'll just have to get a new battery. If it still does, I'd still don't think it's because of an app - to drain this much battery it would need to activate GPS, have heavy network traffic and do complex processes at a time. – Namnodorel Mar 26 '16 at 22:32
  • @Namnodorel unfortunately, it's a non-removable battery.. I also think it's not due to any app. It's either a leak in the ROM or something else. I am assuming there is not problem in the battery because as I said, once I recharge if after drop, it works perfectly fine :| – theHeman Mar 27 '16 at 10:19
  • Batteries that are going bad can be inconsistent sometimes. My Galaxy S6's battery is slowly dying, and some days it's better, some days it's worse. My drain is not as significant as yours, but I believe it is not due to an application. Have you tried running the phone in safe mode? Have you tried a factory reset (as awful and unfortunate as they are to perform and recover from)? – Kaizerwolf Jun 10 '16 at 14:15
1

Are you sure, it's not any app that is draining your battery? You can find this out by booting you phone into Safe mode. Read How to boot your phone into safe mode for instructions. If your battery doesn't drain in Safe mode, try uninstalling the apps that you installed after you started seeing this weird behavior. If you are not able to figure out which app it is, try factory resetting it. Also, if the battery is draining so quickly it might very well be a faulty battery.

  • Well, general suggestion is good, but it doesn't really answer the real question (diagnose battery usage using logcat) – Andrew T. Jan 6 '17 at 2:48
  • @AndrewT. Generally spoken, you are correct. But considering OP wants to solve the issue, fixing it to logcat is somehow making it an XY problem (in limits). So though not 100% fitting the question "literally", I'd say it fits the issue and offers an approach to solve it. – Izzy Jan 6 '17 at 9:48
0

Is there anyway to use filters or some other feature where I can limit the logcat output to the stats which are only related to battery usage?

Sure. The easier way is to used the device monitor from Android Studio. The more complex way is to use the command line interface to adb logcat (it uses the ANDROID_LOG_TAGS env var). Cf logcat Command-line Tool documentation on developer.android.com.

Can something like adb shell dumpsys batterystats > batterystats.txt be of better use to me? If so, how do I use it to get what I want?

Battery drain is mainly because of some unexpected conditions occuring (errors conducting applications to loop infinitly, badly detected devices making access sub optimals, for ex reading byte per byte instead of Mb per Mb, etc). You should use the filtering ability of adb logcat to find such unexpected conditions. But be warned that such tools are mainly used by app or even platform devs, and it can be sometimes a little but complex to interpret such logs. However 100% of the guys who succeeded, have tried ;-)

protected by Community Jun 22 '17 at 15:44

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.