yashsingh1/xdaforums huggingface dataset:
[Magisk] VR25:
# 2017.12.15 (201712150)

- Fixed "cs not found", "charging not stopping", bootlooping, "syntax error" issues & more

- Flash same version again to uninstall

- Better compatibility with legacy shells

- Massive optimizations

- More accurate charging control

- More robust get_ctrl_files function

- `touch /data/x` before flashing moves cs from bin (default) to xbin dir -- may be useful when cs trips SafetyNet or causes a bootloop

- Updated ctrl_files_db & reference

**Release Comments/Notes**

- All data generated by previous CS versions will be wiped.

- First run (initial setup) -- battery MUST be charging for cs to correctly identify & test control files.

- If a device has more than one known charging control file, cs will test them all to verify whether at least one of those truly works.

- Settings will be reverted to defaults (90 10).

- Install, reboot, configure, reboot and forget.

- First run (initial setup) -- battery MUST be charging for cs to correctly identify & test control files.

- First run (initial setup) -- battery MUST be charging for cs to correctly identify & test control files.

- First r... guess that's enough said.

------------------------------

# 2017.12.15-1 (201712151)

- Initial setup improvement -- install, connect charger, reboot, configure (or leave defaults: 90 10) and forget

- Updated reference
[Magisk] abuttino:
Fixed for Pixel 2 XL.

Thanks guys!

Sent from my Pixel 2 XL
[Magisk] aheadofsingularity:
Nexus 6P still incompatible.

I think 11.25-1-debug2 was best version for me.（Because it worked）
[Magisk] VR25:
:rolleyes: Did you really follow the new setup instructions accordingly?
[Magisk] aheadofsingularity:
Yes I did. I have charged my battery while the installation.
[Magisk] donny110:
First try.. Flashing magisk still failed, that's nothing new.. However.. Flashing through twrp gives error 2 and using the /touch /data/b command first gives error 1 on flashing..
[Magisk] Droid_JD:
Problems over here too.

Sorry!

Pixel XL
[Magisk] donny110:
This is what I get flashing through magisk by the way
[Magisk] VR25:
[MENTION=8787485]aheadofsingularity[/MENTION], [MENTION=2863435]Droid_JD[/MENTION], it'd be great if you could provide more info...

1. Connect charger

2. Enable verbose (cs -v)

3. Disable cs service (cs -s)

4. Run cs

5. Zip /data/media/cs contents & upload

This seems to be related to Magisk itself...

BTW, it's "touch /data/x" now, but you shouldn't need that with the latest version as I've changed the path (/system/xbin --> /system/bin) already. Something is off...

Have you searched through Magisk support threads for a similar issue yet?
[Magisk] guest4711:
Now I get

u0_a183@:/ $ su
root@:/ # cs

/system/bin/cs[716]: no closing quote
1|root@:/ #
[Magisk] x1reN:
Version 2017.12.15-2 causes bootloop on Galaxy S8 (SM-G950F). Had to uninstall the version again..
[Magisk] Palackan:
Still cs not found
[Magisk] Droid_JD:
Sorry, I was rushing out the door.

Installed via magisk. Plugged phone into charger, rebooted. Waited a few minutes, opened terminal emulator, then ran the following:

"

marlin:/ $ su

marlin:/ # cs 80 70

(i) Checking compatibility...

grep: /vendor/app/ViPER4AndroidFX: Is a directory

(!) Unsupported device

(i) Gathering debugging data...

mv: bad 'cs_debug.zip': No such file or directory

- Done.

(i) Please upload /sdcard/cs_debug-google-marlin.log to the official XDA thread.

marlin:/ #

"

The "(i) Checking compatibility...

grep: /vendor/app/ViPER4AndroidFX: Is a directory" probably stayed on the screen for about 5-10 minutes before it spit out everything else.
[Magisk] Palackan:
Can anyone help??
[Magisk] aheadofsingularity:
Mostly same cs output here on even Nexus 6P.

It is same that cs says "ViPER4AndroidFX Is a directory". Wow.
[Magisk] datsoy:
here's mine.
[Magisk] VR25:
Why's & Whatnot's

- So, moving cs from xbin to bin fixes some issues while causing others -- will revert to xbin, key back to bin (touch /data/b).

- Some devices display "funny errors" i.e., Viper4Android is a directory. Not sure where this came from :silly: -- will take a closer look.

- cs won't work on supposedly compatible devices -- more debugging data will be helpful.

- Misc syntax errors -- legacy shells (older systems/devices) -- will have to improve script portability even further.

In case you're wondering, I obviously use cs myself and the latest version works flawlessly on my Moto Z Play. That's not because it likes me more, though -- as that doesn't seem to be true at all. :D

Anyways...

For bootloops & "cs not found" issues...

0. Make sure you're root

1. Run "touch /data/x /data/r"

2. Reinstall the module

3. Test again (recall that battery must be charging during initial setup)

Others, please...

0. Make sure you're root

1. Try enabling cs verbose with cs -v

2. Run "set -x 2>/sdcard/cs_verbose.log"

3. Run "cs" & let errors enjoy themselves for a while...

4. Rename cs_verbose.log to cs_verbose_DeviceName.log

5. If you can get a debug zip with "cs debug", upload it. Else, zip everything in "/data/media/cs" --> cs_debug_DeviceName.zip, add cs_verbose_DeviceName.log & upload.

--------------------------

[MENTION=5297624]datsoy[/MENTION], got it, thanks.

Nexus 6P users, does "su -c cs -c /sys/devices/soc.0/qpnp-smbcharger-17/power_supply/battery/charging_enabled" fix the problem?

Pixel/Pixel XL --> "su -c cs -c /sys/devices/soc/qpnp-smbcharger-16/power_supply/battery/charging_enabled"
[Magisk] datsoy:
Its working now. thanks. :highfive:
[Magisk] VR25:
Nice!

Guess I know what's going on...

Now, could you run the following and post the output? This won't break cs again. :D

su -c . /path/to/find_cs_path.sh.txt
[Magisk] datsoy:
sure! here it is. ;)

/sbin/.core/mirror/system/etc/hosts

/sbin/.core/img/cs
[Magisk] VR25:
# 2017.12.16 (201712160)

- Default cs path reverted to /system/xbin -- in case bootloop or "cs not found" issues occur, change to bin by running `su -c touch /data/b` before installing

- Fixed ModPath searcher not filtering out '/vendor'

- Portability & compatibility improvements

- Updated control files database -- reverse engineering -- owners of yet-unsupported devices, I look forward to seeing reports!

# 2017.12.15-2 (201712152)

- Auto-remove /data keys (b & r)

- `touch /data/r` before flashing -- force reinstall

- Updated `cs -c` (debugging tool)
[Magisk] aheadofsingularity:
Now cs201712160 working perfectly on Nexus 6P! Thank you!
[Magisk] donny110:
And afterwards we are back to cs not found again ?.. Even though it's in the module list.. Btw, this is the only module I also have trouble installing through magisk manager..

Edit: Okay after deleting from magisk manager and reinstalling... We are somewhat further.. But not at the same time..

Running the cs command now gives

Whaomi: unknown UID 0

*cs must be run as root..*

Even though the su command is given beforehand.. And the root sign is in the terminal
[Magisk] VR25:
[MENTION=7389939]donny110[/MENTION], what happens when you run "su -c touch /data/b /data/r" before installing?
[Magisk] donny110:
Same thing happens when I try through magisk manager.. Going through twrp flashes but still gives the root error.
[Magisk] x1reN:
Phone not charging anymore after installing latest version + error while trying to change the settings.

Tried "su -c touch /data/b" before, didn't worked at all then (bootloop). Tried "touch /data/x /data/r" then and now this error (screenshot)
[Magisk] guest4711:
Still getting "no closing quote" with latest version.

u0_a183@:/ $ su
root@:/ # cs

/system/xbin/cs[723]: no closing quote
1|root@:/ # ls -l /system/xbin/cs
-rwxrwxr-x 1 root root 18029 Dec 16 11:27 /system/xbin/cs
root@:/ #
[Magisk] psychoela:
Latest version still not working, charging not stop with set limit
[Magisk] guest4711:
Changed the shebang to "#!/system/xbin/bash" (from "#!/system/bin/sh"). Now I can provide a cs_debug.zip.
[Magisk] NetSoerfer:
I charge my OnePlus 5T at night, and I don't want it to go beyond 85% because I get through the day on 70% capacity.

Ideally I want it to be at 85% when I get up, but since it discharges during the night I usually start the day closer to 75%. I haven't really come up with a great idea how to achieve this, but your ideas got me thinking:

Set the limits around the battery's sweet spot during the night (cs 55 45 between 10pm and 5am) and then charge to 85% after 5am. That way I'll start the day closer to 85%.

Thoughts on the very low lower threshold (cs 90 10)

This is something that throws me off quite a bit. I don't understand why you set such a low lower threshold by default?

I go all day on battery and charge at night, with the occasional opportunity to give it a quick charge, for example while driving and using the phone for navigation. Is this the use case you have in mind with the default settings?

If I set cs 90 10, the phone won't charge again until it's below 10%. If I get through the whole day and night using 75% battery, I'll start the next day with 15% battery because it hasn't charged overnight. I may be missing something, but it seems to me that this wide spread doesn't account for the regular long times away from a charger at all.

Setting cs 90 80 then seems to me like a more sensible choice for people who don't keep their phone plugged in at all times. Charge to 90% overnight, then pause charging to prevent stress to the battery by trickle charging all night, and when I plug in my charger in the evening I know it'll charge because it's definitely below 80%.

This also allows me to opportunistically charge during the day. If I've used more battery than I normally would, I can top up my battery any time to last me through the events of the evening by simply plugging it in. If I use the phone for navigation, it'll use far more battery than 'regular' use so I might run out of battery later that day when I might not have access to a charger, so I want it to charge while driving.

Of course I can set these values as I see fit, and I don't mean to complain - I'm just asking because I'm curious what scenario would benefit from such a low lower threshold.
[Magisk] chandr1000:
The correct charging control file for SM-G900H (k3gxx) is

"/sys/devices/battery.29/power_supply/battery/batt_slate_mode" 0 1

Previously cs detect the wrong charging control xD

it detect

/sys/devices/battery.29/power_supply/battery/store_mode

Besides that, cs working perfectly
[Magisk] Sreekantt:
weird- cs not found on Honor 6x

i followed the work around which u mentioned [MENTION=5228676]VR25[/MENTION] for cs not found but didn't help

still perfect build working for me is 19th november
[Magisk] aheadofsingularity:
for better compatibility, consider implement more easy debug command

dear, [MENTION=5228676]VR25[/MENTION]

First of all, I am not a developer so I can't say exactly it is possible or not, but you should consider somewhat implement easy debug command for cs, for instance,

if you run only single command on cs, it creates zip contains all the information needed for debug, so we can run it more easily, you don't need extra information.

If it is not possible implementation, just ignore me.
[Magisk] VR25:
[MENTION=2056205]NetSoerfer[/MENTION], you've got a point. I didn't consider the occasional charging that much when setting such a low threshold. The low value's purpose is actually to extend battery lifespan by preventing its level from dropping too low -- while being convenient for power users who don't want to charge too often to remain in the limits. For such case, 40 60 for example, would be a nightmare. Some people would even consider 20 80 a bit too strict for their usage patterns.

Back to your point, the manual controls (cs -e & cs -d) were designed to toggle charging on demand. However, since you hit "convenience" pretty hard, your suggestion makes more sense in real world usage. Higher limit is obviously the most important and the actual target here. So, something like 90 80 or 80 70 would generally be more optimal as default settings. Thanks for bringing this up.

"cs debug" is that command. It gathers all data I need at this point.

To Everyone

It seems most issues you face with recent versions of the module are actually due to legacy shells (i.e., Bourne Shell) incompatibility with certain syntax elements we use in CS. Thank you, [MENTION=8010004]guest4711[/MENTION] for testing that.

So, I'm thinking about pushing a test version which includes BASH (Bourne Again SHell) and uses it by default. That way, we'll know exactly which issues are related to syntax/algorithmic errors and which are directly linked to shell incompatibility. As stated in previous comments, the latest version works flawlessly for me. That alone should tell you something.

BTW, in case you didn't know, [MENTION=8570610]MCMotherEffin'[/MENTION] has been directly contributing to the project for a while. So, any questions/suggestions/bills you have, can be directed to him too. ;)
[Magisk] x1reN:
Heyho, were you able to look over my screenshot?
[Magisk] Jaymin.0.1910:
Try running from terminal

su

rm -f /data/media/cs/config

cs 86 85

and see if it works.

And to everyone,

for very close thresholds like '86 85', "cs -k 85" would be a better option. And to make it permanent, just replace "cs service" with "cs -k [THRESHOLD%]" in /sbin/.core/img/cs/service.sh or /magisk/cs/service.sh (for magisk < 14.5)
[Magisk] x1reN:
It's working! Thank you, which settings would you recommend for the S8?
[Magisk] Jaymin.0.1910:
It depends on how often and in which scenarios you use your phone

But, for everyone

here is a quick guide on lithium batteries,

1) draining battery close to 0-10% damages its life

2) charging it to 90-100% too often also damages its life

3) discharging to 0% and charging to 100% afterwards without booting once a month is recommended to recalibrate it

4) battery level between 40-60% is recommended for best battery life and performance ( you see, most phones unpacked have battery around 40% )

5) but, if you are a power user, you might want to expand it according to your usage

for me, I personally use 85 75 on times when I am coding because I mostly code while charging ON and when I am not coding I go with 60 40:)

but, please do your own research on lithium batteries
[Magisk] x1reN:
Here the logs.
[Magisk] ChronoReverse:
I got unsupported device on my US Unlocked HTC 10 running stock rooted with Magisk. I've attached the log.
[Magisk] VR25:
Paste the following code directly on terminal, run it & test cs again (applies to all HTC 10 users):

su -c cs -c /sys/devices/soc/qpnp-smbcharger-16/power_supply/battery/charging_enabled
[Magisk] ChronoReverse:
$ su -c cs -c /sys/devices/soc/qpnp-smbcharger-16/power_supply/battery/charging_enabled

(i) Checking compatibility...

(!) Unsupported control file

I forgot to mention i'm using the build that's in the Magisk repository. Looks like 12-16-2017. I'm on Magisk 14.5 (from the beta channel). Interesting, even commands like "cs -h" and "cs -i" do the Unsupport Device thing. Should I not be using the Terminal Emulator app?
[Magisk] VR25:
Run "cs -v && cs -e && cs debug" and follow the instructions.
[Magisk] ChronoReverse:
[EDIT]Very strange. I rebooted and it's acting differently now. I'll replace everything with the new results.

I also retried:

cs 90 60

And it seems to be attempting to use /sys/devices/soc/qpnp-smbcharger-16/power_supply/battery/charging_enabled but charging doesn't stop even though I'm at 95% now. USB charging with my laptop.

htc_pmewl:/ $ su
htc_pmewl:/ # cs -v && cs -e && cs debug

(i) verbose ON

(!) WARNING: don't forget to disable this after finishing debugging.
- Else, in the long run, your device's internal storage will be filled up and system will eventually crash or freeze!

(!) WARNING: verbose is enabled.
- Don't forget to disable it after finishing debugging.
- Else, in the long run, your device's internal storage will be filled up and system will eventually crash or freeze!

(i) CS service paused.

(i) Charging enabled.
- Start time: 2017-12-18 19:27:28

(i) Reboot the system or simply run "cs -s" to resume CS service.

(!) WARNING: verbose is enabled.
- Don't forget to disable it after finishing debugging.
- Else, in the long run, your device's internal storage will be filled up and system will eventually crash or freeze!

(i) Gathering debugging data...
- Done.

(i) Please upload /sdcard/cs_debug-htc-htc_pmewl.zip to the official XDA thread.

I turned off verbose afterward.
[Magisk] VR25:
Ok, definitely there are some issues with the control file ID mechanism.

Strip off the ".txt" extension from the attached file, copy "manual_ctrl" to /data/media/cs (replace existing), remove "config" from that folder & test cs again.
[Magisk] ChronoReverse:
Copied in, removed config, rebooted.

htc_pmewl:/ $ su
htc_pmewl:/ # cs 90 60

(i) New settings saved.

(i) Desired charge % reached.
- End time: 2017-12-18 19:59:14
- Charging paused; battery stats cleared.

(i) Waiting until 60% to restart the cycle...
- Press CTRL (Vol. Down) + C to abort.

Charging light is still turned on and the phone says charging on the lockscreen. Charging via USB on my laptop.

I wonder if it's really charging though, let me try to use some battery and then see if it recharges. Battery level went up, looks like it's still charging.
[Magisk] donny110:
Using the touxh data/b data/r makes it installable and actually gives cs.. However it gives a root error.. The other commands given either have no effect or make it unable go install.. This is how far I get so far..
[Magisk] Jaymin.0.1910:
Fixed with the next update:svetius:
[Magisk] NetSoerfer:
Charges beyond the upper limit on Nexus 9 with stock Android 6.
[Magisk] VR25:
Thanks for the log...

But next time, please use Google Drive or any other cloud service to host the data instead of posting it here as is.

This needs more digging (research). The same applies to Silv-R's device and others. Stay up for future builds.

-----------------------

# 2017.12.20 (201712200)

- Core optimizations

- `cs -b` -- clear battery stats on demand

- `cs -r` -- reset cs to its initial state

- `cs -x` -- toggle store_mode/batt_slate_mode (Samsung); charging_enabled/battery_charging_enabled (others)

- Default settings are now 90 80 for best convenience

- Fixed control files ID mechanism setting more than one switch in certain cases

- Fixed `cs -h` (help) not working on unsupported devices

- Updated reference

**Release Notes**

- Bootloop? "cs not found"? -- Run `touch /data/b /data/r` prior to installing.

- Due to major incompatibilities between [MENTION=8570610]MCMotherEffin'[/MENTION]'s work ethics & style and those of mine, he's no longer a collaborator.

- Current settings will be wiped.

- If charging control is inconsistent, try `cs -x`.

- You may want to run `cs -h` or check the README for new/extra usage tips.
[Magisk] Jaymin.0.1910:
Indeed me, and [MENTION=5228676]VR25[/MENTION] are not developing together, I have reworked the module from top to bottom and I will release it in the near future, until then, y'all can track the progress at https://github.com/sjayminsgithub/MC-s-Charging-Controller
[Magisk] donny110:
Okay.. Cs is now working with this build! Used the touch data before installation.. However it is on cs 90 80 which is the new standard.. However.. It charges to 90.. Then technically stops charging, but the charging led does keep lighting up and the phone still gives the charging instruction.. Also no desired charge reached as usualy should happen.. Not sure if this debug is even complete, but I tried..
[Magisk] abuttino:
[MENTION=5228676]VR25[/MENTION]

No longer works on Pixel 2 XL.

cs not found

Did the touch /data/r and /data/b but that didn't help either.

Sent from my Pixel 2 XL
[Magisk] Droid_JD:
Anytime else have this happening?

Phone reaches desired level, then starts draining...quickly: I plugged my phone in last night at about 10pm with 20%. At 2:30 am battery was at about 32%, and the phone was incredibly warm?

I'm going to enable verbose logging and upload the debug, but wanted to get the question out there too.

Pixel xl, stock 8.1, magical 14.5, elemental x 3.0 kernel, CD 12-20 (levels at 80 70)

https://www.dropbox.com/s/n586x4mtcuf4tl2/cs_debug-google-marlin.zip?dl=0
[Magisk] NetSoerfer:
A debug log for the Nexus 7 (2013) with LineageOS 14.1 - yes, it's old, but it's still alive and serving me well. If you ever have some time to spare for an old clunker... :)
[Magisk] NetSoerfer:
Joke's on me. Here's the log.
[Magisk] muziling:
Yes , I have this issue once.
[Magisk] novalis01:
Phone was lagging suddenly, checked and discovered that I had over 100 cs processes running.

Don't know why. Stopped that experiment now...
[Magisk] VR25:
Run cs -x & test again.

If that doesn't help -- with charger plugged in, run cs -r && cs -c /sys/devices/soc/qpnp-smbcharger-17/power_supply/dc/charging_enabled & test once again.

Have you tried earlier Magisk versions?

Does /sbin/.core/img/cs/system/xbin/cs or /magisk/cs/system/xbin/cs exist?

If so, can you run source /path/to/cs?

I've experienced this once. Not sure whether my device warmed up, though -- I was asleep. Upon waking up, I just it rebooted and that never happened ever since.

Interesting... ?
[Magisk] abuttino:
Neither xbin directory exists.

Path/to output "No such file or directory"

Sent from my Pixel 2 XL
[Magisk] VR25:
Try the attached zip.

Run touch /data/r before to force reinstall.

If "cs not found" comes up again... touch /data/b /data/r
[Magisk] donny110:
This is what happens with cs - x while charging led is on and battery is discharging..
[Magisk] abuttino:
cs path not found

Did r, then r and b, both no luck

source path/to/cs shows the same result as it did in my other post

Sent from my Pixel 2 XL
[Magisk] VR25:
Wait... that's exactly what's supposed to happen (except the LED part)! If battery is not charging past the upper limit, then cs is working.

"cs path not found"... are you using Magisk 14.6? If so, did you try previous versions (i.e., 14.5 or 14.0)?
[Magisk] abuttino:
Was using 14.5 with a special build for the Pixel 2 XL that didn't patch dtbo.

This is the same build I was using when 12.16 worked fine.

Where can I find 12.16?

Sent from my Pixel 2 XL
[Magisk] VR25:
Here, but try the test version first. Installation procedure is the same.

In case you want to update Magisk, the test version does work with v14.6.
[Magisk] abuttino:
The test version worked. Thanks for looking into this.

Sent from my Pixel 2 XL
[Magisk] x1reN:
"cs path not found" on Magisk 14.6
[Magisk] Jaymin.0.1910:
Hey everyone,

[MENTION=8570610]MCMotherEffin'[/MENTION] here, I have reworked the module from top to bottom, optimized code for best performance and reliability, and removed some unnecessary features, Find a pre-built flashable in my GitHub repository,

https://github.com/sjayminsgithub/MC-s-Charging-Controller:svetius:

It's awaiting acceptance in Magisk Repo
[Magisk] abuttino:
Try the one vr25 made for me a couple posts up, it worked fine after touch /data/r && touch /data/b

Sent from my Pixel 2 XL
[Magisk] xtam:
how to flash this cs-test?

i have 14.6 magisk on n95f ds note 8, cs path not found while using the one from repo.

But when i try to flash this cs-test.zip it says that this is not magisk module, should i flash it from twrp?
[Magisk] abuttino:
I just flashed it from Magisk. Not sure why you had that error

Sent from my Pixel 2 XL
[Magisk] xtam:
ok, maybe file transfer error, tested again and worked

---------- Post added at 09:03 AM ---------- Previous post was at 09:01 AM ----------

@VR25

on Note 8 - exynos N950F DS should I use -x (Samsung) or not?

batt_slate_mode ?

Should i run cs -x or not?
[Magisk] xtam:
Anyway this new version cs-test does not work, does not stop charging, tried with x and without x.

Here is debug file