yashsingh1/xdaforums huggingface dataset:
[Magisk] donny110:
After awhile, I had to update my phone.. the older version I had used to work... The new one however gives unsupported device error..
[Magisk] piptron:
Yes, and wont charge past 90%
[Magisk] donny110:
Nevermind this part.. I can get it too supported.. However ot simply charges past the given level.. Anything visible from the log?
[Magisk] Pipodi93:
I have strange issues on the latest stock Oreo build for OP5. I install the module from the repo, then I type into the terminal:

su

cs 80 20

But it doesn't work immediately (if I'm above the 80% the charge is still enabled), so I need to reboot. Then it works. But this morning I was on 17% and the charger was plugged in. I tried some command, but it won't let me charge my phone. So I uninstalled it and the phone was charging again. How can I get the log? Is still available even if I removed the module?
[Magisk] VR25:
The module controls battery charging and discharging limits in order to protect it from overcharging and deep discharging. This in turn extends battery lifespan.

How much that span is extended depends on how strict you are in limiting battery charge. ~40% is the "sweet spot". The longer you keep battery power in that range (or close), the better.

Regarding settings, if you set none, 90 80 are set automatically. These values tell cs to stop charging at 90% and resume it at 80%. Settings can be changed on the fly.

Could you check whether cs -d (disable charging) & cs -e (enable charging) work as expected?

Try switching the control file by running cs -x. Logs are stored in /data/media/cs.
[Magisk] Arav Singh:
[MENTION=5228676]VR25[/MENTION] have you fixed the unsupported device error for moto M

Cs_debug log https://drive.google.com/file/...LuKLBiYYPDrF/view?usp=drivesdk
[Magisk] Pipodi93:
I reinstalled the module from the repo, now I'm stucked at "Waiting for charger".

I tried:

su

touch /data/r

but it didn't work, always "Waiting for charger".

I've attached two logs.
[Magisk] KimberCT:
Getting this error with the 1.13 update. Same when attempted from recovery. I happened to factory image the phone today, but no luck. Pixel 2 XL.
[Magisk] sandaljrpit:
Not support with my phone. MI4 . :D
[Magisk] Telperion:
Same error here as [MENTION=4241120]KimberCT[/MENTION], Pixel 2 January update. I have it installed and it's working, just can't install the latest update.
[Magisk] abuttino:
[MENTION=5228676]VR25[/MENTION] Same here. Can't install the 1/13/18 update

Installation failed.

Sent from my Pixel 2 XL
[Magisk] JustinTrouble:
Same here.
[Magisk] ikelos:
Hi there,

I recently upgraded my OnePlus 5 to the 5.0.1 (Oreo 8.0) update. Magisk is working and I installed the magic charging switch from the module repo (2018.01.13 and it installed fine). I can use cs -d and cs -e to correctly disable or enable charging, however it appears not to notice when it charges over the threshold (default of 90/80). I'm not sure how the service monitors changes in battery charge level, but it seems that's the functionality that's at fault. I'm happy to gather more information if it will help with resolving this issue...

Mike
[Magisk] SethEtherald234:
Here my file, please help
[Magisk] __riptide__:
Since the 31st December update it causes long kernel wakelocks with the name of "alarmtimer". Sometimes the device doesn't go into deep sleep at all. I have tried disabling the service but no avail. The only thing that fixes it is disabled the whole module in magisk or removing it all together.
[Magisk] TGHH:
With installing the latest update and the patch I can execute cs but the limits do not apply - phone charges anyway.

Phone Moto G5 plus with ElementalX 2.02 kernel

Magisk 15.3/5.5.5

Best, Tom

BTW - this is one of the most valuable piece of software around! Many thanks for the time and effort! :good:
[Magisk] ikelos:
Tom,

That sounds just like what's happening to me (see above). Are you by any chance running Oreo on your phone?

Mike
[Magisk] TGHH:
Nope, I'm on StockROM (by TWRP flashed with latest OTA).

Tom
[Magisk] piptron:
How's it goin' mate?
[Magisk] bkkzak:
I get the same error

Pixel Xl BenzoRom 8.1 1/11/18 Magisk 15.3

---------- Post added at 08:53 AM ---------- Previous post was at 08:34 AM ----------

Is this the same fix addressed with the Magisk 1531 beta? I tried to upgrade to that and I couldn't get root to work
[Magisk] t3chwizard:
[MENTION=5228676]VR25[/MENTION] nice work dude, all the bugs seem to have been worked out. Works perfectly now
[Magisk] :
This is working with my mi mix 2 running oreo beta
[Magisk] JohnFawkes:
[MENTION=5228676]VR25[/MENTION] htc 10
[Magisk] JohnFawkes:
delete please. double post
[Magisk] aaargh777:
Installation still not working, last installable version for me is 2017.12.31.

All newer versions fail.

Log:

https://pastebin.com/uy6qZUH8

Edit: Pixel 2 XL Android 8.1
[Magisk] VR25:
Try the attached version.
[Magisk] SquirrelCmD:
Huawei P10 plus, Nougat, version from 25.01. :(
[Magisk] aaargh777:
Attached version installs fine, thanks
[Magisk] AlexBurnout77:
The phone keeps vibrating at the lower limit (the % where the phone can charge again), charging and discharging rapidly (like 3 times a second). That's horrible for my battery. I hope you didn't mess the module up again.

PS: OnePlus3, OxygenOS 5.0.1 Oreo
[Magisk] piptron:
Says unsupported. Please help
[Magisk] AlexBurnout77:
Yep. You pretty much did it. I had to revert back to 1.13 because I feared the battery would've literally exploded because of quick charging switching caused by untested code. I'm done with this module. Switching.

P.S.: Seems like CS isn't the problem since 1.13 worked great but after 1.25 everything was messed up. What could be the problem?
[Magisk] Droid_JD:
I've been having the danger installation issue, and this version finally worked for me.

Pixel xl, LOS, lavish 15.3

Thanks!!!
[Magisk] ikelos:
This issue is still present in version 2018.1.25.
[Magisk] Arav Singh:
Again get same error cs must run as root
[Magisk] eTaurus:
Instead of saving my battery this module is going to destroy it because it gives me very high battery drain. That's a shame because the idea is very good and I would love to be able to use it.

It may work for some devices but not for my HTC 10.
[Magisk] VR25:
**2017.1.27 (201801270)**
- General optimizations
- Minor cosmetic changes
- Stability improvements
- Updated cs service function

*Release Note*
- Unsupported devices whose owners already provided a debug zip won't be supported anytime soon. Most, if not all of those lack advanced charging control functionality -- custom kernel [or proper hardware] required.

Hopefully all the reported issues are gone.
[Magisk] Arav Singh:
Unsupported device error...

Here is the log https://drive.google.com/file/d/1In5vCHq-94ZKr0xPf09zK5htNcghnI7x/view?usp=drivesdk
[Magisk] psychoela:
[MENTION=5228676]VR25[/MENTION] thanks for update and hopefully my device can supported:D

Edit: Latest one not working fine,charging stop with high limit but not start charging at low limit(nexus 6).Thanks
[Magisk] VR25:
Test whether it works in manual mode (Nexus 6):

1. Run cs -s to pause cs service

2. Run cs [test values] i.e., cs 91 90

Once done, run cs -s to resume cs service
[Magisk] psychoela:
Follow done but still not work. Cs previous version 25/1 working fine
[Magisk] cheveguerra:
Hi,

So, the BEST setting (acording to The Battery University)

should

be "75 65" and second best "75 45" or did I misunderstood something?

Regards
[Magisk] VR25:
That depends on what you think of being "best" for you personally. There are two variables to consider:

1. How close to the sweet spot (~40%) you keep your battery

2. How convenient it is to keep it there

Convenience here means how often you should recharge the battery and to what extent you're OK with that.

"Sweet spot" is the power level which gives your battery the longest possible lifespan.

I picked 90 80 as defaults thinking on these variables. I did so for a general balance between the two. If most batteries were as hard core as the one in say, the Razer Phone or Moto Z Play, then lower values would be better suited for defaults.

I use cs on a Moto Z Play -- set to 80 70 for general usage and to about 50 40 for long [navigation] sessions.
[Magisk] cheveguerra:
Ok, so ... the "optimal" :fingers-crossed: charging cycle should be a shallow one (no more than 10% difference between max-min values) and the closer to 50% the better? .. this obviously according to my usage ... if I maintain it between 40%-50%, the battery lives longer (more cycles) but it means that when I am away from a charger I only have

half

the battery.

If I keep it between 80%-90%, it does not live as long, but when away from a charger I have an almost full battery.

And any of these configurations are a lot better than charging the battery to 100% anytime my battery is close to 0%.

Is this "

mostly

" right?? :confused:

Best regards
[Magisk] Droid_JD:
I keep getting "unsupported device" on this newest version.

Pixel xl, magisk 15.3. Lineage OS.

Log attached.
[Magisk] VR25:
That's pretty much it. Except the % difference between both ends is also totally up to you. Think about how often you want the charging switch to be toggled. For instance, you may set something in the lines of 90 10 -- but then, after the switch has been set to OFF, your battery won't be allowed to charge again until it has discharged all the way down to the lower limit (10%).

Try the attached one.
[Magisk] cheveguerra:
Ok, according to the University, a partial discharge reduces stress and prolongs battery life, so does a partial charge, cycling in mid-state-of-charge would have best longevity.

10% depth of discharge = most discharge cycles

100% depth of discharge = least discharge cycles

But then again,

as you said

, it all depends in what is best for your daily usage ... at the end of the day you will probably change the phone before the battery becomes unusable!

Best regards
[Magisk] Droid_JD:
[MENTION=5228676]VR25[/MENTION], still giving me the same error, but now it's checking the power source before telling me my devices is unsupported.

Thanks again for all of this work. It's very appreciated.
[Magisk] piptron:
[MENTION=5228676]VR25[/MENTION] please support my device, thank you
[Magisk] Cryptycat7:
This is like the iPhone versus Android debate. Regarding this question everybody has rather no or an opinion written in stone. 30/40 to 70/80 should extend the longevity of the battery.

But you have to take various parameters into account.

Voltage; especially the heat generated by it as a side effect has a more significant impact on the charge cycles that you can put the battery through, before the "felt capacity" starts to drop.

One charging cycle is defined as charging from 0-100. Charging two times from 20 to to 100 and from 80 to 100 would be equal to charging once from 0-100. Never do that. So called memory effect became reminiscent, when Lithium ion batteries became the standard.

If I have to leave soon, I unplug at 90 percent, if I am at home, I fully charge, which shouldn't be too bad, since every smartphone has overcharge protection.. If you are facing a high discharging rate, take a look at the battery overview page. If idle drain is the issue, find the culprit with better battery stats. Charge to 100, unplug, turn screen off and check the stats after at six hours or more.

Just corrected some critical typos, sorry for that.
[Magisk] t3chwizard:
Yea exactly just don't obsess about it and you will be better off that's my thinking lol
[Magisk] VR25:
I'll keep hunting down the cause of the issue. Both devices are already supported at this point as both contain known charging control files. The question is: why is charging not stopping?

Run cs -x and follow the instructions. Test each available control file listed with cs -e (enable charging) & cs -d (disable charging).

P.S., before jumping into the above, try the initial setup again, but with SELinux mode set to permissive (setenforce 0).

Edit

Nevermind cs -x. It won't work for that purpose under current versions. An update will pop-up soon.
[Magisk] Eruqal:
I was trying to configure this but nothing appears on the terminal
[Magisk] Cryptycat7:
Thinking about bricking my phone by flash a self compiled kernel with this feature added. Let me grab some sample code. Will edit in a moment.
[Magisk] eried1:
Just discovered this thread. What do you think would be the most reliable method of the following:

1. This module

2. Battery Charging Limit app.

3. Making Tasker profiles.

I've tried the app in the past, but it rarely worked so I gave up on the whole idea. Today I downloaded the latest version (v.1.1.0) and it seems to actually do the job so far.
[Magisk] psychoela:
Anyone still have cs 25/1? Please share,thanks:D
[Magisk] eTaurus:
Here you are!

https://mega.nz/#!tJ0WgDbQ!iVF785VxyU6L4FtRLkh7OzlWp7TxuQEKDtN9h7w9fKc
[Magisk] cyrildtm:
I have the same issue with 1/27 version. Ran your command in terminal, and it works there. However the program persists in the command window and does not exit after setting. I can see the charging/discharging messages. The problem is I'm using Tasker and it kills the program after timeout, or otherwise won't finish the task until somehow the `cs 91 90` is killed by other means.

Previous version worked. Using Nexus 6.

BTW this is awesome! It's exactly what I've been looking for.
[Magisk] Droid_JD:
[MENTION=5228676]VR25[/MENTION]

Still saying device unsupported

Log attached

I tried setting se policy to permissive, but it still did the same thing.

CS -x doesn't give me any instructions to follow.
[Magisk] Palackan:
it shows the device is supported but is not working. when i set values to 90 85 the charging does not stop at 90.
[Magisk] eTaurus:
You may either own a device that [MENTION=5228676]VR25[/MENTION] hasn't come around to fix or that he is not able to fix. But it doesn't matter because he did not release a new version since 27/1, so how could your device be fixed?

[MENTION=5228676]VR25[/MENTION] mentioned not long ago that he is trying to fix this problem and that he will release a new version when it has been fixed. I have the same problem on my HTC 10 and I have to be patient, I guess, and so are you.
[Magisk] aaargh777:
I can't help with your issue but after a quick look at your logfile it seems that your version of cs is outdated

csVersion=201712310

Latest version is

csVersion=201801270
[Magisk] irule311:
I get an unsupported device message with my pixel xl 1. I'm at a loss at this because I thought it was supported?

My log is attached.
[Magisk] S. Prime:
My Asus Z580CA shows unsupported device. I am attaching the debug log.
[Magisk] eried1:
I got the same problem as I have with all other methods (BCL app and Tasker shell codes); once the screen turns off all settings are disregarded and the original values (1) of the charging files, charging_enabled and battery_charging_enabled, are restored.

Edit: I might add that that my device, Lenovo P2, is supported according to the terminal.

I used to think that the issue was related to the root being systemless, but since it works for some of the others I no longer have a clue. I don't see how it could be battery optimization since I've whitelisted Magisk and allowed background processes.
[Magisk] t3chwizard:
So it was working for a while but it randomly will stop charging and I have to reinitialize it by doing "cs 90" or whatever and then it works.
[Magisk] yeye.phone:
Hello,

I try the module, but i can't do anything with cs command and no log.

See screenshots below.

Best regards
[Magisk] sokka91:
Thanks for this amazing mod!

One question, if the service is disabled if the phone is restarted the service will be automatically re-enabled?
[Magisk] Mao04:
Same as others here, works with 1/25 but not with 1/27. Shamu, nephilium 1.9, magisk 15.3. Is there something special I would need to do to capture useful debug info?
[Magisk] sharp3r:
Hi. This module is what i was looking for. I was using it on my S7 edge Ambasadii ROM v2 (odex s8 port) and it was working fine. But now I'm on Helios ROM v7.27 (odex stock based ROM) and the module is not working at all... i uninstall it and reinstall with no chance. All commands typed got stuck at the cursor without any output. Even the debug command doesn't create any file....

[MENTION=5228676]VR25[/MENTION] Is this module related to any android system apps? bcs I debloat any ROM i use.

ss attached

Thanks

Edit: i found out that running the command normally

su -c cs

doesn't work but running it like this works

su -c /system/xbin/cs
[Magisk] yeye.phone:
Hello,

with the correct path it's seems to work (thanks to sharp3r) :

$ su
a3xelte:/data/data/com.termux/files/home # /system/xbin/cs -i

Battery Info
STATUS=Charging
CHARGE_TYPE=Fast
HEALTH=Good
ONLINE=3
TECHNOLOGY=Li-ion
VOLTAGE=4283000
VOLTAGE_AVG=4282000
CURRENT=1500
CURRENT_AVG=1500
CHARGE=1
LEVEL=98%
TEMP=241
TEMP_AMBIENT=241
CHARGE_CONTROL_LIMIT=0

CS Settings

# Battery power
higher_limit=90
lower_limit=80

# Battery info file (uevent)
UEVENT=/sys/devices/battery.20/power_supply/battery/uevent

# Charging switch
SWITCH=/sys/devices/battery.20/power_supply/battery/batt_slate_mode
ON_key=0
OFF_key=1

# Service
auto_run=true
pause_svc=false

# Debugging
loop_verbose=false

a3xelte:/data/data/com.termux/files/home #

But when the % charge up to 90% and more, the phone doesn't stop charging.

See log below.

How can i solve that ?

Best regards
[Magisk] rnadomuc:
After I put my phone on the charger, the terminal spat out a ton of sys_cache not found errors. Then it said congratulations, my device is compatible.

Is that, er, normal?

edit: I was using the local terminal, the one enabled in Developer Options, not sure if that makes a difference
[Magisk] rnadomuc:
Reading up on things a bit more, it seems the battery being above 90% can also have an effect, since apparently stats aren't kept if above that?
[Magisk] rnadomuc:
Restored a backup and gave it another try, this time waited until my battery was lower, did it from adb on my computer, did cs -t 90 80 and then imported the project into Tasker. Hopefully that should do it.
[Magisk] rnadomuc:
Well, unfortunately despite not receiving any sorts of errors and making sure everything was configured appropriately, it does not seem to be working with my Qi charger. I'll attempt charging with a USB charger next...
[Magisk] VR25:
Been out for a while due to random internet access issues.

I didn't stop working during that time, though.

Can't thoroughly read all recent posts now, but I'll do it as soon as I get some free time -- and of course, push the new version.
[Magisk] Nick James:
My device will not deep sleep over night since using cs, but only when the phone has stopped charging but still plugged in. This causes a kernel wake lock called chg_wake_lock

This wake lock is most common with OnePlus devices (I've got a OnePlus5) from what I can Google. Additionally, I'm running a custom kernel (Boeffla) so still a lot of moving parts here but I'm convinced its cs.

The total running time for this wake lock happens to be the amount of time my phone is plugged into a charger but not accepting a charge per cs.

My speculation is, this kernel wake lock is running when it senses a charger plugged in. Despite it not charging, the device is still 'awake' and not in a deep sleep because it doesn't have to be since charging (but its not really due to cs).

The second I remove the charger, the wake lock stops stops.

Does that make sense? Am I on the right track?
[Magisk] rnadomuc:
After more testing, I was able to get it to work nicely with Tasker by turning off battery optimization for Tasker in the android settings.

There is a problem, however. While it will stop charging with USB power, it does not stop charging with a Qi wireless charger. I prefer wireless charging so the usb slot doesn't end up getting damaged over time. However, the heat it causes at 100% is very concerning, I recently had to have the phone's battery replaced and I think that might have had something to do with it.

Is there a way to get it working with a wireless charger or am I screwed on that front?
[Magisk] VR25:
That's interesting...

The way you put it into words makes sense.

The only exit doors I'm currently seeing are a wakelock blocker and a different charging switch. Run cs -x to toggle switches.

Yes, there might be a switch for wireless charging too. Which device are you using? Could you provide a debug log? Thanks
[Magisk] rnadomuc:
Using a Nexus 5. I can supply a debug log - can you describe precisely what actions you want me to take and what commands you want me to do?
[Magisk] Macusercom:
Since yesterday I got some issues: if CS is installed, it doesn't charge my phone anymore. It installs everything in /sdcard/cs but after multiple reboots and reinstallations it is not possible to charge my phone if CS is enabled.

If I use the cs command in the terminal it says waiting for charger. Any ideas?

EDIT: After reinstalling it again with redownloading the ZIP after deleting if, it is working again. I'm happy now and I can enjoy cs again now! :)
[Magisk] rnadomuc:
today it worked on the qi charger. I'm not sure what changed. I'm assuming that even though I have Tasker set to not be optimized on battery, for some reason it still failed to trigger.

It might have something to do with an app I recently installed that need to listen to the mic at all times, which can prevent the phone from entering 'deep sleep' (rather new to this stuff).
[Magisk] shrimetal:
Is there youtube video on how to use it? Too many options.
[Magisk] NetSoerfer:
No idea, but there's not much to do to get basic function set up:

Install, reboot

Plug in charger

Open any terminal emulator

Inside the terminal emulator, type:

su (to switch to root)

cs 90 80 (to set the upper and lower threshold)

Done.

The thresholds work as follows:

The phone will stop charging once it reaches the upper threshold (90% battery in the example above).

While the phone is between the upper (90%) and lower (80%) threshold, it won't start charging if you plug in the charger.

If you plug in the charger while the phone is below the lower threshold, or if it discharges below the lower threshold while plugged in, it will begin charging and stop when it reaches the upper threshold.
[Magisk] qtCme:
It doesn't stop when it reaches the percentage it was set in.
[Magisk] rnadomuc:
It seems like the tasker configuration is flawed. rather than the 80 <-> 90 behavior that's intendeded, it's instead 89 <-> 90.

I'm not sure how to fix it yet since I've never really used Tasker before...
[Magisk] lruihao:
After I set my threshold, I am seeing this screen.

Will the threshold that I set continue to run if I exit Terminal?
[Magisk] hriday f:
PLS HELP!!!

I have read everything but yet didn't understand. I m new in all these things so can SOME1 PLS TELL ME how to change the value from 90 to 100. I want it to stop when it is 100% not 90. PLS TELL ME STEP BY STEP
[Magisk] twist3d0n3:
So you want it at default? Uninstall the module :/
[Magisk] hriday f:
No, I want it to stop charging at 99% or 100. The default is 90%. Pls tell me how to change it to 99 or 100
[Magisk] Droid_JD:
Basically, to change the default values you would enter "CS (Max charger value) (resume charger value). For example, to stop at 100 and resume at 90 you would enter:

Su

Cs 100 90
[Magisk] hriday f:
Thanks a lot dude for a fast reply, but where do I have tp enter

su

Cs 100 90
[Magisk] guest4711:
Open a terminal window on your smartphone or tablet.

If you don't find a terminal app in your app drawer you must probably enable it in developers options. Or you may install an app, e.g. Terminal-Emulator for Android - https://f-droid.org/app/jackpal.androidterm
[Magisk] hriday f:
I have downloaded terminal emulator ant when I type

Su

Cs 100 98.

In the next line it tells cs not found. What to do. And also tell if reboot is required to enable the change
[Magisk] guest4711:
Make sure you enter everything using small letters

su
cs 100 98

If it still does not find it, there is something wrong with your installation. Delete this magisk module, reboot, and start over following the instructions.

After successful installation no reboot is required when changing parameters...