yashsingh1/xdaforums huggingface dataset:
[Magisk] pat357:
[MENTION=8570610]MCMotherEffin'[/MENTION]

You have some suspicious tests in the mcc and service.sh

example :

if ! mod_dir=$(find /sbin/.core/img /magisk -type d -maxdepth 1 -name mcc); then
echo -e "- Failed to detect Magisk mount point, aborting...\n"; exit 1;
fi;

What exactly do you want to test ?

This if...then tests the return value of "mod_dir=$(find /sbin/.core/img /magisk -type d -maxdepth 1 -name mcc)", which is always 0, so with the negation

this test will always end up to 1. The part inside the if..then will never be executed because of this.

The find command always return 0, independent of something found or not. Only returns non-zero on wrong input or other problems.

What's even more, you assign the value /sbin/.core/img/mcc to mod_dir !

added later :

PS : there is a way with a small change to make the above work and make it as a fallback in case the sed replacement fails :

mod_dir=$(find /sbin/.core/img /magisk -type d -maxdepth 1 -name mcc)
if [ ! $mod_dir ]; then
echo -e "- Failed to detect Magisk mount point, aborting...\n"; exit 1;
fi;

I guess this should work...

End updated text

The following should test what you really want to know :

if [[ $mod_dir != $(find /sbin/.core/img -type d -maxdepth 1 -name mcc) ]] || \
[[ $mod_dir != $(find /magisk -type d -maxdepth 1 -name mcc) ]]; then
echo -e "- Failed to detect Magisk mount point, aborting...\n"; exit 1;
fi;
[Magisk] ichigo696:
Daemon not running, even after MCC -rd. Oneplus one, magisk 16, Tugapower oreo.
[Magisk] jemail:
Hi,

Tried reinstalling latest version as advised.

Daemon not running after reboot and is not running after mcc -rd.

Logs

https://mega.nz/#F!xhNzDDYb!jN8Ghsjv_IvZOs_tG7jClg
[Magisk] Jaymin.0.1910:
What happens when you run

mcc --launch-daemon

directly from Terminal ??

Hi,

Please pull my recent changes again, the code you mentioned has been changed alongside with a little daemon internal change. A next change is in my local repository. Also please note that the break command breaks the entire loop rather than an iteration of it.

Hi, I actually completely forgot that find doesn't return an error. The syntax I'm using is basically a hack in shell to import some C features. What it'd do is assign the output of the command to mod_dir if it succeeded, else execute the body of if...then. Thanks [MENTION=4970217]pat357[/MENTION] for letting me know, I have made necessary changes to my local repo:highfive:

Can you tell me what happens when you run

mcc --launch-daemon

from a Terminal. By default, logging is disabled for daemon to prevent IO overload crashes. If it works well, use CTRL + C to kill it, else please provide all mcc logs.
[Magisk] ichigo696:
It says it's already running, but as you can see, the result from mcc -i is incongruous with what was written before. Maybe it's a flow control error in the assignation of the status variable? Or maybe it's really not running. Sadly, I have no time to look myself. Hope these logs will be useful :)
[Magisk] Jaymin.0.1910:
Thanks for your logs, greatly I have found out where it faulted, and will push an updated version along with support for some huawei devices.
[Magisk] DenyDarko:
Hey [MENTION=8570610]MCMotherEffin'[/MENTION]

Is there a way to prevent the module from reseting battery stats?
[Magisk] MArtyChubbs:
1.5.1 does not install, failure to detect charging. Thanks bro!

Update:

1.5.1 MR installs (detects charging) with Magisk 16.3 - can't get the daemon to start

1.5 MR installs (detects charging) with Magisk 16.0 - can get the daemon to start... have a script to restart run after boot using smmanager.

Thanks to the dev and all for helping out.
[Magisk] lvbaal:
In the OP it says that mcc installer requires MagiskHide to be disabled. I install and run mcc with it MagiskHide being enabled without issues so far. Please explain.
[Magisk] Jaymin.0.1910:
Hi,

Thanks for your question.

Most modules out here are using either topjohnwu's template, or Unity Installer, both of them use Magisk util_functions.sh for installation. The only modules I know not using them are those built by osm0sis and me. I need extermely customized module, so I'm not using the template, and if I source util_functions.sh, it will clutter up my own defined functions, while it is also a requirement for detecting Magisk version.

So, for detecting Magisk version, I'm directly calling the magisk binary, which will not be available by any way ( Magisk gives all its binaries a random name on boot ) other than a direct call. And the direct call to it will be denied if MagiskHide is activated and some hidden app is running. So you can install mcc with MagiskHide activated, but not if some hidden app running.

Your installation might have succeeded because there is no MagiskHidden apps running.

MCMotherEffin'
[Magisk] lvbaal:
Big thanks for the explanation. Indeed, for now, I have no MagiskHidden apps running.
[Magisk] pat357:
Could you tell me where I can find your latest insider code ? Is this on your local repo ? You do keep it also on git hub I hope.

And where can I find your local repo ? (besides on your PC of course)

We need some common ground for the latest code, because I'm of no use to you if I tell you about issues you might have already solved in your local repo.

For the other thing I guess this should always work :

mod_dir=$(find /sbin/.core/img /magisk -type d -maxdepth 1 -name mcc)
if [ ! $mod_dir ]; then
echo -e "- Failed to detect Magisk mount point, aborting...\n"; exit 1;
fi;
[Magisk] MArtyChubbs:
Current setup: Pixel 2 stock with flash kernel 2.3, Magisk 16.0 and xposed.

This works for me:

Busybox for Android NDK 1.28.2 (1.28.3 breaks mcc 1.5: can't find busybox)

MC's Charging Controller 1.5.MR (1.5.1.MR does not install: can't detect charging)

and I run mcc -rd in Termux to start daemon.. all good ;)

On Magisk 16.3:

Busybox for Android NDK 1.28.3

MC's Charging Controller 1.5.1.MR

and when run mcc -rd in Termux to restart daemon...it does not start. so, back to Magisk 16.0 and older Busybox (I don't care, since the other config works and I am happy for what it can do!)
[Magisk] pat357:
[MENTION=8570610]MCMotherEffin'[/MENTION]

Did you make any tests with the mod_dir replace using sed in post-fs--data ?

I don't think it can ever work IMHO.

Reason is that post-fs-data is running before Magisk is overlaying/merging the files.

This way, the patched file in /system/xbin will be replaced by the not patched file in

/magisk/mcc/system/xbin/mcc, and you're back to where you began.

But post-fs-data may open some other possilities :

We could patch the file /magisk/mcc/system/xbin/mcc during post-fs, so that Magisk will replace

/system/xbin/mcc by the already patched file from /magisk/mcc/system/xbin/mcc.

This way the patching is only needed once, thanks to Magisk !

PS: about starting the daemon in service.sh

for i in 1 2 3 4 5; do
( (no_file_logs=true mcc --launch-daemon) &); sleep 10;
done;

Seems you throw out the the "break" command and just let the daemon start 5x, even when it's already running, you just keep starting it !

What's the idea behind this ? It's just 5 x 10sec wasted time : maybe we should compensate in the 120s like 120 - 50 = 70sec and replace

the sleep 120 by sleep 70 ?

It's beyond me why you wouldn't use the solution I've proposed ? It's clear, efficient and no time is wasted.

You might reconsider this.
[Magisk] Jaymin.0.1910:
Hi, I did consider this from a bit of process concept, and I did come up with this. Although the 25 seconds delay is a waste of time, I thought other solutions might break it for the rest.

Hi, I have setup my personal fork of the official repo here and sent you a collaboration invite. All the beta coding will go there, and finally all of them will be pushed to the official stable channel once tested, please contribute your code their. Thanks:highfive:

Hi,

Thanks for using mcc.

I'm aware that BusyBox on Android has never been fully functional, and patching that is developers' favorite task.

And since you told about your config, I'm happy to inform you that most of the flaws have been fixed on my personal Repo. Currently, I'm testing support for huawei devices with help of [MENTION=1861039]lvbaal[/MENTION]. Once all done, I'd push it to official repo.

MCMotherEffin'
[Magisk] papoy1019:
Please try to include this switch for Asus Selfie! Thanks!

/sys/class/power_supply/usb/present

enabled=1

disabled=0
[Magisk] Sudarchikov:
Hi, [MENTION=8570610]MCMotherEffin'[/MENTION] !

If suddenly you have some free time, could you see my logs and perform a miracle? ;)

Asus Z00A logs here:
[Magisk] Jaymin.0.1910:
Wait a minute, I have written already some code for supporting your device. Thanks to [MENTION=1861039]lvbaal[/MENTION] and [MENTION=8874047]papoy1019[/MENTION].
[Magisk] pat357:
[MENTION=8570610]MCMotherEffin'[/MENTION]

There's some confusion about donations :

In the file README

## Encourage Me

* I don't accept donation, so if you like my work, please hit

the 'Thanks' button on the official thread to encourage me.

While you do have a donation page set up by Paypal and even a direct link to it via -donate.

There is some contradiction between this 2 !!

What is your policy about donations ?
[Magisk] MArtyChubbs:
That is brilliant! can't wait
[Magisk] Jaymin.0.1910:
Yes, I have one. BUT that doesn't work as I'm still a minor. Also all I do is entirely for my own programming practice, so that I can be a good professional programmer in the future. So I don't think donations make sense.
[Magisk] Yousef Taha:
[MENTION=8570610]MCMotherEffin'[/MENTION] I installed it on my Samsung Galaxy Note 3 LTE (N9005) running latest LineageOS 14.1 and latest Magisk.

Set the command 'mc -s 85 80' and rebooted but got into bootloop..

I tried uninstalling magisk in recovery but no luck .. Dirty reflashed ROM but still bootlooping.

Would you please give me the trashbin link here
[Magisk] Jaymin.0.1910:
mcc saves its all files to magisk.img, the only external files are environment logs stored in /cache ( which too I have moved to magisk.img in my latest local beta version ).

You can simply remove /data/adb/magisk.img from recovery and reboot.

If that doesn't work uninstall Magisk from recovery, and boot into bootloader and reboot.

Please also check for any system modifications you might have done, since removing Magisk restores stock boot image which is not patched to pass dm-verity.

EDIT: After you restore your device, can you help me debug bootloops for such devices ?? Don't worry, it wouldn't mess anything.
[Magisk] Yousef Taha:
I tried what you said, but still in a bootloop.

I haven't done any other system modifications other than mcc. I hope you can help me restore my phone without having to wipe the data. And of course, I would be happy to help you debug any problems :)
[Magisk] Jaymin.0.1910:
:confused::mad:Can you grab logcat while booting ?? :)
[Magisk] Yousef Taha:
I'm sorry I'm kindda a noob, could you please tell me how to get the logcat?
[Magisk] pat357:
Holey cow, a bootloop !

There might be a way without uninstalling Magisk and loosing all your other modules.

This way you'll not lose other modules and you don't have to reinstall Magisk

download Magisk_mount ( https://xdaforums.com/attachment.php?attachmentid=4460801&d=1522324923 )

install it via TWRP

still in TWRP go to advanced -> filemanager

In the root of your internal sdcard you'll find the directory /magisk

Inside /magisk, there is a sub-directory called mcc

Delete this directory mcc.

reboot back to system

Done !

You could also use one of the 2 other recovery modules listed there.

They should both be able to uninstall/disable modules from inside TWRP.

https://xdaforums.com/apps/magisk/module-tool-magisk-manager-recovery-mode-t3693165

https://xdaforums.com/showpost.php?p=72542167&postcount=242

---------- Post added at 08:35 PM ---------- Previous post was at 07:47 PM ----------

See here : https://xdaforums.com/showthread.php?t=2274119

It's the same procedure for all phones.

What phone do you have ?
[Magisk] Yousef Taha:
I've tried all above ways but still bootlooping. Weird thing is, when I listed the modules it said that there are no modules!

I don't know how exactly is the module is causing the bootloop if it's no longer installed! Even after uninstalling Magisk and wiping System, Cache and Dalvik, then flashing the rom again still bootlooping!

About the logcat, I've read the post you referred to but the problem is it's too old and outdated (since 2013) and the Android SDK is now much different than that in the post's instructions.

I'm using Samsung Galaxy Note 3 LTE (N9005) running latest Lineageos 14.1
[Magisk] pat357:
You didn't wipe your data, did you ?

Because if you wiped system, cache & dalvik, data is the only one left to cause the bootloop.

The tools I mentioned in my first post, are meant to be used BEFORE uninstalling magisk.

Now with uninstalling magisk, new possible problems come in to play, like dm-verity and forced encryption.

Can you still see the data on your phone-memory and the data on your sd-card when booting via TWRP ?

You should certainly check this, as your data might be encrypted by now.

Uninstalling Magisk was maybe not the smartest thing to do : Magisk took care of dm-verity and prevented your data from becoming encrypted.

About the link I gave you to make a logcat : the way to make a logcat is still the same as it was in 2013 !!

There is nothing changed about the preparation (getting ADB, PC drivers) and the commands to make a logcat.

Of course feel free to google for a more recent page , maybe I 've "spoon-feeded" you to much !;)
[Magisk] Jaymin.0.1910:
[MENTION=8507997]Yousef Taha[/MENTION], I suggest please clean flash your ROM:o. Since mcc have no traces left, it must be something else:)
[Magisk] Yousef Taha:
I did indeed and it's working now.. Thanks for the help anyway ;)
[Magisk] pat357:
I hope you didn't loose your /data ?

I suppose you still have TWRP ?

I strongly advise you to make a nandroid backup on your extSD once you have setup your apps/Magisk modules again.
[Magisk] Yousef Taha:
Fortunately, I periodically make a backup of all my apps and data using Titanium Backup. Bad thing was that I lost my Whatsapp messages after the last backup.

In your opinion, do you think that it's better to make a backup using TB or a nandroid backup using TWRP? The only difference I see is that a nandroid backup additionally backs up the system, which is not of much importance considering that Lineageos zip is only a 315 MB.
[Magisk] piptron:
Still unsupported
[Magisk] Deus.:
Hello everyone,

I'm using this tool for a while, unfortunately since 1.3.9 I can't install updates. I had to re-install my system yesterday, and, of course, everything wiped, the Charging Switch as well.

Is there a source where I can download the MCC 1.3.9 version? Newer versions cannot be installed.
[Magisk] Jaymin.0.1910:
Hi I'm the developer.

I couldn't find any traces of version 1.3.9, is there such version ?? I can't remember of any. Are you talking about the 1.3.MR version ?? If so, quote this post back and I'd build a zip for you.
[Magisk] Deus.:
Hello,

Thanks for the quick reply. To be honest, I'm not sure if it was really 1.3.9, I can remember 1.3.something, the last before 1.4 (that I'm 100% sure).
[Magisk] NYLimited:
Hello,

I've been trying to figure out just how to use your module but I must be doing something wrong. I hope you can point me in the right direction when you have some time..

I installed the latest version posted in this thread. I ran it with default settings at first. Later changed the thresholds. In all cases info displayed in terminal is this (or similar):

su
pplus:/ $ su
pplus:/ # mcc -i

- Battery status

-- battery level :- 100
-- battery health :- Good
-- charging status :- Not charging

- Current settings

-- up threshold :- 90
-- down threshold :- 70
-- shut threshold :- 20

-- automatic switching :- ON
-- automatic power-off :- ON
-- background daemon mode :- ON

-- daemon ( bg activity ) status :- Not running

pplus:/ #

Now, if I understood things correctly charging should have stopped at 90% but it never does. It always charges to full 100% as shown above.

Also, it seems to show that the daemon is not running - I don't know if that simply means paused for the moment but it always shows not running. I'm attaching the logs you requested (mcc_err was zero bytes, hence it is not added).

Thanks for any help you might offer!
[Magisk] lvbaal:
If mcc must interrupt charging, at leadt the feamon should be running.. Try mcc -rd and see what it says
[Magisk] NYLimited:
I'm pretty sure that made no difference when I tried in the past. Anyhow, here it is again:

su
pplus:/ $ su
pplus:/ # mcc -rd

- mcc daemon is not running, launching it...

- It should be running now

pplus:/ # mcc -i

- Battery status

-- battery level :- 94
-- battery health :- Good
-- charging status :- Charging

- Current settings

-- up threshold :- 90
-- down threshold :- 70
-- shut threshold :- 20

-- automatic switching :- ON
-- automatic power-off :- ON
-- background daemon mode :- ON

-- daemon ( bg activity ) status :- Not running

pplus:/ #
[Magisk] Jaymin.0.1910:
Hi, this bug is introduced with the last release. Please wait until I push the next version. The daemon will never run since it kills itself.
[Magisk] NYLimited:
Thanks fir the quick answer. No problem waiting, take your time. Actually, a daemon that kills itself is quite humorous (yes, I have a twisted sens of humour).. ;)
[Magisk] Jaymin.0.1910:
Meanwhile, see there should be a file MAGISK_MOUNTPOINT/mcc/mcc.conf, which should have a line like switch_1=/some/path some_value other_value, and maybe another switch_2=/some/path some_value other_value. Could you send me which owner and group those files in switch_1 and switch_2 belong to ?? or just the output of

ls -l /path/to/each/switch[/b] ?? Thanks
[Magisk] Jaymin.0.1910:
Thanks and guess what ?? A new update will go live in the next few hours!!!
[Magisk] NYLimited:
Nice, thanks! I'll have to run my battery down somewhat to try it (at 100% now). I guess in the morning - it is only 01:13 here. You are way ahead of me by some 9.5 hours I think..
[Magisk] Deus.:
Thank you for your work, I just installed the 2.0 beta from Magisk, it was installed successfully, after a reboot the 'mcc -i' shows the daemon isn't running, when I run 'mcc -rd' it shows "Failed to launch the daemon".
[Magisk] Jaymin.0.1910:
Please attach the log files. What does

busybox ps | grep -v grep | grep '{mcc}'

show ??
[Magisk] Deus.:
Which log do you mean exactly? The command output is doesn't mention any log.

The output of the "busybox ps | grep -v grep | grep '{mcc}'" command is: busybox not found

I ran a "find / -name busybox 2> /dev/null" command and it can be found in multiple places, /sbin/.core/img/mcc/busybox, for example

EDIT: fixed it, I ran the busybox from the /sbin/.core/img/mcc/busybox directory. The output:

busybox ps | grep -v grep | grep '{mcc}' <
5712 root 0:07 {mcc} /system/bin/sh /system/xbin/mcc --launch-daemon
6567 root 0:07 {mcc} /system/bin/sh /system/xbin/mcc --launch-daemon
[Magisk] Jaymin.0.1910:
Hello, see the 4th post for log files. Zip and attach them here.

EDIT: Don't worry, I figured out a fix myself, no need of logs. Will push them in a few minutes.

EDIT: Done.
[Magisk] Deus.:
I was pretty close to upload the log :D

Yeah, the new version works like a charm, thank you.
[Magisk] Sudarchikov:
Hi, [MENTION=8570610]JayminSuthar[/MENTION]

Unfortunately, last build does not work on my Asus Zenfone 2 (Z00A) (((

>> mcc: error: Failed the check

>> Failed!

>> ! Installation failed

Is it completely hopeless?
[Magisk] Jaymin.0.1910:
I currently don't have any such devices, if you can find a control file on your own like [MENTION=1861039]lvbaal[/MENTION] and [MENTION=8874047]papoy1019[/MENTION] did, I will always be here to add support for your device. Your device possible don't have hardware support or it doesn't follow general standards.
[Magisk] NYLimited:
Uninstalled previous version, installed new one.

Working as expected now, thanks!

One more question if I may..

I attempted to change the default settings to 90 75. I used the terminal command

mcc -f -s 90 75

However, the module insists on changing the lower value to 80% - always 10% less than the upper value. Now, mind you, this is not totally bad but shouldn't it set the values as specified?
[Magisk] Jaymin.0.1910:
Thanks for letting me know about it. I took a quick look and found out a faulty exclamation mark. I will push an update sooner:o
[Magisk] papoy1019:
Its already available in repository! Working great in my Asus Z00T Selfie, LOS 14.1! More power to the Dev! :victory:
[Magisk] DenyDarko:
Ive noticed a weird behavior with the module.

While generally it works, when it reaches the down limit, for example 85%, it will start/stop charging continuously till it reaches 86% where it stabilizes.

Same start/stop behavior happens when it reaches the upper limit till the device loses one percentage. Ie 95% - > 94%
[Magisk] Jaymin.0.1910:
Yes, that's a new thing implemented to make sure charging is stably en/disabled. The start/stop you saw were to make kernel know of the change. Although it will only happen if the battery current is what is not expected. If that causes any bad effect, feel free (in other words,"please do") post here about that.
[Magisk] kkolokol:
Thanks - at last all is functioning properly(last update). If meaningful: HTC U11 stock 2.42.617.6. Your competitor - mcs - is not functioning any more but you are.
[Magisk] NYLimited:
Mine did the same but at a percentage much lower. I noticed the flashing at around 72% and my lower threshold is at 83 or 84.

The only undesirable part that I know of is that my screen brightness is set to increase by 10% when plugged and, if the screen happens to be on during this time, it will keep getting brighter and dimmer.. :D
[Magisk] DenyDarko:
It's not just one start/stop. That was the past behavior and it was fine.

Now It's a constant loop start/stop till the battery percentage changes.
[Magisk] papoy1019:
Well, its not really competitor, because if you know what you want, you really want to use it. Its very good that there are many approaches to achieve our goal. For me, there are 3 ways that i can use of. First, this mcc, second mcs and lastly the battery charging limit app. They have the same use, its up to you what suits you best. And most of all, its all free. So, it doesnt make one superior to others because they are doing the same thing, its up to the user if he/she knows what he is doing. Its good to uplift someone or something but its best to do it by not degrading others.
[Magisk] pat357:
Same here, and if the phone is sleeping, it makes it awake and put the screen on -> more battery usage !

It looks like someone is connecting/disconnecting the charger.

Uninstalled v2.0 and I went back to version 1.50 for this reason.
[Magisk] MArtyChubbs:
All is working on magisk 16.3.

I see the new default behavior is mcc -s 80 70. May I ask why? Was mcc -s 80 60 not optimal?

Great work!
[Magisk] pat357:
Sorry for the delayed reply.... been busy :p

I guess you should use both TB and a nandroid backup (like I do).

With TB you can restore your apps and settings , but in case of a complete loss, a nandroid restore is much faster and you are sure you have everything back.

TB on the other hand can be used after updating your system (newer firmware version or even a complete different custom firmware).

So, my suggestion is USE BOTH !
[Magisk] Yousef Taha:
Alright. Thanks bro for the help :D
[Magisk] jemail:
Moto G Osprey version 2.0MR fails to install. Fails check.

[MENTION=4970217]pat357[/MENTION]

Does anyone have version 1.5 I can download please?

The first 1.5 version, as I think a version of 1.5 was pushed twice in the same day and only the first one worked for me.