Stop charging by software

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
bichlepa
Posts: 148
Joined: 04 Mar 2014 18:29
Location: Germany
Contact:

Stop charging by software

Post by bichlepa » 27 Jul 2016 07:52

I always left my phone charging the whole night. It's well known that it is bad for the battery if it is fully charged and is kept fully charged for a long time.

I think it will improve battery life if it stops charging as soon it reaches 95%.
So I'd like to build a flow which stops charging as soon the battery is charged by 95%.

Is it possible that AutoMagic disconnects the charger by a software command? My phone is rooted.

User avatar
Bushmills
Posts: 286
Joined: 23 Sep 2014 21:56

Re: Stop charging by software

Post by Bushmills » 27 Jul 2016 08:12

I'm doing exactly that, but keeping charge between 60 and 70 percent. Two hours before scheduled or estimated depart I'll top up to 100%
Power supply is turned on or off with a GemBird / energenie sispm2 "power manager", connected to my internet router. The device runs under openwrt, and provides the sispmctl program which is used to control power rail functionality. Actually, 4 of those power rails are connected to the device.
On the router runs also a system called "serafena" (https://github.com/Bushmills/serafena)
which, among other, receives power switching requests from the mobile devices, and switches the sockets accordingly.
Under https://github.com/Bushmills/serafena/w ... wer-strips is an example of the resulting charge graph.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Stop charging by software

Post by Martin » 28 Jul 2016 18:36

There are commands meant to be used for developers to test battery features. Maybe this can work for your use case.
Check out the dumpsys command. Here's the output from a Nexus 5X on Android 6:

Code: Select all

> dumpsys battery --help
Dump current battery state, or:
  set [ac|usb|wireless|status|level|invalid] <value>
  unplug
  reset
dumpsys battery unplug would simulate unplugging the device. dumpsys battery reset can be used to go back to normal operation.
You can execute the commands using action Execute Root Command.

I'm not sure if this just fakes a few internal software toggles or if it actually stops charging the device. Let me know if it works.

User avatar
bichlepa
Posts: 148
Joined: 04 Mar 2014 18:29
Location: Germany
Contact:

Re: Stop charging by software

Post by bichlepa » 28 Jul 2016 19:47

Unfortunately it doesn't work. The commant unplug doesn't exist on my phone. I also tried to use set ac 0. This caused the trigger "Power source disconnected" to trigger and the phone showed that the charger is disconnected. Also the accu level didn't change. But still it has charged. After using the command reset and replugging the charger the level jumped to a higher value.

Therefore this is right:
Martin wrote:this just fakes a few internal software toggles

Post Reply