FORUMS
Remove All Ads from XDA

[APP][ROOT][4.4+]Battery Charge Limit v1.0.4

131 posts
Thanks Meter: 471
 
Post Reply Email Thread
Announcement from harsha1397: App to stop charging of mobile at desired limit
Please read the following before installing the app:
  • This app requires a rooted mobile (Android 4.4 or later)
  • Before uninstalling the app, disable limit in the app (if forgotten, reboot after uninstalling)

Usage instructions and app details:
  • Enable limit in the app
  • Change the limit up to which it should charge (default: 80)
  • Check which control file suits best for your device, see Q/A section below for hints. In most cases, the pre-selected choice should be the best that's available for your device.
  • The app only gets kicked in while you connect a charger (or USB), and automatically closes shortly after unplugging charger (or USB) i.e it only runs in the background as long as it is plugged in, and won't affect your battery life.
  • If your device is not charging even after disabling the limit (which shouldn't happen, just in case), uninstall the app and reboot the device (The changes made by the app don't survive a reboot). Your device should charge normally then.

If the app says "your device is not yet supported"
There are various control files in different devices (due to OEMs), and toggling the values in them (0 and 1) makes it possible to enable and disable charging via software (might not be possible for every device), though the charging cable is still physically connected.
Since we cannot own every device, it is impossible for us to find every file. We can support a lot more devices with information provided by testing possible files on different devices by you, the people in the community.
Hence, for support to be provided to other devices, you need to do some detective work to find the files on the respective devices. Please refer to this file for control files of currently supported devices, so you can know where they are generally present: https://github.com/sriharshaarangi/B...rol_files.json
You can send us a pull request or open an issue on GitHub. If necessary, you can also post the name of the device and the file here.

FAQ
Q) Can you please add support for... (insert arbitrary device name here)?
A) Maybe, but we need your help. Bottom line, this app does nothing but modifying the content of a certain "control file", some more details are given above. If you find such a control file for your device, please let us know (ideally, open a GitHub issue here: https://github.com/sriharshaarangi/B...geLimit/issues) and we will add support for your device.

Q) I think I observed a bug. Can you fix it?
A) We'll do our best, but we need your help: Please open an issue on GitHub (https://github.com/sriharshaarangi/B...geLimit/issues) and provide as much information as possible about the problem.
In most cases, we need the "logcat" logs of your device to find out about the exact issue. In order to provide those, you could use aLogcat (https://play.google.com/store/apps/d...logcatroot.app).
FOR CHARGING-RELATED ISSUES: Select the "Time" format in the preferences of aLogcat, so we can see precise timings, and filter for "(Charging|Power) State" with "Apply as regular expression" ticked.
FOR CRASHES: Please also select the "Time" format and provide unfiltered logcat data that includes the stack trace of the crash.

Q) Why do you want to limit charge to a lower capacity?
A) In short, to prolong battery life in long term usage. For more information, refer this : http://batteryuniversity.com/learn/a...ased_batteries

Q) How does this app work? Does it modify something in the ROM/Kernel to stop charging?
A) It writes "0" or "1" to a control file that represents some state of the power supply hardware, as simple as that. The file is normally read-only, so you need root to overwrite it.
The change might be automatically reversed by the OS if the power supply situation changes. Anyway, it should never survive a reboot of the device.

Q) I can select multiple more than one control file in the radio group. Which one should I use?
A) For most devices, battery_charging_enabled or store_mode are preferable. Try those first and see if it works. If you observe any bugs, try another file.

Q) I have a OnePlus (3/3T) device, and the app doesn't work correctly for me on OxygenOS. What to do?
A) Check that the control file you selected is NOT battery_charging_enabled! Although it should be preferred in general, there are known issues for this file with OnePlus devices.

Q) I use the store_mode on a Samsung device. My device always stops charging at 70 % (or other specific percentage), no matter what limit I have set.
A) The store_mode implementation differs among the supported (Samsung) devices.
Normally, it freezes the level at the current percentage when store_mode is triggered until the cable is unplugged for some seconds. This is a normal condition due to Samsung's kernel implementation, it's not a bug of this app.
If this is a problem for you, try to switch to another control file (e.g. batt_slate_mode), if supported.

Q) How does the "automatic stats reset" work?
A) The automatic reset should perform a stats reset when your power supply is removed while the battery level is within the desired range. Everything else is wrong behavior.

Q) No matter if I the "automatic stats reset" is enabled or not, my phone is always resetting my battery statistics. Why?
A) Are you using a threshold above 90%? If yes, your ROM will most likely clear the stats when the power is removed. There is nothing we can do about that.

Download Links:
v1.0.4: https://www.androidfilehost.com/?fid=889764386195927297
v1.0.3: https://www.androidfilehost.com/?fid=745425885120755941
v1.0.2: https://www.androidfilehost.com/?fid=889764386195923345
v1.0.1: https://www.androidfilehost.com/?fid=889764386195919111
v1.0.0: https://www.androidfilehost.com/?fid=817550096634789023
v0.11.0: https://www.androidfilehost.com/?fid=961840155545580765
v0.10.0: https://www.androidfilehost.com/?fid=961840155545576298
v0.9.2: https://www.androidfilehost.com/?fid=457095661767160082
v0.8.2: https://www.androidfilehost.com/?fid=673368273298951679

Please uninstall versions < 0.8 before installing this!

Changelog:
1.0.4:
  • New "always write" setting for devices that modify their control files in a problematic way
  • Experimental support for Xiaomi MiPad 2, Nexus 5, Nexus 9, Galaxy Nexus (maguro) and Xiaomi Mi6

1.0.3:
  • Fixed service starting after boot when disabled

1.0.2:
  • Fixed ignoring "ACTION_POWER_CONNECTED" when service was disabled
  • Experimental support for Nexus 10, Nvidia Shield and Xiaomi Mi6

1.0.1:
  • Added preference to disable limit enforcement aka "state fixing"
  • Added expert preference to enable immediate reaction to power state events (be careful!)

1.0.0:
  • Tested Magisk 13.x support
  • Improved UI
  • Even higher service priority (against being killed by Android)
  • Online limit change support (limit changeable while service is active)
  • Settings with control file selection and temperature scale
  • Fahrenheit temperature info support
  • Greatly improved "state fixing" with exponentially increasing delay (hopefully fixing GitHub issue #15 aka "rapid cycling")
  • Greatly improved SU shell speed/performance
  • German translation

0.11.0:
  • Improved UI (Using NumberPickers, GitHub issue #13)
  • Show voltage and temperature in app and notification (GitHub issue #14)

0.10.0:
  • The recharge threshold can now be customized between 0 and the chosen charging limit
  • Sending a charging limit of 100 via (broadcast) intent will disable the service.
  • Sending values between 40 and 99 will enable and start the service if it was previously disabled.

0.9.2:
  • Fixed crash on some devices that are unrooted or unsupported

0.9.1:
  • Fixed widget not showing in some devices

0.9:
  • Added Widget to toggle service
  • Added scrollable view

0.8.2:
  • experimental Amazon Fire support

0.8.1:
  • Bugfixes

0.8:
  • State check after boot (starting monitoring service as necessary)
  • Bugfixes

0.7:
  • Experimental support for Huawei and Nexus 4 devices
  • Support for external control over charging limit
  • Bug fixes

0.5
  • Ability to select recharge limit (Range: 10%)
  • Automatic file selection
  • Added store_mode for Samsung devices
  • Added option to auto reset stats
  • (Huge code refactoring)

0.3
  • Updated to support 7.1.1
  • Auto-select the battery charging file for Samsung, Pixel and Nexus devices
  • Added clear battery stats button
  • Auto-whitelisting from Doze mode

XDA:DevDB Information
Battery Charge Limit, App for all devices (see above for details)

Contributors
harsha1397, real_milux
Source Code: https://github.com/sriharshaarangi/BatteryChargeLimit


Version Information
Status: Beta
Current Beta Version: 1.0.4
Beta Release Date: 2017-09-04

Created 2017-02-15
Last Updated 2017-09-04
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20170215-181142.png
Views:	37914
Size:	52.6 KB
ID:	4042272  
The Following 257 Users Say Thank You to sriharshaarangi For This Useful Post: [ View ] Gift sriharshaarangi Ad-Free
 
 
15th February 2017, 01:37 PM |#2  
OP Senior Member
Flag Chennai
Thanks Meter: 471
 
Donate to Me
More
Todo:
- Check for charging on device boot
- Widget for quick toggle
- Widget to reset batterystats
- Limit reached alert
- Low battery alert
- UI overhaul
The Following 36 Users Say Thank You to sriharshaarangi For This Useful Post: [ View ] Gift sriharshaarangi Ad-Free
15th February 2017, 03:22 PM |#3  
Member
Thanks Meter: 23
 
More
I can't believe it. You can't imagine how long I was looking for such an app .
Will try it!
The Following 7 Users Say Thank You to Freezy202 For This Useful Post: [ View ] Gift Freezy202 Ad-Free
15th February 2017, 06:49 PM |#4  
Ace42's Avatar
Senior Member
Flag New York
Thanks Meter: 1,444
 
More
I remember this was a feature that some kernels had years ago, and I would limit the charge to 85%. On my laptop I can cap it to 60%, which is great because I leave the charger in often.

Anyway, thank you for making this app!
The Following 3 Users Say Thank You to Ace42 For This Useful Post: [ View ] Gift Ace42 Ad-Free
15th February 2017, 07:23 PM |#5  
OP Senior Member
Flag Chennai
Thanks Meter: 471
 
Donate to Me
More
Quote:
Originally Posted by Freezy202

I can't believe it. You can't imagine how long I was looking for such an app .
Will try it!

Quote:
Originally Posted by Ace42

I remember this was a feature that some kernels had years ago, and I would limit the charge to 85%. On my laptop I can cap it to 60%, which is great because I leave the charger in often.

Anyway, thank you for making this app!

Did you get a chance to test it? Is it working as expected?
The Following 6 Users Say Thank You to sriharshaarangi For This Useful Post: [ View ] Gift sriharshaarangi Ad-Free
15th February 2017, 07:49 PM |#6  
Member
Thanks Meter: 23
 
More
Quote:
Originally Posted by harsha1397

Did you get a chance to test it? Is it working as expected?

Unfortunately it does not work as it should :/. It doesn't really limit. Even when I unplug the notification doesn't go away as you mentioned.
I have a HTC One M8, android 6.
The Following User Says Thank You to Freezy202 For This Useful Post: [ View ] Gift Freezy202 Ad-Free
15th February 2017, 08:51 PM |#7  
OP Senior Member
Flag Chennai
Thanks Meter: 471
 
Donate to Me
More
Quote:
Originally Posted by Freezy202

Unfortunately it does not work as it should :/. It doesn't really limit. Even when I unplug the notification doesn't go away as you mentioned.
I have a HTC One M8, android 6.

Does the battery percentage continue to rise beyond the limit? Regarding notification, it doesn't immediately go away after unplugging. It goes away after the percentage drops 3% below the limit. It is to ensure that the phone again charges to the limit if the phone is still plugged in. If it is not plugged in, then notification closes.
The Following 2 Users Say Thank You to sriharshaarangi For This Useful Post: [ View ] Gift sriharshaarangi Ad-Free
15th February 2017, 09:24 PM |#8  
Senior Member
Flag tbilisi
Thanks Meter: 83
 
More
very good idea, thanks for app, was looking for app like this for a long time will report in half hour if app works
15th February 2017, 09:30 PM |#9  
kos25k's Avatar
Senior Member
Thanks Meter: 291
 
More
thanks!I always was searching such an app cause:
1)I read if u charge your battery till 80% it will last more time..
2)At the end of the day,I always have 40% battery left and I cant trust my phone for the next day without charge.
Thanks again It works on my moto x play!It stopped at 79% but its ok not such a big deal!
The Following User Says Thank You to kos25k For This Useful Post: [ View ] Gift kos25k Ad-Free
15th February 2017, 10:05 PM |#10  
Senior Member
Flag tbilisi
Thanks Meter: 83
 
More
ok, so it worked, but first time, when i unpluged and pluged app didn't noticed pluging and continued charging. after that i tried several times and it worked again. so there should be somewhere bug in monitoring pluging charger sometimes is left unnoticed.

Sent from my ONE A2005 using Tapatalk
The Following 2 Users Say Thank You to chxei For This Useful Post: [ View ] Gift chxei Ad-Free
16th February 2017, 01:42 AM |#11  
Ace42's Avatar
Senior Member
Flag New York
Thanks Meter: 1,444
 
More
Quote:
Originally Posted by harsha1397

Did you get a chance to test it? Is it working as expected?

Seems to work on my LeEco Pro 3. Charging icon switched to normal battery at 80%.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20170215-193653.jpg
Views:	15750
Size:	103.5 KB
ID:	4042896  
The Following 2 Users Say Thank You to Ace42 For This Useful Post: [ View ] Gift Ace42 Ad-Free
Post Reply Subscribe to Thread

Tags
battery, charge, charging limit

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes