Skip to content

Commit

Permalink
**v2021.8.31 (202108310)**
Browse files Browse the repository at this point in the history
- Additional charging switches
- Fixed "current_now is always 0 mA."
- Logs are exported as a tarball archive.
- Updated readme > notes/tips for front-end developers > initializing acc
  • Loading branch information
VR-25 committed Aug 31, 2021
1 parent f8146e0 commit 3d08d20
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 70 deletions.
52 changes: 23 additions & 29 deletions README.html
Expand Up @@ -848,29 +848,22 @@ <h3 id="installingupgrading-acc">Installing/Upgrading ACC</h3>
<h3 id="uninstalling-acc">Uninstalling ACC</h3>
<p>Either run <code>/dev/.vr25/acc/uninstall</code> (no reboot required; <strong>charger must be plugged</strong>) or uninstall from Magisk manager and reboot.</p>
<h3 id="initializing-acc">Initializing ACC</h3>
<p>ACC is automatically initialized after installation/upgrades.
It needs to be initialized on boot, too.
If it's installed as a Magisk module, this is done by Magisk itself.
Otherwise, the front-end should handle it as follows:</p>
<pre><code><code><div>on boot_completed receiver and main activity
if file /dev/.acca/started does NOT exist
create it
mkdir -p /dev/.acca
touch /dev/.acca/started
if accd is NOT running
launch it
/data/adb/vr25/acc/service.sh
else
do nothing
else
do nothing
</div></code></code></pre>
<p><code>/dev/</code> is volatile - meaning, a reboot/shutdown clears <code>/dev/.acca/</code> and its contents.
That's exactly what we want.
Of course, <code>/dev/.acca/started</code> is just an example.
One can use any random path (e.g., <code>.myapp/initialized</code>), as long as it's under <code>/dev/</code> and does not conflict with preexisting data.
<strong>WARNING</strong>: do not play with preexisting /dev/ data!
Doing so may result in data loss and/or other undesired outcome.</p>
<p>On boot_completed receiver and main activity, run:</p>
<p><code>[ -f /dev/.vr25/acc/acca ] || /data/adb/vr25/acc/service.sh</code></p>
<p>Explanation:</p>
<p>ACC's working environment must be initialized - i.e., by updating the stock charging config (for restoring without a reboot) and pre-processing data for greater efficiency.
This is done exactly once after boot.
If it were done only after installation/upgrade, one would have to reinstall/upgrade acc after every kernel update.
That's because kernel updates often change the default power supply drivers settings.</p>
<p>Since acc's core executables are dynamic ([expected to] change regularly), those are linked to <code>/dev/.vr25/acc/</code> to preserve the API.
The links must be recreated once after boot (/dev/ is volatile).</p>
<p><code>accd</code> is a symbolic link to <code>service.sh</code>.
If <a href="http://service.sh">service.sh</a> is executed every time the <code>main activity</code> is launched, accd will be repeatedly restarted for no reason.</p>
<p>Notes</p>
<ul>
<li>This &quot;manual&quot; initialization is only <em>strictly</em> required if Magisk is not installed - and only once per boot session. In other words, Magisk already runs <a href="http://service.sh">service.sh</a> shortly after boot.</li>
<li>ACC's installer always initializes it.</li>
</ul>
<h3 id="managing-acc">Managing ACC</h3>
<p>As already stated, front-ends should use the executable <code>/dev/.vr25/acc/acca</code>.
Refer to the <a href="#default-configuration">default configuration</a> and <a href="#terminal-commands">terminal commands</a> sections above.</p>
Expand Down Expand Up @@ -1181,12 +1174,6 @@ <h2 id="links">LINKS</h2>
</ul>
<hr>
<h2 id="latest-changes">LATEST CHANGES</h2>
<p><strong>v2021.8.2 (202108020)</strong></p>
<ul>
<li>Fixed AccA related issues.</li>
<li>Fixed charging switch list tester (-t /path/to/list).</li>
<li>Fixed charging switch parser (-p).</li>
</ul>
<p><strong>v2021.8.4 (202108040)</strong></p>
<ul>
<li>Dynamically add/remove current_now negative sign.</li>
Expand Down Expand Up @@ -1247,6 +1234,13 @@ <h2 id="latest-changes">LATEST CHANGES</h2>
</li>
</ul>
<p>Release note: plug the charger if the install, upgrade, stop or restart processes seem to take too long.</p>
<p><strong>v2021.8.31 (202108310)</strong></p>
<ul>
<li>Additional charging switches</li>
<li>Fixed &quot;current_now is always 0 mA.&quot;</li>
<li>Logs are exported as a tarball archive.</li>
<li>Updated readme &gt; notes/tips for front-end developers &gt; initializing acc</li>
</ul>

</body>
</html>
60 changes: 29 additions & 31 deletions README.md
Expand Up @@ -836,30 +836,27 @@ Either run `/dev/.vr25/acc/uninstall` (no reboot required; **charger must be plu

### Initializing ACC

ACC is automatically initialized after installation/upgrades.
It needs to be initialized on boot, too.
If it's installed as a Magisk module, this is done by Magisk itself.
Otherwise, the front-end should handle it as follows:
```
on boot_completed receiver and main activity
if file /dev/.acca/started does NOT exist
create it
mkdir -p /dev/.acca
touch /dev/.acca/started
if accd is NOT running
launch it
/data/adb/vr25/acc/service.sh
else
do nothing
else
do nothing
```
`/dev/` is volatile - meaning, a reboot/shutdown clears `/dev/.acca/` and its contents.
That's exactly what we want.
Of course, `/dev/.acca/started` is just an example.
One can use any random path (e.g., `.myapp/initialized`), as long as it's under `/dev/` and does not conflict with preexisting data.
**WARNING**: do not play with preexisting /dev/ data!
Doing so may result in data loss and/or other undesired outcome.
On boot_completed receiver and main activity, run:

`[ -f /dev/.vr25/acc/acca ] || /data/adb/vr25/acc/service.sh`

Explanation:

ACC's working environment must be initialized - i.e., by updating the stock charging config (for restoring without a reboot) and pre-processing data for greater efficiency.
This is done exactly once after boot.
If it were done only after installation/upgrade, one would have to reinstall/upgrade acc after every kernel update.
That's because kernel updates often change the default power supply drivers settings.

Since acc's core executables are dynamic ([expected to] change regularly), those are linked to `/dev/.vr25/acc/` to preserve the API.
The links must be recreated once after boot (/dev/ is volatile).

`accd` is a symbolic link to `service.sh`.
If service.sh is executed every time the `main activity` is launched, accd will be repeatedly restarted for no reason.

Notes

- This "manual" initialization is only _strictly_ required if Magisk is not installed - and only once per boot session. In other words, Magisk already runs service.sh shortly after boot.
- ACC's installer always initializes it.


### Managing ACC
Expand Down Expand Up @@ -1293,13 +1290,6 @@ A common workaround is having `resume_capacity = pause_capacity - 1`. e.g., resu
## LATEST CHANGES


**v2021.8.2 (202108020)**

- Fixed AccA related issues.
- Fixed charging switch list tester (-t /path/to/list).
- Fixed charging switch parser (-p).


**v2021.8.4 (202108040)**

- Dynamically add/remove current_now negative sign.
Expand Down Expand Up @@ -1338,3 +1328,11 @@ Refer to the release note bellow and documentation for details.
- Updated documentation (more information, now with a table of contents and in HTML format)

Release note: plug the charger if the install, upgrade, stop or restart processes seem to take too long.


**v2021.8.31 (202108310)**

- Additional charging switches
- Fixed "current_now is always 0 mA."
- Logs are exported as a tarball archive.
- Updated readme > notes/tips for front-end developers > initializing acc
2 changes: 2 additions & 0 deletions TODO.txt
Expand Up @@ -21,3 +21,5 @@ acca --daemon option seems unreliable, even though -D works just fine
open html doc on/from terminal

make [most] code POSIX compliant

two instances of accd running
2 changes: 1 addition & 1 deletion acc/batt-info.sh
Expand Up @@ -56,7 +56,7 @@ batt_info() {


# parse CURRENT_NOW & convert to Amps
currNow=$(echo "$info" | sed -n "s/^CURRENT_NOW=//p")
currNow=$(echo "$info" | sed -n "s/^CURRENT_NOW=//p" | head -n1)
dtr_conv_factor ${currNow#-} ${ampFactor-}
currNow=$(calc ${currNow:-0} / $factor)

Expand Down
4 changes: 3 additions & 1 deletion acc/charging-switches.txt
Expand Up @@ -4,7 +4,7 @@
#
# "::" = " ", applies to MTK only
# PWD=/sys/class/power_supply
# Last updated: Tue, Aug 10, 2021
# Last updated: Tue, Aug 31, 2021

smb?/input_suspend
battery/charger_control 1 0
Expand Down Expand Up @@ -39,6 +39,7 @@ battery/device/smartchg_stop_charging 0 1
battery/input_suspend 0 1
bq*standalone/charging_enabled 1 0
battery/mmi_charging_enable 1 0
bbc/charging_enabled 1 0

/sys/devices/platform/soc/soc:google,charger/charge_disable 0 1
/proc/smb*_disable_chrg 0 1
Expand All @@ -62,6 +63,7 @@ battery/mmi_charging_enable 1 0

# EXPERIMENTAL
/sys/devices/platform/battery_meter/FG_suspend_current_threshold 100 5
bbc/hiz_mode 0 1

# troublesome
#/sys/power/pnpmgr/battery/charging_enabled 1 0
Expand Down
6 changes: 2 additions & 4 deletions acc/logf.sh
Expand Up @@ -34,11 +34,9 @@ logf() {
batt_info > $TMPDIR/acc-i.txt)
dumpsys battery > dumpsys-battery.txt

tar -c *.log *.txt \
| bzip2 -9 > $data_dir/logs/acc-logs-$device.tar.bz2

tar -c *.log *.txt | gzip -9 > $data_dir/logs/acc-logs-$device.tar.gz
rm *.txt magisk.log in*.log power*.log m*accapp.log 2>/dev/null
echo "(i) $data_dir/logs/acc-logs-$device.tar.bz2"
echo "(i) $data_dir/logs/acc-logs-$device.tar.gz"

else
if tt "${1:-x}" "-*a*"; then
Expand Down
2 changes: 1 addition & 1 deletion acc/strings.sh
Expand Up @@ -167,7 +167,7 @@ Options
-la Same as -l -a
-l|--log -e|--export Export all logs to /data/adb/vr25/acc-data/logs/acc-logs-\$deviceName.tar.bz2
-l|--log -e|--export Export all logs to /data/adb/vr25/acc-data/logs/acc-logs-\$deviceName.tar.gz
e.g., acc -l -e
-le Same as -l -e
Expand Down
2 changes: 1 addition & 1 deletion acc/translations/de-DE/strings.sh
Expand Up @@ -147,7 +147,7 @@ z.B.,
acc -l -a cat
acc -l grep ': ' (zeigt nur explizite Fehler an)
-la Dasselbe wie -l -a
-l|--log -e|--export Alle Protokolle nach /sdcard/Documents/vr25/acc/logs/acc-logs-\$deviceName.tar.bz2 exportieren
-l|--log -e|--export Alle Protokolle nach /sdcard/Documents/vr25/acc/logs/acc-logs-\$deviceName.tar.gz exportieren
z.B., acc -l -e
-le Dasselbe wie -l -e
-r|--readme [editor] [editor_opts] README.md anzeigen/bearbeiten
Expand Down
4 changes: 2 additions & 2 deletions module.prop
@@ -1,7 +1,7 @@
id=acc
domain=vr25
name=Advanced Charging Controller (ACC)
version=v2021.8.29
versionCode=202108290
version=v2021.8.31
versionCode=202108310
author=VR25
description=Mainly intended for extending battery service life on Android devices. In a nutshell, this is achieved through limiting charging current, temperature and voltage. Any root solution is supported. The installation is always "system-less", whether or not the system is rooted with Magisk.

0 comments on commit 3d08d20

Please sign in to comment.