yashsingh1/xdaforums huggingface dataset:
[Android Apps and Games] dimm0k:
LGV20 device

what I am noticing with the Tasker version is that battery_charging_enabled always changes to 0 properly once the number is reached, however the battery level stays at that level no matter what I do as long as the device remains connected. the screen also stays on for no reason when I receive a notification if the battery level is greater than what's set. it's like the task keeps the screen on for some reason. the other thing is that I can see battery_charging_enabled remains at 0 while connected, but SOMETIMES it stays at 0 even after I unplug. sometimes it changes back to 1
[Android Apps and Games] ALTAMAS:
Where to search....?
[Android Apps and Games] RedSkull23:
In this thread!

[MENTION=5247459]ALTAMAS[/MENTION]
[Android Apps and Games] xcal_tau:
In magma UX 9.7, note 3 n9005, whatever kernel i used, the battery charge limit only work once. The second charge don't work. Even after i disable the charge. The battery will not charged. Disable apps doesn't work, i need to reboot to make the charging work again. It looks like it makes the state of charging to full or reach the charge limit, and it hang there. Please fix

---------- Post added at 10:57 PM ---------- Previous post was at 10:54 PM ----------

Doesn't work on magma ux 9.7. Note 3 n9005. Whatever kernel. Charge, the limit work. But the second charge, it doesn't work, make the state of charging to full or reach the limit, so whatever i do to charge, battery will not charged. I must reboot to make it charge again. I have tried the settings, not work. Please fix

---------- Post added at 10:58 PM ---------- Previous post was at 10:57 PM ----------

Doesn't work on magma ux 9.7. Note 3 n9005. Whatever kernel. Charge, the limit work. But the second charge, it doesn't work, make the state of charging to full or reach the limit, so whatever i do to charge, battery will not charged. I must reboot to make it charge again. Please fix
[Android Apps and Games] Infy_AsiX:
I instead have a Tasker profile with the state of battery level 85-100 to set charging to 0 with the same mentioned exit task. It doesn't seem necessary to have a loop checking the state when Tasker has the built in function? The plugged in state variable isn't required then either.

Unsure why your screen stays on. See the above quote for the exit task to re-enable charging after unplugging.

Does the file reset back to 0 when it charges up past? Or is it just charging normally while showing "not charging"? If it's resetting, you could try changing the permission to "writable" before setting batt_slate_mode and then "read only" after. If this works check to see if the file's permission and value resets to default after rebooting. If it does then it's fine after a reboot, but if it doesn't your device won't charge until a Task or script runs to reset the file.
[Android Apps and Games] dimm0k:
interesting. I've changed up my Tasker Profile so that it's triggered only when the battery level is between 85-100 AND if it's plugged in otherwise this won't be triggered if the battery level is between 85-100 and not plugged in. my IF statement to trigger the shell command is set at >90 so once battery level hits 91 charging should stop. without the loop I could not get the shell command to echo the 0.

I believe the Profile is entered once, so the shell command to echo the 0 is never triggered without the loop since the IF statement fails. I also think because of this loop my screen stays on should it ever come on for any reason until I unplug, triggering the exit task.

Lastly it seems this Tasker Profile constantly charges the battery so that it stays at 91... once it reached that I noticed using the device kept my battery level at 91 no matter how long I used it!
[Android Apps and Games] Mx WaR HaBiB:
Does the file reset back to 0 when it charges up past?

No

Or is it just charging normally while showing "not charging"?

Yes

shows that it should not charge but eventually reaches 100% :(
[Android Apps and Games] Infy_AsiX:
Do you mean your device lacks the sys/class/power_supply/battery/ folder or it's charging_enabled file? An alternative method is to set sys/class/power_supply/usb/current_system_max to 0. I find the value normally fluctuates and increases based on however the thermal algorithm is designed. However after plugging in and setting a value manually it will keep that value until replugged.

From monitoring my device the thermal configuration seemed poor as it would rather aggressively throttle the current. The best I could figure is it didn't really seem to be battery temperature related, but rather already throttling starting at an average CPU temp of 60°C over about 30 seconds!

You can set the current as I mentioned above. Using a thin cable might be an ok workaround but has the downside of increasing resistance and lowering interference shielding.

https://drive.google.com/file/d/0BzPejZy60f0GTlN2QTVBVDFUREk/view?usp=sharing

So I just spent some time fixing and tidying up the Tasker setup I mentioned previously for sharing. Place in sdcard/Tasker/projects and import via the Home button in Tasker's bottom left. It's relatively easy to understand and self explanatory by checking the setup, so changing your own values in is ok. This is set using these two required files:

/sys/class/power_supply/battery/charging_enabled

/sys/class/power_supply/usb/current_system_max

edit update 15/9/17: I renamed all the profiles and tasks with a number so they can be sorted into a legible sense as Tasker's import seems to ignore any previous set sort.

It would be probably possible to create a similar setup using just current_system_max. I used both files when I started and that simplifies the configuration a little. It's a dozen profiles as well as tasks exported together as a project.

Note my device lacks Qualcomm quick charge so the max is 1500. Use Tasker's search and replace the 1500000 with whatever for testing. I've actually got a QC2.0 charger here and looking at current_system_max when using it, the values were slightly higher when throttled than a normal 1.5A charger IIRC.

Using this table from http://batteryuniversity.com/learn/article/how_to_prolong_lithium_based_batteries

[IMG="Table 4: Discharge cycles and capacity as a function of charge voltage limit."]https://i.imgur.com/7rawyJ5.jpg[/IMG]

I monitored /sys/class/power_supply/battery/voltage_now to set my limit at 4.05V which is also 85% on my Z3C with it's 4.25V down from 4.35V firmware feature. A good app for real time overlaying I use is Cool Tool, useful too for monitoring the current draw at /sys/class/power_supply/battery/current_now while in use.

I'm not sure but it does work without plug state for me. Maybe give my project a test and see.

Yeah leaving the charge at a certain percentage is one way. Following this post's knowledgeable insight I've set a basic trickle like charge effect based on the third suggestion. After monitoring the voltage a 2% range fits that suggestion.
[Android Apps and Games] Gibbothegreat:
What's missing is the charging_enabled file.
[Android Apps and Games] :
ssss
[Android Apps and Games] post-mortem:
If the voltage of the battery is not changing, then what's the harm?
[Android Apps and Games] phantom146:
[MENTION=6898873]sriharshaarangi[/MENTION]

It seems that the battery stat reset isn't going too well, there are two lines of error on my end.

Log is attached.

Error: Cannot reset battery stat manually and automatic
[Android Apps and Games] post-mortem:
Are you sure those errors are coming from this app?
[Android Apps and Games] phantom146:
Not really sure to be honest, and is skeptic about it. But I am pretty sure there's something strange going on as the battery reset before was all good until I rebooted or so (which I doubt was the cause) and from then on, the reset stat won't work (even if Magisk grants root).
[Android Apps and Games] takis:
Will this ever be on the Playstore?
[Android Apps and Games] Infy_AsiX:
That depends is the voltage actually not changing or are you referring to the percentage output?

If power management does keep the voltage under the preferred limit while keeping the maximum percent limit the same, then there is some smart logic limiting the current. The reason being that voltage further increases as current increases. Power management at 100% has separate logic limiting the current due to safety needs.

Since we're stopping the charge early at a certain percentage under 100, power management charges at the standard current rate resulting in a higher than preferred voltage. That's why lowering the current as much as possible when nearing the preferred voltage limit for a trickle effect avoids that problem.

I just watched my voltage again and after some testing realised I can get another 5% to reach 90% while still under 4.05V by stepping down the current appropriately. As the charge rates are well below 500mA, the battery only reaches 90% when not in use. I've made fixes to the shared Drive link as version 5 if anyone's interested.
[Android Apps and Games] post-mortem:
You should consider starting your own thread.

:cowboy:
[Android Apps and Games] hgmichna:
Charging logic

Weird. I don't understand a word.

Could you tell us where you got the idea from that "there is some smart logic limiting the current"? All we have been talking about here is that either the charging is automatically switched on and off or the current from the charger bypasses the battery altogether and directly feeds the phone.
[Android Apps and Games] Infy_AsiX:
Well sure, if there's some miracle battery that somehow charges capacity while voltage isn't raised by the level of current. That "charging is automatically switched on or off" works by some logic algorithm. The point is whether there is any smart design to lower the current to keep voltage down or simply "dumb" fast charge to the capacity limit. There should be some at 100% for the safety reason of not exceeding the voltage limit.

Rare if it exists, a phone that's not wired through the battery first or both ways. Got some proof?
[Android Apps and Games] phantom146:
Hmmm it might be the cause of the battery reset not working for me is Magisk v14 (the app I think isn't updated for it) because when I switch to Supersu, it works fine af :)
[Android Apps and Games] edjocute:
I've found that Magisk doesn't work with battery reset (on some devices) because the dumpsys command doesn't have sufficient permissions to run properly when SELinux is enforcing. This is the same problem with aggressive doze in apps such as Naptime and Greenify which also relies on the dumpsys command. You can either turn SELinux off or set the proper permissions with:

sepolicy-inject --live "allow system_server su fd use"
sepolicy-inject --live "allow system_server su fifo_file write"

You'll need su to run these commands of course, or you can put these into a file in the /magisk/.core/service.d/ directory to have the permissions modified automatically on startup.
[Android Apps and Games] Mx WaR HaBiB:
when I change the value of this file my mobile is restarted and it returns to its original value :crying:
[Android Apps and Games] phantom146:
You da real mvp!
[Android Apps and Games] aamadorj:
Thanks a lot!!! In my opinion, you fixed a legendary issue.
[Android Apps and Games] d0x360:
Just wanted to give an update to the app not working on my pixel xl. I figured it out today. It's because I was using the app "ampere" to measure power from the charger at the same time.

I'm not sure why one would effect the other but I did a full wipe and installed Oreo last week and it still wouldn't work...then I figured I'd give it a shot and found any app that is actively monitoring how much power the phone is drawing from wall will make this app not work.
[Android Apps and Games] Cronoss:
Guys I have an issue:

The limiter works perfectly on my Galaxy S3 T999 with Lineage OS

the issue is that, for example I set the limit to 80, it will cut the charging. Great. But after that, the battery percentage will always remain at 80%. No matter how much use I give it.

I'm talking about having the wall charger plugged in.

Even if the charger is plugged in, shouldn't it still go down to what I set my lower limit? In my case, 20.

I have removed all other battery monitoring apps and even set SELinux to passive.

Using SuperSu

I'm also using the default profile for samsung devices.

Any ideas?

EDIT: If I manually unplug the charger and connect it back, then power begins to drop as it should until it reaches the lower limit and starts charging again.

This until in reaches the upper limit and then freezes again.

EDIT 2: I'm NOT using store_mode. I'm using batt_slate_mode

EDIT 3: I found out that if I reach the "limit charging %" and disable Battery Charge Limit service and re enable it immediately afterwards, the % drops normally and then starts recharging again.

Can someone help me set up tasker to stop the service once battery % reaches a certain number and the restart the service?

That would work perfectly.
[Android Apps and Games] SolidSTI:
So if your phone will only discharge after installing on a Nexus 6, what is the best way to revert all of the changes the application performed?
[Android Apps and Games] ashutoshmn:
Well, this guy knows his game for sure. Great observation indeed.

And I completely agree with you. Another thing I would like to mention is that upto 65% or so the voltage is well around 4.0 volts while still charging and from there it starts to increase and till it reaches 80%, the voltage is around 4.22 volts, that high you might be wondering, right?

But, the thing is that 4.22 value is only while it is still charging and nearing to 80% and as soon as it reaches 80% charge, the charging is shut off and voltage drops to 4.1 ish something, so that means during charging there is more voltage pushed as compared to non-charging for a particular battery percentage.

Now, to sum it all up and relate all this to your post, here's the deal:

As you said if we reduce the charging current to an appropriate level (lets say 500ma) after the charge reaches 65%, then next 15% worth of charge there will not be much increase in voltage (as V ∝ I).

Now, can you please guide here, how to do that via a program/script or something if one has a kernel that supports varying charge levels. Can this can be implemented in this app itself. These is a file in thr root directory which this app can edit as soon as charge reaches a particular value and all this happens on-the-go.

Just tagging you also [MENTION=6898873]sriharshaarangi[/MENTION] bro, for your insight.
[Android Apps and Games] post-mortem:
Instead of hard-coding the file names, you could use a reference, then may a scene or even a text file allowing someone to choose the charge-limiting file appropriate for their device. That way, the Tasker project you created will function out of the box on most devices, including whatever turns out to be your next device.
[Android Apps and Games] Infy_AsiX:
Each charge stopping file behaves differently though, requiring specific changes to the setup. It's a nice idea I haven't experience in yet though. Changes aren't too difficult as it is already. If anything it's a working proof of concept, just needs testing feedback and improvement feature ideas. Someone can take this and probably go further with it
[Android Apps and Games] post-mortem:
You know, if you did get it to work on different devices, it would be relevant to the masses, as it would be kernel and chipset independent. You'd just need to know which files are relevant to which vendor.
[Android Apps and Games] RedSkull23:
I'm about to insert the command lines on the file. There's a specific name that i should give to the file?
[Android Apps and Games] paperjam252:
I have a Samsung Galaxy Tab 3 7.0 that this app doesn't seem to want to work with. It has the batt_slate_mode control file but changing it to 0 sticks sometimes and sometimes not. Either way it won't stop charging. There are also two other files, one called charge_now and one called uevent with a line that says power_supply_charge_now=1. Changing either of these to 0 is immediately reset after saving and re-entering the file. I'm looking in the root/sys/class/power_supply/battery folder. Anyone have any suggestions on where else I can look?
[Android Apps and Games] edjocute:
I don't think so. You should probably also have #!/system/bin/sh as the first line. Magisk logs should show it reading from the file if working properly.

Here's a magisk module if anyone requires.
[Android Apps and Games] RedSkull23:
I've just applied the module and i tried to manually reset battery stats, finally it works flawlessly; you solved a long issue of mine that i have since i installed Battery Charge Limit on my Honor device. Thanks a lot, man
[Android Apps and Games] AssToast:
Thank you for this great app but I have an idea.

Is it possible to implement a separate notification with sound when the battery reaches the set charge?
[Android Apps and Games] tapa_t:
Does this really stop charging or just stop updating current battery state (voltage?) to the system?

I have an Xperia phone and echo 1 echo 0 > /sys/class/power_supply/battery/charging_enabled at 90% charge.

Charging appears to stop at 90% and gradually comes down by 1% an hour (or less) while still plugged in.

Last night, I unplugged maybe 2 hours after charging stopped and it showed 88% charge in the status bar.

After 9 hours, it still shows 87% charge this morning. I use NO stamina mode of any kind.

I know this phone is pretty energy efficient from experience but this is kind of extreme.

I am wondering whether the battery was still being charged beyond 90% and just not being shown above 90%?

Is there a sure way to know the current battery state? Or, what is says in the status bar and in the settings is accurate?
[Android Apps and Games] bluegizmo83:
No, it really stops charging. On some phones though, when you disable the control file (or use this app), It stops charging at that moment (or whatever percentage you set in the app) but it doesn't completely cut the current. It basically supplies just enough current to maintain the battery at it's current percentage. On other devices it completely cuts the current like no cable is attached. It just depends on the device. No matter what though it stops charging (i.e. charge does not increase, if it's working properly).

Edit: you can check battery voltage to verify it's not really charging to 100%, either through an app like AccuBattery that shows battery voltage, or pull the back of you phone off and check the battery with a volt meter. First charge to 100% and see what the battery voltage is, then limit charging with the app to like 80% and see what the voltage is, it should be lower that it was at 100%
[Android Apps and Games] hgmichna:
Li-ion battery voltages

For reference, without any charging current 4.2 V means 100%. Some phones charge to 4.3 V.

3.92 V is 60%.

Another good app that measures the battery and a lot of other things is System Info for Android, by ElectricSheep. Tap System, Battery to get battery information including the voltage.
[Android Apps and Games] tapa_t:
Thank you for explaining.

I will try AccuBattery app to see the voltage.

The battery is not removable and pulling off the back is not an option as it surely mess up waterproofing of the phone, the only reason I use this phone :D
[Android Apps and Games] Devildire:
Anyone knows the path of the files' location on OnePlus 5, Android 7.1.1?

Generic setting works, but I want to use tasker for it instead. I already looked up '/sys/class/power_supply/battery/charging_enabled', but this folder does not exist for me. Also I searched for charging_enabled with root explorer and did not find anything. If this app can change this mysterious file, I should be able to do this manually too, right?

Edit: found it, it actually was in /sys/class/power_supply/battery/charging_enabled, don't know why it didn't show up before...but changing it manually does not work. Except I disconnect and reconnect the charging cable, then it won't charge as expected. Is there any service running, that has to be restarted, when the file was successfully edited? How does this your app manage to do that?
[Android Apps and Games] Gregbol:
can be "batt_slate_mode"

Envoyé de mon SM-N930F en utilisant Tapatalk
[Android Apps and Games] ayu321:
Really nice app but my phone battery is draining too fast after using this . Like 1% a minute ! Im not using a custom rom , Im on stock rom .
[Android Apps and Games] post-mortem:
Have you restarted your phone at least once since first running this app? And just checking: You are rooted, right?
[Android Apps and Games] AdroitAdorKhan:
I want to translate! I can help to translate this app to Bengali (Bangladesh) language!
[Android Apps and Games] marbertshere:
I just wanted to say that I had some issues with the app after beta, but 1.04 is solid! Thanks!
[Android Apps and Games] Bobbaloo:
Made it through the transition from Nougat to Oreo on my 6p. I was pleasantly surprised. Thanks again for this OP!
[Android Apps and Games] NuronZ:
Very nice and helpful app! Thanks a lot!
[Android Apps and Games] pistachia:
Setting of low limit

Thanks! It works on my Redmi Note 4X. I set high limit to 85% and low limit to 50%. It stopped charging at exactly 85%.

After some usage when the battery dropped to 56%, I connected the phone to USB and it started charging immediately. Is it supposed to only start recharge below the low limit (set to 50%)? or the low limit is for some other purposes:confused:
[Android Apps and Games] post-mortem:
The app only actively limits charging while the device is plugged into a charger. So if you plug in the device and it charges to 85%, the app will disable charging. Then you leave the device plugged in all day long. The device battery slowly discharges on its own. If the battery level reaches the low level (50%, in your case) while it's still plugged in, the app will re-enable charging until the high level again. Once you unplug your device from the charger, it is completely inactive (if it's 84% when you plug it in, it will charge to 85%).
[Android Apps and Games] pistachia:
Well explained. Thanks
[Android Apps and Games] _pantherpl_:
The Battery Chaghe Limit app from https://xdaforums.com/android/apps-games/root-battery-charge-limit-t3557002 doesn't work for some reason. I do have root (by Magisk), and toast messages show that everything gets granted and enabled
[Android Apps and Games] Pipiou211:
Hello [MENTION=6898873]sriharshaarangi[/MENTION] , your application works perfectly on my Nexus 6P!

Can I please have a version of Battery Charge Limit that allows me to limit down to 1%?

I want to charge-discharge my battrry from 8% to 15% and it will be really helpful (just an idea to try cure the famous nexus 6p battery issue) .

You're the best!
[Android Apps and Games] post-mortem:
What device? Model #? Logs?

We need more information to help you.
[Android Apps and Games] _pantherpl_:
Yes, I know, I meant to post this in the thread of the ROM I used, not here... This farce could be avoided if there was an option to delete your own posts quickly... Anyway, I solved the problem by going back to a ROM I used previously, and if a mod is reading this please remove my comments
[Android Apps and Games] post-mortem:
Although we can't delete our own posts, we can always edit our posts to say, "Never mind, I've fixed it."
[Android Apps and Games] soseono:
Working fine on OnePlus 3T with the charging_enabled (Generic) control file. Root is Magisk v14 and I'm having no issues with it. Thank you so much for this awesome app!!!!!