ubports / ubuntu-touch

Ubuntu Touch's issue inbox is now migrated to GitLab.
https://gitlab.com/ubports/ubuntu-touch
1.28k stars 110 forks source link

feature: battery charging limiter (caps the max charge percentage to extend life of device batteries) #840

Open Osndok opened 6 years ago

Osndok commented 6 years ago

Description of the feature

An option in battery settings to adjust the upper charging limit.

Background

I was watching this particular youtube video that concluded the best course of action to extend a phone's battery is only available to rooted android phones: setting an automatic charge limit.

Batteries are critical to mobile devices, and battery longevity is extra-critical to ubports for the following reasons:

I don't know what this looks like at a low level, but it could be as simple as writing an integer to a special hardware register.

Illustrations

ubports-extend-battery-life

UniversalSuperBox commented 6 years ago

From what I can see, there are a few things that would need to be in place for this to actually work:

  1. The device's battery charge circuit supports charge limiting
  2. The Android kernel supports charge limiting and exposes that via sysfs or similar

After we determine which hardware has support for this feature, the following needs to be done:

  1. Write a wrapper for the charge circuitry that handles the cases for different phones (there's no way the controls for the charge limiter will always be in one place). Expose a dbus API for this wrapper.
  2. Write the required AppArmor policy so apps may only use the charge circuitry if they've been specifically enabled.
  3. Build the charge limiting into system-settings via the dbus API

I'm putting this information here so that I can mark this issue as 'help wanted'. This would be a great opportunity for a developer motivated to save the battery on their phone.

The first step is to determine which devices support charge limiting, then to document where the kernel controls are located. If you have that information for any of our supported devices, you can post it here.

ernesst commented 4 years ago

Hello, I've somewhat developed a proof of concept which will need further polishing. It could take several roads :

I like the idea to move it as a background service reading a config file and writing information into a sqlite db. The first one for directing its action the second to allow another UI to read information (like the power indicator or stat circle from the homepage) Anyway plenty of possibility and idea.

The software : https://open-store.io/app/indicator.upower.ernesst It looks for writing access to the file /sys/class/power_supply/battery/charging_enabled. it works well on my OP3

Currently the python script read at each boot a config file, the writing could be easily coded into the indicator as shown above. Unfortunalty i've no knowledge on c++, only python.