VR-25 / acc

Advanced Charging Controller
https://github.com/Magisk-Modules-Repo/acc
GNU General Public License v3.0
1.75k stars 109 forks source link

accd exits for reason I don't understand (nothing phone 1) #169

Closed Bert-Proesmans closed 2 years ago

Bert-Proesmans commented 2 years ago

Hi!

I'm running acc v2022.7.30-dev through Magisk 25200. My Nothing(the company) Phone experiences accd exits. The last lines of the log mention

Spacewar:/ # acc -l tail

50: >/dev/null
50: grep -iv bms
405: sleep 10
406: true
406: sync_capacity
/data/adb/vr25/acc/accd.sh[645]: sync_capacity: inaccessible or not found
400: exxit
83: exitCode=127
84: false
84: set +eux

All logs are attached here, acc-logs-Spacewar.tgz (this is not a zip file, I added the extension in the filename to appease github). These logs were generated after;

  1. Wireless charging my phone
  2. Confirming battery charge is above 60%, 60% should disable the charging switch
  3. Confirming accd is not running by opening AccA

This is not the first time accd suddenly stopped working, I have manually restarted the daemon through AccA multiple times over the last couple of days. When accd is running, everything works as expected; aka both wireless charging and USB power get cut off as expected.

My configuration consists of 2 files; acc-default-conf.txt acc-fast-conf.txt

between which I toggle with DJS;

djsc --append "boot /system/bin/acc --daemon stop; /system/bin/accd --init '${CONFIG_IDLE}';"
djsc --append "0900 /system/bin/acc --daemon stop; /system/bin/accd --init '${CONFIG_IDLE}'; /system/bin/acc -n 'Battery saver';"
djsc --append "2200 /system/bin/acc --daemon stop; /system/bin/accd --init '${CONFIG_IDLE}'; /system/bin/acc -n 'Battery saver';"

djsc --append "0700 /system/bin/acc --daemon stop; /system/bin/accd --init '${CONFIG_FAST}'; /system/bin/acc -n 'Fast charging allowed';"
djsc --append "1730 /system/bin/acc --daemon stop; /system/bin/accd --init '${CONFIG_FAST}'; /system/bin/acc -n 'Fast charging allowed';"

https://github.com/Bert-Proesmans/nothing-phone/blob/d2cb377baed74b3a6f240df88df44fd29503469f/acc-setup.sh#L80-L88 (my whole acc/djs setup is within that acc-setup.sh file)

I have noticed that acc tends to act up when not recently having charged the battery. acca -s c 500 specifically waits for a connected charger before proceeding. I do not yet fully understand why, I observed more symlinks are stored after charger connection. So I tried to sidestep any voltage/power control requirements by specifically working with configuration files.

The goal of my configuration is to have a fast-charge and preservation-charge profile be applied at certain times during the day. This is accompanying my daily schedule.
It's possible I'm 'holding it wrong' (i mean acc), but would then like to ask for some additional guidance please.

Bert-Proesmans commented 2 years ago

So I was battling a few issues at the same time.

One of them is that I stopped and reinitialized the daemon because I understood a custom configuration file always requires the --init argument. Re-initializing the daemon when switching charging profiles is unnecessary for my purposes, --init can be omitted.

The second one is CPU sleep, both acc's at command and djs itself are not fully android integrated task runners; The commands are not executed when the device is in CPU sleep at the declared point in time. I naïvely expected the code to schedule a device wake within the minute of a scheduled command, which doesn't happen. Neither does accd invoke the required commands asap after a missed command execution (at command).

To be clear, acc always worked for allowing/disallowing charging. What didn't work is the way I tried to operate it, using automatically scheduled charging profiles.

In the meantime I switched over to instrumenting AccA, but it quickly became obvious that the app gets confused about the active charging profile, locks up while changing profiles, gets confused about the installed state of djs etc.
I've played with the thought of updating AccA to fix those issues and use the djs integration to wake-lock/schedule wake-ups. But my sense for simplicity took over.

I now circled back to a single charge profile that's active all the time. The charge switches work perfectly so no further complaints from me.
I'll now be a forever at 60% charge!