yashsingh1/xdaforums huggingface dataset:
[Magisk] VR25:
apply_on_boot and apply_on_plug are totally unrelated to this. I don't think you need these for charging control anyway. You can use the search function of your browser or text editor to find more information in the documentation (README file).

apply_on_boot and apply_on_plug are meant for applying miscellaneous kernel settings that may or may not be related to charging. In fact, those can even be used to tweak CPU governors, scaling frequencies, memory management, and really anything else that a kernel tweaking app does - and more.
[Magisk] VR25:
Here's a new snapshot, especially for those who are facing major issues:

**v2022.1.23 (202201230)**

- Fixed bg-dexopt-job wrapper causing long accd stop delay;

- Fixed typos in README;

- Fixed voltage "millivolts --exit" error;

- General optimizations;

- Improved charging status logic;

- Updated unexpected reboot troubleshooting guide.

As always, if not satisfied, acc -b instantly undoes the upgrade.
[Magisk] WibblyW:
So have I understood correctly that ACC doesn't currently support the behaviour I'm after automatically by a certain switch combination:

- Phone booted and ACC sees it's already over the pause threshold

- Battery discharges to pause level

- idle mode (assuming it's supported by the phone) kicks in so it maintains the pause threshold
[Magisk] VR25:
So far, you're the only person asking for this. I never thought of implementing it.

Since acc supports plugins, I wrote one for you to achieve the desired behavior.

Simply place the attached .sh file in /data/adb/acc-data/plugins/ and restart the daemon to load the new plugin.

P.S., I recommend upgrading to the new acc version from above.

Edit: the plugin was updated.

Edit 2: the switch in config must support idle mode.
[Magisk] WibblyW:
Thank you!
[Magisk] stankyou:
Hello. Anyone here with a Pixel 6 that have this working? Do I need a custom kernel?

I only have Capacity Control and Temp Control enabled but it doesn't seem to stop charging.

I'm stock, Magisk/rooted with busybox module.
[Magisk] VR25:
Flash the latest version from Magisk.
[Magisk] stankyou:
Thank you! I will test this out and report back.

Edit: Seems like updating Magisk did the trick. There have been several Magisk updates for the canary build.
[Magisk] bush911:
Just for your information: I am also using Pixel 6, with latest magisk and Kirisakura plus defeault settings Kernel battery idle mode works pretty well for me.

Plugged overnigth, It turned out that the battery lever is still at 80% and cosumes 0mA or -10 mA.

I also changed voltage to 4150mv, it also works.
[Magisk] WibblyW:
/data/adb/acc-data/plugins/ does not exist on my device. Should I create that folder and put it in there or put it in the existing /data/adb/vr25/acc-data/plugins/ folder?
[Magisk] VR25:
Oh, my bad, I gave you the wrong path!

The exiting path is the right one.
[Magisk] mr.inter:
Tried using the search function, but could not manage to find anything similar, so apologies if this has been answered before.

Is there a way by which phone keeps charging for a few seconds / minutes after hitting a certain set percentage, sort of a delay.
[Magisk] Brettroth:
After updating to 1-8 version the test shows none of my switches working for idle mode. On 12-20 version I have several working. On a op6t with mcd kernel.
[Magisk] WibblyW:
Why would you want to do this?
[Magisk] mr.inter:
Just out of curiosity, not an essential requirement. But mainly due to disconnecting phone from charger and immediately losing 1% since it would have immediately stopped charging upon reaching 70% for example.
[Magisk] Lorewaifu:
is there a way to disable fast charging with this? or am I doomed to getting another charging brick? (S9 SM-G960F that may be useful)
[Magisk] WibblyW:
Yeah - it drops from 70 to 69.9 I guess. So really just a product of the battery gauge only showing whole percentages? And perhaps that the battery voltage drops just because it's not being charged any more.
[Magisk] mr.inter:
Yes seems like it, but for example I have Accubattery, and each time I disconnect phone it considers it as a whole 1% loss, so screen on time average is low.
[Magisk] locuturus:
New build, new debug file!
[Magisk] wilberfan:
Yeah, I'm definitely confused: I just tried the new "# cs -a" It replied with "(i) cs service ON -reboot to apply change."

Apply what change? That it was off and now it's on? If I reboot, the terminal will no longer be running, and therefore the charging will therefore not stop at 80%, correct?

And I can't reconcile these two things at the moment:

So, back to my question at the top of this post: Open a terminal, enter "cs -a", reboot and the service is running (probably with defaults, though)? If I want to change the default settings I would then re-open a terminal and enter the new values---but then I have to leave the terminal running in the background? If the terminal should happen to get closed, since it's already running, does it...revert back to the default values?

[edit] I guess the "cs" in "cs -a" is what starts the service. the -a is just a toggle. OK. That makes sense. The 'reboot' to apply change' still doesn't make sense...
[Magisk] wilberfan:
I have MacroDroid set up on my phone with a dozen or so macros. What would a macro for Charging Switch look like? Would the Trigger be "Device Boot"? What would the action have to be? A shell script, or...?
[Magisk] dyingbread:
My trigger is battery level and action is a shell script with simple command cs -e snd cs -d. You can also use device boot as a trigger and shell script as an action with command, like cs 20 80 or something.

You can set whatever triggers you want, the action will always be shell script.
[Magisk] wilberfan:
Doesn't seem to be working for me. My Macro is Trigger: Device Boot, Action: Shell Script ( /data/chargingservice ), where chargingservice is

#!/system/bin/sh
# Charging Switch Script
cs 80 45

---------- Post added at 04:12 PM ---------- Previous post was at 03:50 PM ----------

And I have no idea what's happening here:

#cs -m 80 45
(i) Generating /sdcard/Macrodroid/charging_switch.catagory...
cp: Can't stat '/magisk/cs/.config/macrodroid': No such file or directory
sed: charging_switch.catagory: No such file or directory
sed: charging_switch.catagory: No such file or directory

When it works, is it supposed to generate....I don't even know...something that will open in MacroDroid? Is it a preconfigured macro, or...?

[edit] I have a /magisk/cs/config/macrodroid directory (no dot in font of the .config). Is there a typo somewhere?

[2nd edit] I re-flashed the 2017.11.06 version, and the macrodroid command (# cs -m 80 45) worked successfully... (Still not sure what that means, though.) Does that mean that Macrodroid will start Charging Service without me having to manually set up a macro, or does it just generate something that I can use to create one?

[3rd edit] (Sorry. It's either this, or help in the kitchen) I found this in the source code of the latest CS release:

# Generate MacroDroid & Tasker automation configs
elif [ "$1" = "-m" ] || [ "$1" = "-t" ]; then
if echo "$1" | grep -q 'm'; then
echo "(i) Generating /sdcard/MacroDroid/charging_switch.category..."
mdir=/sdcard/MacroDroid
[ -d $mdir ] || mkdir -p $mdir
cp /magisk/cs/[B][COLOR="Red"].config[/COLOR][/B]/macrodroid $mdir/charging_switch.category
cd $mdir
sed -i "s/:90/:$2/" charging_switch.category
sed -i "s/:11/:$3/" charging_switch.category
[Magisk] dyingbread:
Actually forget about macrodroid. You don't need that. Automation service is enough. Just type cs 80 45 in terminal and it will be saved. You don't need to set it again, even if you reboot your phone.

Use macrodroid if you want to set some weird charging cycle. Better use quicktile as a trigger than manually type in terminal. You just need one click.
[Magisk] wilberfan:
Doesn't work (unless I'm doing something wrong).

I opened a terminal, ran #cs 80 45, rebooted (even left the terminal open). Plugged in the charger, went and took a shower (it's almost dinner time!). When I came back it was at 84% and climbing.
[Magisk] psychoela:
have you try cs -a
[Magisk] VR25:
[MENTION=3442866]wilberfan[/MENTION], cs service only works if you're on build 2017.11.19-2+.

- Its enabled by default -- which means you don't need MacroDroid, Tasker or similar app.

- Default settings are 90 10 (pause, resume)

-- Change that by running "cs pause_value resume_value" (i.e., cs 80 20).

- User settings are never overwritten on reboot nor across module updates. So -- you install, reboot, configure (i.e., cs 80 20 -- optional) and forget.

How do you know cs service is running? Simplest ways:

- Run "cs" and it'll tell you whether or not service is up.

- If /data/media/cs/batt_level changes every 25-60 seconds, then the thing is running.

How do you toggle service ON/OFF/Unpause

- Run "cs -a"

- The message "reboot to apply change" is only displayed upon enabling the service.

-- But why do I need to reboot, VR25? Because the service is started (on boot) and kept running by Magisk daemon itself.

--- You have to do this only once.

I like your profile picture, BTW!
[Magisk] wilberfan:
I was following dyingbread's instructions:

I took that to mean that upon reboot I would NOT have to open a terminal again and enter any cs commands. Maybe I misunderstood something, but it kept charging past 80%.

So far, the only two things that have worked for me reliably:

1. Running # cs 80 45 in a terminal, and then leaving the terminal running in the background. This method requires (or has so far) manually re-opening a terminal following each subsequent reboot and re-entering the cs command again. In no case have I been able to completely exit a terminal window and have cs running automatically after a reboot.

2. Using # cs -m 80 45 to create a MacroDroid macro.

This 2nd process was rather nifty: The # cs -m 80 45 command (I had to manually edit the /magisk/cs/system/xbin/cs file to fix the typo I discovered (see earlier post)). It generated a file called /sdcard/MacroDroid/charging_switch.category. I didn't know WHAT to do with that, but when I tried to open it with a text reader, MacroDroid automatically opened and generated a two item macro. Rebooting resulted in a working cs without having to do anything else.

---------- Post added at 10:13 PM ---------- Previous post was at 09:41 PM ----------

- I am on build 2017.11.19-2

- I just tried it again: Turned off the MacroDroid macro. Rebooted. Ran # cs 80 75 (because the phone was at 75% battery). Rebooted. Plugged in phone. Just passed the 80% level and is still climbing. (Is currently at 82%). So it would seem that cs IS running--but it's not stopping where it's supposed to.

Just did a # cs to confirm: "(i) cs service is already running"

No extra charge!

[edit] Here's another thing: If cs is running with a setting of 80 45, why is it charging at all when I plug the phone in when the battery is, say, 68%? It shouldn't charge at all until it get's down to 45%, correct?
[Magisk] oxman:
Hello,

Thank you for your module, but it don't work on Essential Phone.

I joined the cs_debug
[Magisk] guest4711:
No, it's charging til 80. Then it will discharge til 45, then charging til 80 again.

The 1st parameter tells the upperlevel it will charge when connected, the second one the lower level the battery is allowd to reach when connected...
[Magisk] VR25:
Run "cs -c", copy the following config, paste it directly on terminal & press ENTER twice:

/sys/devices/soc/800f000.qcom,spmi/spmi-0/spmi0-02/800f000.qcom,spmi:qcom,pmi8998@2:qcom,qpnp-smb2/power_supply/battery/input_suspend" 0 1

Run cs as you normally would afterwards and report whether it works.
[Magisk] iluvatrix:
After re-reading from beginning to end I'm still unsure how to handle the Terminal window? Do we leave it running so that the notification is showing or can we totally exit the Terminal?
[Magisk] KingChilly:
Is it possible to use this command on a pixel 2xl? It also does not work on this phone.
[Magisk] VR25:
# 2017.11.24 (201711240)

- Added `cs -e/-d [value]%` commands -- check the README or run `cs -h` for details.

- Advanced command chaining support (i.e., cs -e 50% && cs -d 5h && cs -e 80% && cs -d 30m && cs -e 90%)

- Fixed MacroDroid/Tasker config generation error (/magisk/cs/.config: no such file or directory)

- Proper cs service add-on info to prevent confusion

- Essential Phone & Pixel 2/2XL compatible

- Updated reference
[Magisk] psychoela:
can you see this pause service not working.thanks for new update:D
[Magisk] zpower:
Theres some software for windows like this?

Start and stop charge at some %
[Magisk] samteeee:
Greetings,

I've been trying to use the module on my Pixel 2 XL to no avail: "Unsupported Device"!

Any help is much appreciated.

https://drive.google.com/file/d/13ICwx9zmHy5u7MMqohrZAeOtbdh6Pho4/view?usp=sharing
[Magisk] VR25:
The culprit might actually be the control file, not cs itself. Could you upload cs_debug.zip? ;)

I wonder the same -- badly needing it.

Did you try build 2017.11.24 already? If so, then I missed something -- will double check.
[Magisk] WibblyW:
Yes, but then what you'd want is not to maintain charging for a little longer to get to, say, 70.5% or some other random number based on the extra time charging (which will still likely distort Accubattery's reporting quite a bit) but instead to just below 71% ;-) .

OT, but I think to be honest this is a problem for Accubattery to contend with as it only seems to have visibility to whole % changes... Also. if you look at Accubattery stats over a whole discharge cycle of, say, 75% -> 25% = 50% drop, that "1% error" at the beginning isn't all that impactful to its stats... Really, it could avoid reporting the stats if the drop was < 10% anyway, in the same way it doesn't report estimated battery capacity unless the battery has actually charged > 5% ;-)
[Magisk] mr.inter:
Yes that's what I meant, if a customisable ACCA option would be possible, I would determine the time it takes to charge from 70 to just below 71% and set that as a delay, but I don't think it's possible.
[Magisk] WibblyW:
There's a current limit feature, but I don't know if that would work with your phone or a fast charger. Try it?

GitHub - VR-25/acc: Advanced Charging Controller

Advanced Charging Controller. Contribute to VR-25/acc development by creating an account on GitHub.

github.com
[Magisk] VR25:
# acc --set run_cmd_on_pause="'enable_charging; sleep 300'"

300 is the number of seconds to wait before disabling charging again.

If this fails, try

# echo "runCmdOnPause=('enable_charging; sleep 300')" >> $(acc -c echo)
[Magisk] VR25:
Try the latest snapshot.
[Magisk] mr.inter:
Can I integrate this in a profile from the app?
[Magisk] VR25:
No, AccA does not support this.
[Magisk] WibblyW:
Hmm. Charge seems to be stuck at 100% now and isn't discharging. I've tried rebooting the phone and restarting the daemon
[Magisk] Brettroth:
Same result. I guess I can just use the older version it seemed to work fine.
[Magisk] VR25:
I'll check the plugin.
[Magisk] VR25:
Ok, let me know whether the older version still works.
[Magisk] Brettroth:
Yeah it works fine
[Magisk] Lorewaifu:
I was playing with it yesterday and thought it didn't work because I'm using the acc app now (Wich is great btw) and it says "Charging (fast)" but some minutes ago I noticed that in the lockscreen says "Charging slowly" and sometimes just "Charging"

what should I believe?

I'm using the recommended minimum current https://github.com/VR-25/acc/#alway...tery-is-old-andor-tends-to-discharge-too-fast + 3920mv

by just looking at how much time it takes to go 1% up it seems to be working :D

also: is it a good idea to lower even more the current when charging while I'm sleeping? (8hrs~)
[Magisk] VR25:
I wonder whether that's just an illusion.

Previous versions were prone to false positives in idle mode detection.

Does the battery level actually remain constant for a long time after disabling charging on v2021.12.20?
[Magisk] VR25:
Ignore the "fast" charging mode seen in AccA. It's reported by the kernel, but found to be very unreliable. To avoid confusion, the more recent ACC versions no longer provide this information.

As for the current, 500mA is recommended for sleep time. You may go even lower (e.g., 250 mA), but it's up to you to test (some devices don't support values below 500mA).
[Magisk] Brettroth:
It does. Battery manager shows discharging with 0 current. It might go down 1% sometimes but that's it.
[Magisk] VR25:
Ok, let's troubleshoot this.

1. Install the latest snapshot from here

2. Set a switch (with acc -ss) that supports idle mode, according to the output of acc -t from v2021.12.20

3. Run acc -d to disable charging

4. See if battery manager shows discharging with 0mA current

5. Compare the above observation to the output of acc -i and share your findings

If the test fails, test another switch that supports idle mode.
[Magisk] Brettroth:
Ok so updated selected same switch I was using before and after acc -d battery manager shows 0 current. And also acc-i shows 0. Does that mean it's a false negative for idle support?
[Magisk] VR25:
acc -t is not detecting it.

That's weird...

Could you run acc -t; acca -le and share the log archive?
[Magisk] Brettroth:
Idle mode def works. Acc -t still shows every switch idle mode false
[Magisk] Brettroth:
Idk why but battery temp is down while in idle compared to old version also. Def like this version besides -t
[Magisk] VR25:
Snapshot

v2022.1.29 (202201290)

- acc -x -t <file> marks kernel panic triggering switches with double hashtag;

- Additional charging switches;

- Blacklisted problematic control files;

- Fixed bg-dexopt-job wrapper causing long accd stop delay;

- Fixed typos in README;

- Fixed voltage "millivolts --exit" error;

- Improved charging status logic;

- Misc fixes & optimizations;

- Moved changelog from README.md to changelog.md;

- Removed README.html;

- Support for Magisk's updateJson feature;

- Updated unexpected reboot troubleshooting guide.

Facing major issues with this one?

acc -b undoes the upgrade.
[Magisk] WibblyW:
Thanks. Will give it a try
[Magisk] Brettroth:
Switch test works now thank you
[Magisk] WibblyW:
Still not discharging when over the stop charging level, unfortunately.
[Magisk] VR25:
I'll review this before pushing a new acc release.
[Magisk] VR25:
**v2022.2.3 (202202030)**

- Additional charging switches;

- Auto detect and blacklist unwritable charging control files and those that trigger unexpected reboots;

- Blacklisted troublesome charging switches;

- Fixed bg-dexopt-job wrapper causing long accd stop delay;

- Fixed typos in README.md;

- Fixed voltage "millivolts --exit" error;

- Improved charging status logic;

- Magisk updateJson support;

- Misc fixes & optimizations;

- Moved changelog from README.md to changelog.md;

- Removed README.html;

- Support for a new charging switch format: `ctrl_file1 <on_value|file> <off_value|file> ctrl_file2 <on_value|file> <off_value|file> ...`, `file` is where to get the on/off value from, e.g., `battery/charge_control_limit 0 battery/charge_control_limit_max`;

- Updated unexpected reboot troubleshooting guide.
[Magisk] WibblyW:
Thanks. Will try both tomorrow...
[Magisk] swieder711:
Tried to update directly from the module in Magisk. I see the update button highlighted. Nothing happens when I hit update or download.

Will update manually for now.
[Magisk] VR25:
That was my mistake. I had to amend the release. Test the upgrade again after lowering versionCode with the following command:

sed -i s/3/2/ /data/adb/vr25/acc/module.prop

Alternatively, run acc -b to rollback to the previous version.
[Magisk] Spaceoid:
I would like to add a question to this.

I have LineageOS 18.1 on my OnePlus 6. LOS reports the charging status on the home screen.

When I plug the charger into my phone, oftentimes my phone firstly states "Charging slowly" for two seconds, then switching to "Charging" permanently. SOMETIMES though, the phone will swap between "Charging slowly", "Charging" and nothing at all for several times, ultimately ending up in "Charging slowly".

Is the information on the lock screen to be trusted? As of now, I did not feel any difference in charging time really, though I never measured yet. I just wonder why sometimes my phone gets stuck in the "Charging slowly" message/mode.

I am 95% sure it has to do with ACC, because that does not happen if I deactivate the module. Of course it could also be a faulty cable, but I never had those swaps without ACC iirc.

Also, thank you for the awesome work on this module. I was a HUGE "Battery Charge Limit" advocate in the past, and ACC is even better than that.
[Magisk] downhere:
Just charged my Oneplus 9 with LOS 18.1.

Now I'm surprised...

ACC v2022.2.3 and ACC Settings v2022.1.17.

Any ideas?
[Magisk] TioCareca:
nice, now we can download battery too 😂
[Magisk] Spaceoid:
Just to add up on this - if my phone locks into the "Charging slowly" state while getting plugged in, it really DOES charge more slowly. I compared the slopes of the battery graphs, one time being locked in "Charging" and one time being locked in "Charging slowly". I am not sure whether that is a kernel/ACC issue or a cable issue, though. I bought a new cable and am testing that in the next days; its just a little hard to test because the issue does not happen every time I charge my phone. We'll see.
[Magisk] swieder711:
Running 2.3.2022 with latest canary magisk and Feb patch on pixel 6 pro. Phone is charging to 100%, even tho limit is set to 95%.
[Magisk] Namelesswonder:
Edit /data/adb/vr25/acc-data/config.txt and set the chargingSwitch to gcpm/constant_charge_current_max 4000000 0 --

It is the only charging switch that works properly to idle the battery and restrict charge current with both USB and wireless, so make sure -- is there or else accd will cycle through switches and inadvertently choose any of the others which don't function properly.

You can verify things are functional by running logcat *:S google_charger:V google_battery:V

google_charger reports charging current as usbc and wlcc.

When pause capacity is met usbc will be 0 while wlcc hovers around 40. It's just some phantom measurement from the charging circuitry.​

google_battery reports the charging state as chg_s, charging current as ib, and charging current limit as icl.

There is no separate charging state for battery idle, so it will still report as not charging. ib should be moving around within 10mA of 0. icl is sometimes not what you set, I've noticed that wireless charging will always add an additional 200-300mA to the limit.​

Compare that to the stats from acc -i

If everything lines up and the status is idle then it should be working correctly now.
[Magisk] Lunisi:
Hello, I have the Xiaomi Mi 11 with Android 12 on ROM ArrowOS and I have the exact same problem.

I have put the maximux charge rate on 85%but it still charges.

Will this method work on my phone ? What could I do to stop the charge ?

Thanks !
[Magisk] Namelesswonder:
The switch and method I listed is specific to the Pixel 6.

Run acc -t while charging to get a list of potentially working charging switches. Test each one individually, it is also possible that you will need to use two switches to cover both USB and wireless charging. Make sure to restart acc after setting the charging switch.
[Magisk] swieder711:
Here is how I edited the config.txt

configVerCode=202201010

capacity=(5 101 70 95 false false)

temperature=(40 45 90 65)

cooldownRatio=( )

cooldownCurrent=

cooldownCustom=()

resetBattStats=(false false)

chargingSwitch=(gcpm/constant_charge_current_max 4000000 0 --)

applyOnBoot=()

applyOnPlug=(wireless/voltage_max::9000000)

maxChargingCurrent=()

maxChargingVoltage=()

language=en

runCmdOnPause=()

ampFactor=

voltFactor=

loopCmd=()

prioritizeBattIdleMode=false

currentWorkaround=false
[Magisk] Namelesswonder:
Yep that's it. You can remove the wireless/voltage_max from applyOnPlug.

I've found that it doesn't help, as the default max voltage is already 10V, and it doesn't work to override the voltage anyway. If I don't use a QC 3.0 brick with my 15W Belkin or Tozo charger then it will always negotiate to 5V regardless of what is set on plug.