We have moved to a new Sailfish OS Forum. Please start new discussions there.
9

detect heavy battery drain (and notify me and/or stop it)

asked 2017-12-16 20:08:46 +0300

Hangman gravatar image

updated 2017-12-16 21:41:44 +0300

There are some questions here about a suddenly excessive battery drain. I am not really interested in why and which application cause this, the main problem is when I recognize it, the battery is almost empty and nothing is worse than an empty phone.

This problem also exists with android phones (every Android phone I had did this at some point). And now with the XperiaX I had this already 4 times (and yes, a quick reboot solved this for me, but the battery is at 30% and I have 10 hours to go - great).

So the os could watch the cpu (or the battery, or the current or something) and if someone force the cpu to stay awake it can notify the user so he at least know he will soon have an empty battery. Additionally it would be nice to be able to choose if I want to ignore this for now (because I know it and I want it to be) or the os to stop whoever draining my battery. (Maybe this could be a feature for a third party application, but I'd like to see this at system level, because it will be more efficient and it really runs always, I cannot close it or forget it to start)

Sure, the bugs causing this should be fixed, but this is to prevent the phone from getting empty without notice and create a safe state. Battery draining will always be possible, no matter if it a new bug or a nasty application trying to mine bitcoins with my cpu.

Edit: Just see something interesting android got with the oreo update - https://cdn57.androidauthority.net/wp-content/uploads/2017/10/Android-Oreo-81-apps-using-battery1.jpg

edit retag flag offensive close delete

Comments

Not a monitoring solution, but maybe related: I noticed drastic power drains when enabling the "double tap to wake" feature. Apparently it can prevent proper sleep mode, as discussed elsewhere. So besides looking at apps, you might want to consider OS issues as well.

Kao ( 2017-12-18 09:35:44 +0300 )edit

4 Answers

Sort by » oldest newest most voted
1

answered 2017-12-17 10:37:50 +0300

ghling gravatar image

You probably can handle this with a little script that checks the battery percentage on a regular interval and notify you if it drops by more then X %. I'm no active SFOS dev myself but I'm quite confident there is an API to query the battery level and to create notifications. Run the script via a cronjob and you've got yourself a quick and dirty solution. If you're brave you can even include the reboot this way.

However, I also want to point out that in order for the script to run, it needs to wake the CPU / phone itself. So while it may help you noticing battery drain faster, it probably will cause some itself.

edit flag offensive delete publish link more

Comments

1

Interesting hint, I'll give it a try. Still not the solution I was looking for, but maybe good enought to see if this is working as expected, still a dirty hack. For thoose who interested:

I have a script in /home/nemo/scripts/battery-drain-notify.sh:

#!/bin/bash
DIFF=5 #difference in battery capacity to care about for 15min - I have to test this value
NEW_CAP=$(cat /sys/class/power_supply/battery/capacity)
OLD_CAP=$(cat /tmp/batt-old)
if [ $(($OLD_CAP - $NEW_CAP)) -ge $DIFF ]
    then
        notificationtool -o add -A Battery-notify -c x-nemo.battery.lowbattery "Battery drain exceeded" "Battery drained in the last 15 minutes more than $DIFF%"
    #else
        #notificationtool -o add -A Battery-notify -c x-nemo.battery.removecharger "Battery notify status" "Everything is fine and running :)"
fi
echo $NEW_CAP > /tmp/batt-old

And since I have no cron is installed, I used timedclient-qt5 to run this script every 15minutes, as one-time-command this should also survive a reboot (I'm not sure how to use timedclient-q5):

timedclient-qt5 -a'whenDue;runCommand=/home/nemo/scripts/battery-drain-notify.sh@nemo' -r'hour=00;hour=01;hour=02;hour=03;hour=04;hour=05;hour=06;hour=07;hour=08;hour=09;hour=10;hour=11;hour=12;hour=13;hour=14;hour=15;hour=16;hour=17;hour=18;hour=19;hour=20;hour=21;hour=22;hour=23;minute=0;minute=15;minute=30;minute=45;everyDayOfWeek;everyDayOfMonth;everyMonth' -e'APPLICATION=batterynotify;TITLE=test'
Hangman ( 2017-12-18 00:25:17 +0300 )edit
0

answered 2017-12-16 20:21:52 +0300

olf gravatar image

updated 2017-12-16 20:22:34 +0300

Already discussed and answered in https://together.jolla.com/question/164268/10-low-battery-warning-not-appropriate/ and other battery related threads here on TJC.

edit flag offensive delete publish link more

Comments

1

Thanks for reading my question but this does not satify me. I don't want to get notyfied if it is to late, the 10% warning is totally fine (in my opinion). I use "Battery Log" to get the estimated runtime and this is fine too. A notification at a minimum remaining runtime would be better, but still useless.

I want the phone to keep my remaining runtime as expected (thats not right and not poossible due to user interaction but this give an idea of what I mean), it can detect if something happens what should'nt happen.

Hangman ( 2017-12-16 21:03:35 +0300 )edit
0

answered 2017-12-16 22:19:42 +0300

DrYak gravatar image

Partial solution :

(Partial as it's not automatically looking for power hogs).

Install any top-like software on your phone.

  • Crest is a nice graphical QML app available on openrepos/warehouse
  • Even plain top and htop do the trick if you're not afraid.

Look for applications that hog the CPU.

9 times out of 10, it's some android process. Either a badly written app, or some Android process going crazy (like com.android.acore).

If somebody cared enough to port the necessary bits to mer-core, powertop would be a nice utility to specifically detect and alert about power-hogs.


Definitive solution :

Just kill alien-dalvik when not in use. And suddenly all your battery problem go away !

Just joking.

But there's a grain of truth here : Power hogs are seldom QML native apps.

edit flag offensive delete publish link more

Comments

The last time this happend I thought about powertop too (good hint, I just installed it). But this is not the point, the missing automatically thing bothers me.

Most time aliendalvik is off, but sometimes I forget it. One time it was the browsers fault, or mine .. I left a website open with a running script refreshing the site, so it's not always android :).

Hangman ( 2017-12-16 22:38:27 +0300 )edit
0

answered 2017-12-17 03:19:44 +0300

pawel gravatar image

you can use situaations to kill browser and or dalvik when displays get.off

edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
5 followers

Stats

Asked: 2017-12-16 20:08:46 +0300

Seen: 738 times

Last updated: Dec 17 '17