[APP][ROOT][4.0+]Battery Charge Limit v1.1.1

Search This thread

amn1987

Senior Member
I don't have the same problem that you described in your previous post, at least I don't think so. Haven't checked it out too much.

Yes block the wakelocks that occur while using acca or battery charge limit to avoid 2-3% standby drain during the night and so on. Just make sure to take your time to test it out and make sure everything still works when blocking the wakelock.

I attached a screenshot of the wakelocks I'm blocking. Haven't been blocking all these for that long but my standby drain is about 0.5% per hour at the moment while charging cable still plugged in and everything seem to work and I haven't experienced any problem with massive drain later or so. Also this is on my poco f1.

Thanks for the suggestion. I had been looking for an app to block wakelocks reliably for some time. Just started. Hopefully this will do the trick.
P.S. Only those depicted in your ss need to blocked? Also safe to apply on boot?
 

JD. A

Senior Member
Sep 9, 2013
967
278
Thanks for the suggestion. I had been looking for an app to block wakelocks reliably for some time. Just started. Hopefully this will do the trick.
P.S. Only those depicted in your ss need to blocked? Also safe to apply on boot?
I've haven't found any problem by blocking these, it's not that easy finding out exactly what they do though. I suggest you try yourself and start blocking both kernel and app wakelocks which is keeping your phone awake for long amounts of time if you run into a problem revert the last blocked wakelock. Also don't block any wakelock containing "PowerManager" etc. Those are basically catch alls from what I've found out. So if you block them you'll most likely run into problems.
 

andrasandhi

Senior Member
Dec 10, 2010
493
115
Bandung
Moto G5S Plus
Realme 6 Pro
Charging control file on Realme 6 Pro (RMX2061)
 

Attachments

  • Screenshot_2020-06-29-13-06-50-99_8e83d07f350116947e2a7caeff30f633.jpg
    Screenshot_2020-06-29-13-06-50-99_8e83d07f350116947e2a7caeff30f633.jpg
    137.5 KB · Views: 348

Osprey00

Senior Member
Jul 21, 2009
449
212
FYI, I found that the following CTRL file works for wireless charging on my phone (LG V30):

/sys/class/power_supply/dc-wireless/charging_enabled

Many thanks to the developer for this great app. If I may make a suggestion, it would nice if we could designate multiple CTRL files so that the service could work with both wired and wireless. If it's not possible to detect which charging method is being used, you could possibly just enable/disable both files at the same time. Edit: Also, adding that path as one of the pre-defined ones in the app would be quite useful, I'm sure.

Edit: I forgot to mention that one quirk that I've noticed is that, only when using that path for wireless, the app ignores the "Recharge below" setting and starts recharging as soon as the percentage drops 1% below the max.
 
Last edited:
  • Like
Reactions: MaverickNextDoor

whitedavidp

Senior Member
Jul 31, 2012
632
185
FYI, I found that the following CTRL file works for wireless charging on my phone (LG V30):

/sys/class/power_supply/dc-wireless/charging_enabled

Many thanks to the developer for this great app. If I may make a suggestion, it would nice if we could designate multiple CTRL files so that the service could work with both wired and wireless. If it's not possible to detect which charging method is being used, you could possibly just enable/disable both files at the same time.

Edit: I forgot to mention that one quirk that I've noticed is that, only when using that path for wireless, the app ignores the "Recharge below" setting and starts recharging as soon as the percentage drops 1% below the max.

After this I went looking on my V40 Thinq (LM-V405QA) and found this file:

/sys/devices/platform/soc/a90000.i2c/i2c-4/4-0061/power_supply/wireless/charging_enabled

Without a wireless charger I cannot test. But I have added it to my Tasker routines that approximate what this app does. So both wired and wireless get written. Thanks
 

Osprey00

Senior Member
Jul 21, 2009
449
212
After this I went looking on my V40 Thinq (LM-V405QA) and found this file:

/sys/devices/platform/soc/a90000.i2c/i2c-4/4-0061/power_supply/wireless/charging_enabled

Without a wireless charger I cannot test. But I have added it to my Tasker routines that approximate what this app does. So both wired and wireless get written. Thanks
Yeah, that's the same file. The path that I gave includes symbolic links and, if you follow it in a file manager, resolves to a path very similar to what you gave, which looks to be specific to the SOC. On my LG V30, which has a Snapdragon 835, a couple of numbers are different than yours on an 845. In other words, the shorter path is the one that should exist on most phones (at least ones with wireless capability) while the longer one will differ slightly from phone to phone. Either one works with Battery Charge Limit, I've found, but the generic one is probably the better one to use.

I didn't consider automating writing of the files. I may have to try that. Thanks.
 
Last edited:
  • Like
Reactions: MaverickNextDoor

evronetwork

Senior Member
Jan 19, 2012
1,568
411
North
Wish there was an update of this app, it works as expected but the reset stats doesn't work, so I'm doing it manually

Xiaomi Mi MIX 2s
 

bamn

Senior Member
Jul 23, 2010
319
109
@sriharshaarangi or anyone who could help.

Maybe you could help me out, I am looking for a way to manipulate the battery temp reading or to force charging ignoring low batt temp.
The problem is that my batt temp reading sometimes jumps to -20(c) and it won't charge.

I can warm the phone up (hot air) or run a benchmark and the temp reading goes back to normal, it seems downwards from about 26c it jumps to -20.

It's a U11 running lineagos 17.1
Ideally I would only ignore the -20 value as this is never correct and keep the rest of the safety intact.
But I wouldn't mind ignoring the low temperature protection completely as it is rarely below 0 where I live.

I hope you are willing to help me out, I do understand the risks of ignoring temp values!
 

Osprey00

Senior Member
Jul 21, 2009
449
212
@bamn

If you look under /sys/class/power_supply/battery, there are three files that seem relevant:

charger_temp
charger_temp_max
temp

temp appears to hold the current temperature, since I see the value is slightly different each time that I open it. It's hovering around 290, which seems to be about what normal is. I'm guessing that the other two determine whether charging occurs by comparing their values to the value in temp. My charger_temp is blank/unreadable and my charger_temp_max is 1216. I'd try setting either or both to -1, then try 0, then other values. If you can't write to charger_temp, changing the permission might help or maybe you can even rename it and create file in its place with its name that you can write to. If none of that works, perhaps you can rename temp or change its permissions/ownership so that the system can't update it. Anyways, those are just some ideas.
 
Last edited:
  • Like
Reactions: bamn

bamn

Senior Member
Jul 23, 2010
319
109
@bamn

If you look under the same folder where the charging_enabled file is, /sys/class/power_supply/battery, there are three files that seem relevant:

charger_temp
charger_temp_max
temp

temp appears to hold the current temperature, since I see the value is slightly different each time that I open it. It's hovering around 290, which seems to be about what normal is. I'm guessing that the other two determine whether charging occurs by comparing their values to the value in temp. My charger_temp is blank/unreadable and my charger_temp_max is 1216. I'd try setting either or both to -1, then try 0, then other values. If you can't write to charger_temp, changing the permission might help or maybe you can even rename it and create file in its place with its name that you can write to. If none of that works, perhaps you can rename temp or change its permissions/ownership so that the system can't update it. Anyways, those are just some ideas.

Many thanks for your help!
I am able to open all these files but I cannot change the values and safe.
Changing the file name or permissions also gives an error.
I am rooted/unlocked and I tried different root enabled file managers and the echo/chmod command through terminal/tasker.

All options fail...
It's really stupid, I need to heat up my phone to get it to start charging, as long as it's charging the battery temp stays normal and slowly drops, from about 22 downwards it'll jump to minus 9 and then soon to -20.

With - 20 it won't charge and if I switch off/reboot it won't come back on again.
 

shiroichiii

Member
Apr 21, 2019
5
1
Hi I use this app yesterday, I set my limit to 80% and set recharging to 70%, i decided to disable it, it didn't work so I reboot my phone it still don't work, then I tried to cleanflash and installing new ROM but it still doesn't work it still limit my charging to 80% I even tried to changing back to my stock ROM but the problem is still here, please someone help me:(((
 

Osprey00

Senior Member
Jul 21, 2009
449
212
Many thanks for your help!
I am able to open all these files but I cannot change the values and safe.
Changing the file name or permissions also gives an error.
I am rooted/unlocked and I tried different root enabled file managers and the echo/chmod command through terminal/tasker.

All options fail...
It's really stupid, I need to heat up my phone to get it to start charging, as long as it's charging the battery temp stays normal and slowly drops, from about 22 downwards it'll jump to minus 9 and then soon to -20.

With - 20 it won't charge and if I switch off/reboot it won't come back on again.

It turns out that I have the same problem. Sorry. I should've tested, myself. The permissions on the file and folder appear to be OK. I'm reading that the system can "write lock" certain files to prevent them from being overwritten, which could be what's happening here. I'm not an expert in this area, so I'm not sure if there's any way around this. Something that you could maybe try is setting charging_enabled to 1 and then setting permissions and/or ownership on it to try to prevent the system from ever changing it back to 0. If that doesn't work, you might try an app like Tasker to set that file to 1 automatically whenever it reads that it's 0 or you connect your charge or something.

Hi I use this app yesterday, I set my limit to 80% and set recharging to 70%, i decided to disable it, it didn't work so I reboot my phone it still don't work, then I tried to cleanflash and installing new ROM but it still doesn't work it still limit my charging to 80% I even tried to changing back to my stock ROM but the problem is still here, please someone help me:(((

Have you uninstalled the app? If you installed it from the Play Store, then it will have re-installed itself on each new ROM as soon as you signed into your Google account.
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 400
    Please read the following before installing the app:
    • This app requires a rooted mobile (Android 4.0 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/BatteryChargeLimit/blob/master/app/src/main/res/raw/control_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/BatteryChargeLimit/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/BatteryChargeLimit/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/details?id=rs.pedjaapps.alogcatroot.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/article/how_to_prolong_lithium_based_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 device, and the app doesn't work correctly for me. 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.

    Downloads:
    The app is available on Google Play Store

    Alternate APK download links:
    v1.1.1: https://www.androidfilehost.com/?fid=674106145207486851
    v1.1.0: https://www.androidfilehost.com/?fid=817906626617956614
    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.1.1:
    • Fix charging status layout issues and misc UI fixes @xdnax
    • Added switch to disable toasts on service changes @xdnax
    • Added switch to show temperature in notification @xdnax
    • Ensuring write permissions on the charging control file @real_milux
    • Fixed notification sound on limit reach @sriharshaarangi
    • Fixed a bug causing crash
    • Added Russian translation
    • Updated Bengali, German and Brazilian Portuguese translations
    • Added control file for Amazon Tate (LineageOS 14.1)

    1.1.0:
    • UI & icon redesign @xdnax
    • Custom control file data support @xdnax
    • Improved control file lists @real_milux
    • ICS (Android 4.0, API 14) compatibility @real_milux
    • Pixel/Pixel 2 support fixes @xdnax
    • Added control files for Pixel/Pixel 2, Xiaomi Redmi Note 2, Sony XPERIA Mini, Le 1s, Huawei P10 lite, HTC One, Motorola Defy+, Xiaomi Mi A1
    • Bengali translation @AdroitAdorKhan
    • Spanish translation @Joseahfer
    • Lots of bugfixes and minor improvements

    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: Stable
    Current Stable Version: 1.1.1
    Stable Release Date: 2018-10-17
    Current Beta Version: 1.0.4
    Beta Release Date: 2017-09-04

    Created 2017-02-15
    Last Updated 2020-08-05
    59
    Todo:
    - Check for charging on device boot
    - Widget for quick toggle
    - Widget to reset batterystats
    - Limit reached alert
    - Low battery alert - Needs a service running in the background
    - UI overhaul
    - on/off switch to enable/disable charging
    38
    Announcement: Official Version 1.1.0, welcome @xdnax!

    Hello everybody,

    it has been quite a while since I wrote my last post here. The reason for this is rather simple:
    Apart from being very busy in the last months, I realized some time ago that I was investing more time in reading and answering posts in this thread than doing actual implementation work for BCL, which is definitely not my intended workflow.
    Therefore, I shifted my attention completely to GitHub, where the workflow was/is much more efficient.
    Some people here suggested to officially fork this project and continue it elsewhere. I want to say the following to those people:
    While it is in general a good thing that dead projects are forked and continued, good behavior demands to first open a GitHub issue asking whether the project is to be continued before suggesting an official fork, which did afaik not happen.
    Furthermore, a simple look at GitHub would have clearly revealed at all times that I was reacting to issues there on a regular basis, so our project was hardly inactive, and surely not dead!
    Luckily, @xdnax was considerate and smart enough to keep mentioning that he wants to respect our work and keep his fork unofficial for the moment, which deserves a huge THANK YOU from my side!

    Talking about @xdnax:
    He did a great job in contributing to the development of this app during the last months.
    Unfortunately, I didn't have his contributions on my radar for quite a while.
    Since we love to work with other motivated and decent developers like him, we are happy to announce that he is now the third "official developmer" of BCL.
    Welcome to the team, @xdnax!

    Some people noticed the appearance of a semi-official version 1.0.5.
    Although I never had time to publish an official build, I indeed created this version and uploaded it with a "v1.0.5" tag to our GitHub repo.
    This is where the F-Droid build system picked it up and created an APK from it, which I myself wasn't aware of for some while. Sorry for the confusion guys...

    During the last days, we organized our internal communication and unified our contributions to bring out a new official version.
    Well, here we go: I'm happy to announce that we finally release version 1.1.0!
    Link: https://www.androidfilehost.com/?fid=817906626617956614
    Please don't get confused about the numbering: This release includes all improvements of @xdnax and more, and is not a major version step because it doesn't introduce any breaking behavior changes.
    Happy charging, opening post will be updated soon!

    Changelog:
    • UI & icon redesign @xdnax
    • Custom control file data support @xdnax
    • Improved control file lists @real_milux
    • ICS (Android 4.0, API 14) compatibility @real_milux
    • Pixel/Pixel 2 support fixes @xdnax
    • Added control files for Pixel/Pixel 2, Xiaomi Redmi Note 2, Sony XPERIA Mini, Le 1s, Huawei P10 lite, HTC One, Motorola Defy+, Xiaomi Mi A1
    • Bengali translation @AdroitAdorKhan
    • Lots of bugfixes and minor improvements
    22
    Source code: https://github.com/sriharshaarangi/BatteryChargeLimit
    App v0.3: https://www.androidfilehost.com/?fid=745425885120716170
    Changelog:
    - Updated to support 7.1.1
    - Auto-select the battery charging file for Samsung, Pixel and Newus devices
    - Added clear battery stats button
    - Auto-whitelisting from doze
    19
    Update to version 1.1.1

    This is mainly a bug fixing update, with loads of improvements. Should reduce crashes as well.
    Download link: https://www.androidfilehost.com/?fid=674106145207486851
    The update will be available on Play Store soon[UPDATE: Now available]
    Changelog:
    • Fix charging status layout issues and misc UI fixes @xdnax
    • Added (i) Switch to disable toasts on service changes (ii)Add switch to show temp. in notification @xdnax
    • Ensuring write permissions on the charging control file @real_milux
    • Fixed notification sound on limit reach @sriharshaarangi
    • Fixed a bug causing crash
    • Added Russian translation
    • Updated Bengali, German and Brazilian Portuguese translations
    • Added control file for Amazon Tate
    • Other minor fixes