yashsingh1/xdaforums huggingface dataset:
[Magisk] ronyscomparim:
I made the 10-90% setup, I understand that I should only start loading below 10% and stop loading with 90%. this does not occur, but if I configure mcs -d 30m pause loading for 30 minutes! any solution for 10-90?
[Magisk] add_pl:
Not working OnePlus 6
[Magisk] Dilbertcrash:
Kernel with advanced charging control

What Kernel do you recommend for use with mcs?

I have a G5s plus Sanders
[Magisk] SchwarZWeiSs:
Is mcs 80 -d 8h || 25 valid for: Charge to 80% then disable charge for 8h or if battery level is at 25% or less?
[Magisk] Dexter_S:
Hello, I am trying to use mcs with time basis. I am using "mcs -e 30m && mcs -d 10m && mcs -e 30m". It is working upto send action i.e disabling the charging for 10min. But after 10m, the charging is not resuming. I have t manually mcs -e to resume charging.
[Magisk] emabertax:
Hi, i want create this rules: charging battery at 100%, when battery is at 100% keep charging active for 5-10 minutes and after stop completly charging. How i can create this rules on terminal? Please help me thanks :)
[Magisk] Dilbertcrash:
Correct is...

The correct comand for enable is = -e
[Magisk] Schroeder09:
I updated to magisk 17. 0 and this started causing problems. Snapchat will no longer open and I would occasionally get Play services errors. The same thing happened on 17. 1 magisk. I've been to Leary about trying this module again because I spent the last couple days getting Android 9 set up to where I wanted it. Is this still compatible with Android 9? Have my issues been seen before? I have some pictures of log cats that I could post.
[Magisk] Schroeder09:
Anyone? Does this still work in Android 9? I'm on a 2xl
[Magisk] guest4711:
As long as your kernel has the necessary interface/uses the known control files it will work.
[Magisk] Schroeder09:
Does it work with flash and EX kernel?
[Magisk] guest4711:
Test it yourself and report back. Otherwise we'll never know.
[Magisk] Fif_:
I'm seeing the exact same problem on a OnePlus 5 running 4.5.15.

Did you ever find a solution to this chg_wake_lock issue?

I've tried changing drivers, but only the default one (charging_enabled) works.
[Magisk] Nick James:
No, I haven't figured it out nor have I been able to even make it work with the default one any longer.

My work around was to change my charging schedule meaning, I don't charge my phone overnight. If I have 40-60% battery remaining before bed, I know I have enough battery to get through at least 8am (if not more) the following morning
[Magisk] Fif_:
Mcs works fine here with the default driver, using a 85-83% setting, it's just that the phone stays awake & screen off in between t topping up charges. That translates to a few minutes of charging followed by 3h or so of discharging when the charge has reached its steady state. If I could get rid of the chg_wake_lock, I'm sure I could lower the discharge rate and increase the interval in between topping up charges.
[Magisk] vijai2011:
Thanks for the module. It works great (except I wasnt able to install this from magisk manager where is complains cannot mount magisk_temp.img). I thought, it would be great to have a UI controller for controlling the module and I made a simple app and open sourced it. I wouldn't call it foolproof yet and I would request users to test it and open issues in the git if you find any.

Gitlab: https://gitlab.com/vijai/MCS-Controller

App download: MCS Controller V1.0.0

P.S: I cannot release into google play yet as I do not have a good icon for the app. I'm looking for someone to contribute to the app by making some graphics for the app. Interested people can PM me or open issue in gitlab.

NOTE: No support will be provided on this thread (to prevent thread hijacking) or in PM. You can either mail me from the app's about screen or open issue in gitlab.
[Magisk] Schroeder09:
I'm on flash kernel 3.06 right now. I had issues. I stated that. That's why I asked if anyone else was using it with these kernels. Is it a kerenl problem or a conflict with another app or module. That's what I'm after. The question was: is anyone using this module as of late (on Android 9) with the flash or ex kernel. It's a yes or no answer.

You went out of your way and wasted time to post a useless reply that didn't answer the question or help anyone.

Anyway, here's a PM I was sending to VR25 when I realized I couldn't attach files. Here's the log from magisk. Please help with how to correct the issue so I can try this module again. Any help or input is appreciated.

I'm on Android 9 september security patch with magisk 17.1. I have flash kernel 3.06. Previously I was on Android 8 with flash kernel and Magisk 16.7. When I updated to 17.0 I started having all kinds of problems with Snapchat and play services force closing and crashing. I determined this module was the problem. It worked for me for a long time though, and I like it.

Do you have other users with similar setups as mine functioning correctly? I tried installed your 2018.8.8 version today and I get an installation failure at time of install.
[Magisk] Adromir:
I don't know what i am doing wrong, its not working for me on any Magisk version after 16.4. After i upgrade i only get "mcs not found" when I run it in my Terminal with su before. With magisks 16.4 it works
[Magisk] VR25:
That's a f%#$ awesome news!

I'll test the controller and report back. If it passes my basic exams, I'll make you a contributor and approve related discussions on this thread.

BTW, after adk, which was updated just now, mcs will be the next to receive a huge update -- coming within a week or two.

Meanwhile, smaller updates will start popping sooner to address the top priority reported issues.

Thank you all for hanging around, suggesting and reporting so much stuff. Special thanks to those who press the button and move this thing up even further -- by helping others while I'm not available and/or creating extensions for the module.

EDIT: [MENTION=4311415]vijai2011[/MENTION], tested it. All's good. Discussions can take place here. Thanks, and nice job! :D
[Magisk] Benni:):
Hey I made an app, too.

it's mostly intended for moto z phones with a battery mod.

Feel free to use whatever code you like.

https://xdaforums.com/moto-z/themes/tool-efficency-mode-battery-mod-info-t3826694
[Magisk] 4Style:
Hmm doesn't seem to work for me on xiaomi mi8 using global stable Rom. I've set the values to 10 and 90 but still it continues to charge even over 90%. Maybe because of the stock kernel, idk, but if you need logs, feel free to ask me :)
[Magisk] 4Style:
Na nevermind I just recorded some debug information, maybe it helps. Would be nice to see this mod work on xiaomi phones.
[Magisk] ncar123:
So I just install it and defualt is stop charging when 90% but then if it drops?

And what if I disconnect and connect the charger
[Magisk] ktmom:
It cycles, charges until 90% (in your case) then stops charging until the low limit that is set, at which point it starts charging again.

When you plug your charger back in, if it's below the low limit, your device should start charging. If when you plug back in, the device is still above the low limit then it won't charge until it reached the low limit.

"find somebody that you think is undeserving of your compassion and give it to them" - Christian Picciolini
[Magisk] HosseinMoradi2007:
Thanks for the module It works great on my redmi note 5 :)

i have a suggestion

can you add a battery temperature limit to your module so when charging and the battery reached the temperature limit, then charging stops until it reached the lower limit temperature.
[Magisk] randyok@:
"Failed to mount" when I try to install from magisk (Android Pie)
[Magisk] aouerfelli:
More specifically, this is the log:

Archive: /data/user/0/com.topjohnwu.magisk/cache/install.zip
inflating: common/config/macrodroid
inflating: common/config/mcs
inflating: common/config/switches
inflating: common/config/tasker
inflating: common/service.sh
inflating: common/system/xbin/mcs
inflating: module.prop
- Copying zip to temp directory
- Installing Magic_Charging_Switch-2018.8.8.zip
update-binary: line 198: make_ext4fs: not found
losetup: /data/adb/magisk_merge.img: No such file or directory

losetup: /data/adb/magisk_merge.img: No such file or directory
losetup: /data/adb/magisk_merge.img: No such file or directory
losetup: /data/adb/magisk_merge.img: No such file or directory
losetup: /data/adb/magisk_merge.img: No such file or directory
losetup: /data/adb/magisk_merge.img: No such file or directory
losetup: /data/adb/magisk_merge.img: No such file or directory
losetup: /data/adb/magisk_merge.img: No such file or directory
Magic Charging Switch (mcs) 2018.8.8
VR25 @ xda-developers
Powered by Magisk (@topjohnwu)

- Creating /data/adb/magisk_merge.img with size 64M
- Mounting /data/adb/magisk_merge.img to /dev/tmp/magisk_img

(!) Failed to mount /data/adb/magisk_merge.img

! Installation failed

It might have to do with my stock kernel not having advanced charging support.
[Magisk] guest4711:
No, the problem is it can not creste the filesystem:

. Probably your TWRP does not support ext4fs fully... Please ask in your device forum.
[Magisk] aouerfelli:
I don't use TWRP, I flashed Magisk via the boot method. That might be why.
[Magisk] brqndon:
Any help would be very much appreciated.

Was running mcs just fine on Oreo. Upgraded to Pie on September release, updated to Magisk 17.1, and now getting a failed to mount when attempting to install via Magisk Manager.

Thanks so much in advance.
[Magisk] brqndon:
Nevermind! I suppose uninstalling and reinstalling Magisk fixed it.
[Magisk] VR25:
Are you using Magisk 17.1?

Does mcs -d stop charging?

Will see what can be done. Thanks:)

That's Android Pie's fault. It lacks some useful binaries, such as make_ext4fs and resize2fs. TWRP should have those; install from it.

The upcoming version will rely on the magisk binary to prevent future issues of this kind.
[Magisk] 4Style:
Yes I do. Mcs - d gets executed but does not stop charging.
[Magisk] VR25:
If mcs -x displays any other charging switch(s), try it/all. I'll take a look at your log.

BTW, this does work on a couple of Xiaomi phones. ;)
[Magisk] 4Style:
Yeah would be great to see this mod working.

Mcs - x gives me this result:
[Magisk] VR25:
Test all.

Pick a number and run mcs -d. If charging stops, then the chosen control file works.
[Magisk] 4Style:
Ah thank you very much. I picked nr 1 and now it works just fine :)
[Magisk] slayer1991:
HTC 10 issues

Hey VR25, first off thanks for all the hard work!

I'm having some issues getting it to work. Running latest leedroid with cleanslate kernel.

If I reboot without the charger connected, and I run mcs - i, then plug in the charger as it is Waiting for charger, it says incompatible device.

If I reboot with charger connected, it'll just get stuck waiting for it.
[Magisk] VR25:
Try the above procedure (mcs -x, then mcs -d) and let me know how things go. Thanks. :)
[Magisk] Bortex19:
Are the specifications that I have put loaded as default until I use "mcs -s" or reset the device? "mcs -e 50% && mcs -d 10m && mcs -e 60% && mcs -d 5m && mcs -e 70% && mcs -d 10m && mcs -e 80%"

It would be great to have control by temperature, so that when reaching certain degrees it will stop and continue once it has cooled down. For example, I want to charge my phone from 20% to 80% but keeping it always "cold"

Thank you!

PD: It works on my Xiaomi mi 8 (chinese version, global rom), MIUI 10, Magisk 17.1
[Magisk] Bortex19:
Hello! Could you explain this a little more? How do you create the profiles? How do you launch each one? What is "-c" for? What does this part "mcs -s (output to %MCS)" mean? mcs -s is okey, but what about %? Could you put examples with literal command lines? Like "su; mcs -e 50% && mcs -d 10m && mcs -e 60%"

Excuse me for so many questions but you write about a very interesting thing :D
[Magisk] VR25:
No, these don't reset your settings at all. The only command which does that is mcs -r. Whenever you run on-demand operations such as the combination above (mcs -e 70...), mcs daemon is paused to prevent interference. The -s toggles daemon state. It lets you start/stop/pause/resume automation.

You're welcome!

Control by temperature is coming with the next update (already being tested). I'm also working on auto-shutdown at set % feature and voltage & current control. The last two have the potential to make this thing work on all devices, thanks to the generic nature of respective control files.

I'll allow the OP to explain it further.

The basics...

- You don't create a profile. It's a Tasker project.

- su -c <commands> is like "sudo <commands>" on Linux desktop. A bare su won't work with Tasker the way you want it to. So, you have to use short circuiting (a chain of commands) -- <su -c command> && <su -c another command> && <so on and so forth>.

- $MCS is a Tasker variable created to store the output of su -c mcs -s. That output is used to determine whether mcs daemon has been paused. This whole part is unnecessary, through. On-demand operations automatically pause mcs daemon to prevent interference. So, All you need is what comes next.

- su -c <charge for/until...> && su -c <keep charging OFF for/until ...>, which translate to su -c mcs -e <time or percent> && su -c mcs -d <time or percent>. Example: su -c mcs -e 30m && su -c mcs -d 120s && su -c mcs -e 1h && su -c mcs -d.
[Magisk] Bortex19:
Wow! Thank you very much ^^

About this " A bare su won't work with Tasker the way you want it to. So, you have to use short circuiting (a chain of commands) -- <su -c command> && <su -c another command> && <so on and so forth>." I have use exactly this command "mcs -e 50% && mcs -d 10m && mcs -e 60% && mcs -d 5m && mcs -e 70% && mcs -d 10m && mcs -e 80%" without use -c and it worked perfectly (the first thing I did was write "su", press enter and I got superuser permissions). Am I missing anything?

The other user said that he has many different profiles "I have got multiple profiles with the run shell command for different occasions:". How can he alternate between them? (because I suppose that he does not write everything each time)
[Magisk] VR25:
That was fixed, then. It didn't work for me, but last time I tried was last year... so :p

Either disable the ones you're not currently using, or set different triggers for each.
[Magisk] yomama163:
I use Tasker to create these profiles in combination with mcs. These tasks are launched as soon as a condition is fulfilled (device boot, week day, anything you can imagine). Highly recommend this app to automate processes for your phone.

I assume you have root since Magisk grants root privileges.

First you grant root privileges for Tasker. After that you can use one of the most useful commands: Run Shell. Works the same as if you would use a terminal emulator only in a task.

My sample profile to start MCS at boot:

Profile: Device Boot (27)

Event: Device Boot

Enter: Start mcs (28)

A1: Wait [ MS:0 Seconds:10 Minutes:0 Hours:0 Days:0 ]

A2: Run Shell [ Command:su -c mcs -s Timeout (Seconds):0 Use Root:eek:n Store Output In:%MCS Store Errors In: Store Result In: ]

A3: If [ %MCS ~R paused ]

A4: Run Shell [ Command:su -c mcs -s Timeout (Seconds):0 Use Root:eek:n Store Output In:%MCS Store Errors In: Store Result In: ]

A1: I use the wait command to give the system time to boot up completely.

A2: su -c is the command to have root privileges for shell commands, mcs can only work with root. After that mcs -s is the command to start mcs (in case it didn't start for some reason). I store the result of this command in %MCS, A3 will explain why.

A3: %MCS stored the result of the command in text. It can only be resumed or paused. Since I want it to run as soon as I boot my phone I made an IF clause to check if MCS is running or not (hence the %MCS -R paused, equivalent to searching the text for the word "paused")

A4: If MCS is paused, the command from A2 will restart to reassure that MCS is running.

Short: % is only used internally in Tasker to create variables.

I don't use mcs -d or mcs -e in my tasks, so I can't give you any examples.
[Magisk] stammler:
Just installed this, rebooted, went into adb shell and execution of mcs -i shows

/system/bin/mcs[30]: can't create /data/media/mcs/logs/mcs_verbose_log.txt: Permission denied

/data has mod rwxrwx--x and is owned by system:system, so no other user can read... I'm running this on a freshly bought and updated Pixel 2 with the newest Pie image.

Edit: oops, running as root works :victory:
[Magisk] Bortex19:
Have you used "su"command?
[Magisk] stammler:
yeah just realized myself... thanks
[Magisk] elvinguitar:
I wanted to clarify the option for the "%PAUSE %RESUME".

Based on the example:

"mcs 80 20" --> pause charging at 80%; resume when battery level is less or equal to 20%.

I understand that charging will stop once it hits the 80% level. However, I don't understand how the lower threshold (20% in this example) works. It says that charging will resume when the battery level is less or equal to 20%. Does it mean my phone won't charge if the battery level is between 20% and 80%?
[Magisk] Bortex19:
Exactly that. If you want your phone to charge whenever you plug it in but without exceeding 80%, then use "MSC -d 80%"
[Magisk] elvinguitar:
I fully understand the "%PAUSE" limit. What I dont understand is the "%RESUME" limit. It says that charging will resume one the level has reach 20% or less. I'm currently at 70%, and when I try to charge my phone, it worked. I thought it won't work since it hasn't reach the 20% level.
[Magisk] Bortex19:
Battery charging is not prohibited between 20 and 80% . When it reaches 20%, the charge automatically starts again and it will stop at 80%, which is the limit. If you start the charge by your own, it will stop at 80%.

The 20% is something like "hey, don't let it get down here" not "you have to wait until 20% arrives"
[Magisk] elvinguitar:
Well, if that's the case then that means the %RESUME option does not matter. Because the charge will start once you plugged the charger, whether it's below 20% or not (as long as it is beow 80%). If the battery reaches 20% or below, then the %RESUME option is useless if the user forgot to charge the phone.
[Magisk] Bortex19:
As long as I understood, it's useful if you're using your phone while it's charging. It will stops at 80 and will start again at 20
[Magisk] elvinguitar:
Ahhh. So if Im currently at 70, then charge my phone, it will continue charging until it hits 80. Then (while charger is still connected), charging will stop and will only continue once it hits 20. Is that right?
[Magisk] Bortex19:
Yes ?
[Magisk] elvinguitar:
That make sense now. Thank you very much ?
[Magisk] Bortex19:
You are welcome!

Changing the subject, I have realized that I have to write "su; mcs -s; mcs -s" for being able to charge my phone, because if I don't do this, the phone does not charge.

I'm using this command line as default "mcs -e 50% && mcs -d 10m && mcs -e 60% && mcs -d 5m && mcs -e 70% && mcs -d 10m && mcs -e 80%"

For example, now I had a 30% and it did not charge until I did what I wrote above
[Magisk] VR25:
Not all control files hold their value across charger disconnects. In your case, the control file does hold its value. Hence, default setting (charging enabled) is not restored automatically on charger disconnect/reconnect.

You have to manually enable charging with <mcs -e> or reboot the system to be able to charge again.

I understand why you want this specific charging scheme. Unfortunately that level of instructions is not handled automatically (yet).

---

Development Update

Temperature and current/voltage based charging control are coming.

So far, I've been able to control charging voltage indirectly, through the combination of temperature based charging control and current (amperage) modification.

With the ability to modify charging current, I have full control over my device's charging speed (inc. USB charging). Battery can be charged as fast as possible or super slowly... I mean, r-e-a-l-y slow (almost the same as not charging at all).

Obvious benefits aside... as my observations suggest so far, manipulating current has the potential to work on most or even all Android devices, without a custom kernel. Recall that super slow charging is almost the same as not charging at all.
[Magisk] Bortex19:
Thank you! Are you going to put anything to keep the values in a safe range? What have we to keep in mind when we introduce any value (I'm almost noob in electricity)? Could it be dangerous?
[Magisk] VR25:
I'll make all calculations. Users don't have to worry about safety at all. MCS won't accept values beyond set limits.
[Magisk] HosseinMoradi2007:
@VR25

have you read this ?

what do you think about this ?

it seams right :confused:

Re: Battery University article BU-808

Charging - research and methodology
[Magisk] Sachitoge:
Is this perhaps what you need?
[Magisk] guanto96:
Problem in xbin for the Nexus 5 too with the latest version

Btw thank you for the working you are doing
[Magisk] Sachitoge:
The new module works excellent! However, my charging stopped at 82% instead of 80%.

I think this varies depending on diffeeent charging current becausw your module refreshes every x-minute and in low level, my charger charges up to 3600mAh (checked from amperemeter on phone and dongle).

But in 80% it drops to around 1700mAh and around 90% - 95% it drops to around 500mAh - 700mAh.

Either way, few percentage isnt any issue for me but I think you could set up a tweak for specific device so that if device battery level is below 75%, it refreshes more often to stop at the right timing.

My phone charges about 1%/~30 sec if under ~75% to give an example.

Phone batt design capacity is 3.000mAh.

Just giving info in case you want to make it more accurate/precise (but 1 - 4% isnt going to hurt anything nor anyone so, im good with it).

Thanks!

Do you plan to make an app in the future? Like AKT Profile app, instead of using terminal it does change it itself with root permission.

Would make things more easy and can be more quick with save configuration.

Hope someone with knowledge of Android app programming can reserve his time to make an app for this module.
[Magisk] VR25:
You're welcome. Now try build 2017.10.13-2. ;)

[MENTION=6165419]Sachitoge[/MENTION], I'm aware of the issue (it's even stated in the OP). I'm working on that -- thanks for the suggestions! You just refreshed my ideas.

About the Android app -- there's actually one in the wild already. Although it has some limitations and more incompatibility issues, it works great for what it can already do. I've been thinking on building my own app with all cs features since day one. Currently studying the process.
[Magisk] guanto96:
Tried but it gives me again error, I attach the log
[Magisk] Sachitoge:
You stated it is wiping battery stats after successfull charge (script completing) however it still shows me battery stats (history).

Could you implement a command line if typed a cmd you specify, it erases android battery stats/history so it starts from zero, fresh details (for us who avoids charging beyond 80-90%.

It would be nice, a cmd like "cs -w" for example.
[Magisk] guest4711:
Thanks the developers and all supporters for this fine module.

Unfortunately it does not work for my tab2 (espressowifi), where I cannot simply replace a failed battery...

cs-debug.zip attached.
[Magisk] CyberZeus1977:
Hi, just a quick question. I have a Nexus 6P running stock Oreo with EX Kernel and Magisk 14 and a Nexus 4 running Pure Nexus Nougat with Magisk 14.

Does this module work on both?

Thanks

Inviato dal mio Nexus 6P utilizzando Tapatalk
[Magisk] guest4711:
Why don't you try it yourself? You'll need about 5 minutes for download, install, reboot and test...
[Magisk] CyberZeus1977:
I would.

After download it says 'Process error' on both phones

Inviato dal mio Nexus 6P utilizzando Tapatalk
[Magisk] guest4711:
Do I understand it right that you cant install it in MagiskManager? (Magiskmanager -- modules -- "plus sign") Can you install other modules? If not, there is a problem with MagiskManager, probably missing folder /storage/emulated/0/MagiskManager

See the Magisk thread...