Skip to content

Commit

Permalink
**v2021.12.20 (202112200)**
Browse files Browse the repository at this point in the history
- [accd, misc-functions]: prevent unwanted crashes related to `eval` and `set -eu`;
- [batt-info]: filter out the unreliable `POWER_SUPPLY_CHARGE_TYPE` property (note: this change makes AccA always display "unknown" charge type);
- [batt-info]: fixed current reading issue;
- [batt-info]: round current and voltage values to two decimal places;
- [ctrl-files]: added `battery/op_disable_charge 0 1` switch;
- [README]: updated troubleshooting section;
- General optimizations.
  • Loading branch information
VR-25 committed Dec 20, 2021
1 parent 47d551f commit c609dfb
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 46 deletions.
42 changes: 24 additions & 18 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ <h1 id="advanced-charging-controller-acc">Advanced Charging Controller (ACC)</h1
</li>
<li><a href="#troubleshooting">TROUBLESHOOTING</a>
<ul>
<li><a href="#acc--t-is-stuck-waiting-for-charger-andor-acc--i-status-never-reads-charging"><code>acc -t</code> Is Stuck Waiting for Charger and/or <code>acc -i status</code> Never Reads &quot;Charging&quot;</a></li>
<li><a href="#acc--t-hangs-anor-all-charging-switches-fail"><code>acc -t</code> hangs an/or All Charging Switches Fail</a></li>
<li><a href="#battery-capacity--level-doesnt-seem-right">Battery Capacity (% Level) Doesn't Seem Right</a></li>
<li><a href="#bootloop">Bootloop</a></li>
<li><a href="#bootloop-or-unexpected-reboots">Bootloop or Unexpected Reboots</a></li>
<li><a href="#charging-switch">Charging Switch</a></li>
<li><a href="#custom-max-charging-voltage-and-current-limits">Custom Max Charging Voltage And Current Limits</a></li>
<li><a href="#diagnosticslogs">Diagnostics/Logs</a></li>
Expand Down Expand Up @@ -933,22 +933,29 @@ <h3 id="more">More</h3>
<p>This information is in the <a href="#default-configuration">default configuration</a> section as well.</p>
<hr>
<h2 id="troubleshooting">TROUBLESHOOTING</h2>
<h3 id="acc--t-is-stuck-waiting-for-charger-andor-acc--i-status-never-reads-charging"><code>acc -t</code> Is Stuck Waiting for Charger and/or <code>acc -i status</code> Never Reads &quot;Charging&quot;</h3>
<p>Create <code>/data/adb/vr25/acc-data/curr</code> (persistent) or <code>/dev/.vr25/acc/curr</code> (volatile) to disable enhanced battery status check.
In the enhanced mode, if battery status is &quot;charging&quot; and the absolute value of current is &lt;= 50 mA, the status is considered &quot;not charging&quot;.
If the device reports abnormal current values (e.g., due to a hardware issue) and acc fails to notice the issue, charging control will not work.</p>
<h3 id="acc--t-hangs-anor-all-charging-switches-fail"><code>acc -t</code> hangs an/or All Charging Switches Fail</h3>
<p>Create a file <code>/data/adb/vr25/acc-data/curr</code> (persistent) or <code>/dev/.vr25/acc/curr</code> (volatile) to disable enhanced battery status check.
In enhanced mode, if battery status is &quot;charging&quot; and the absolute value of current is &lt;= 50 mA, the status is considered &quot;not charging&quot;.
Although rare, this can cause charging control issues on some devices.
Hence, one may want to see if disabling it makes a difference.
However, before trying this, it's recommend to test a different power source.
Fast charging, in particular, is known for overriding/blocking custom charging control settings.</p>
<h3 id="battery-capacity--level-doesnt-seem-right">Battery Capacity (% Level) Doesn't Seem Right</h3>
<p>When Android's battery level differs from that of the kernel, ACC daemon automatically syncs it by stopping the battery service and feeding it the real value every few seconds.</p>
<p>Pixel devices are known for having battery level discrepancies for the longest time.</p>
<p>If your device shuts down before the battery is actually empty, capacity_sync or capacity_mask may help.
Refer to the <a href="#default-configuration">default configuration</a> section above for details.</p>
<h3 id="bootloop">Bootloop</h3>
<h3 id="bootloop-or-unexpected-reboots">Bootloop or Unexpected Reboots</h3>
<p>While uncommon, it may happen.</p>
<p>It's assumed that you already know at least one of the following: temporary disable root (e.g., Magisk), disable Magisk modules or enable Magisk core-only mode.</p>
<p>Most of the time, though, it's just a matter of plugging the phone before turning it on.
Battery level must be below pause_capacity.
Once booted, one can run <code>acc --uninstall</code> (or <code>acc -U</code>) to remove ACC.</p>
<p>From recovery, one can flash <code>/data/adb/vr25/acc-data/acc-uninstaller.zip</code> or run <code>mount -o ro /system; /data/adb/vr25/acc/uninstall.sh</code>.</p>
<p>Troublesome charging switches trigger unexpected reboots on some systems.
Those can be quickly identified after running <code>acc -x -t</code>.
After the reboot, <code>/sdcard/acc-*.log</code> reveals the problematic switch.
It can then be removed from <code>ctrl-files.sh</code> or blacklisted.</p>
<h3 id="charging-switch">Charging Switch</h3>
<p>By default, ACC uses whichever <a href="https://github.com/VR-25/acc/blob/dev/acc/charging-switches.txt">charging switch</a> works (&quot;automatic&quot; charging switch).
However, things don't always go well.</p>
Expand Down Expand Up @@ -1236,17 +1243,6 @@ <h2 id="links">LINKS</h2>
</ul>
<hr>
<h2 id="latest-changes">LATEST CHANGES</h2>
<p><strong>v2021.10.30 (202110300)</strong></p>
<ul>
<li>Additional charging switches</li>
<li>All control files (switches, current and voltage) are now contained in a single file (<a href="http://ctrl-files.sh">ctrl-files.sh</a>) and it can be overridden by a plugin with the same name.</li>
<li>Fixed issue #117 (@onokatio).</li>
<li>General optimizations</li>
<li>Shutdown warning notifications are less annoying (non-repetitive), but are still disabled by default. To enable, create the file <code>/data/adb/vr25/acc-data/warn</code>.</li>
<li>Strip newlines from the output of acc -p.</li>
<li>The logs tarball now also includes the outputs of <code>getprop</code> and <code>acc -p</code> (potential/new charging switches).</li>
<li>Updated Documentation</li>
</ul>
<p><strong>v2021.11.3 (202111030)</strong></p>
<ul>
<li>Fixed installation issues</li>
Expand All @@ -1263,6 +1259,16 @@ <h2 id="latest-changes">LATEST CHANGES</h2>
<li>Reverted <code>acc mA</code> resume difference to 50;</li>
<li>Updated build script;</li>
<li>Updated links in the README.</li>
</ul>
<p><strong>v2021.12.20 (202112200)</strong></p>
<ul>
<li>[accd, misc-functions]: prevent unwanted crashes related to <code>eval</code> and <code>set -eu</code>;</li>
<li>[batt-info]: filter out the unreliable <code>POWER_SUPPLY_CHARGE_TYPE</code> property (note: this change makes AccA always display &quot;unknown&quot; charge type);</li>
<li>[batt-info]: fixed current reading issue;</li>
<li>[batt-info]: round current and voltage values to two decimal places;</li>
<li>[ctrl-files]: added <code>battery/op_disable_charge 0 1</code> switch;</li>
<li>[README]: updated troubleshooting section;</li>
<li>General optimizations.</li>
</ul>

</body>
Expand Down
41 changes: 24 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
- [Profiles](#profiles)
- [More](#more)
- [TROUBLESHOOTING](#troubleshooting)
- [`acc -t` Is Stuck Waiting for Charger and/or `acc -i status` Never Reads "Charging"](#acc--t-is-stuck-waiting-for-charger-andor-acc--i-status-never-reads-charging)
- [`acc -t` hangs an/or All Charging Switches Fail](#acc--t-hangs-anor-all-charging-switches-fail)
- [Battery Capacity (% Level) Doesn't Seem Right](#battery-capacity--level-doesnt-seem-right)
- [Bootloop](#bootloop)
- [Bootloop or Unexpected Reboots](#bootloop-or-unexpected-reboots)
- [Charging Switch](#charging-switch)
- [Custom Max Charging Voltage And Current Limits](#custom-max-charging-voltage-and-current-limits)
- [Diagnostics/Logs](#diagnosticslogs)
Expand Down Expand Up @@ -961,11 +961,14 @@ This information is in the [default configuration](#default-configuration) secti
## TROUBLESHOOTING


### `acc -t` Is Stuck Waiting for Charger and/or `acc -i status` Never Reads "Charging"
### `acc -t` hangs an/or All Charging Switches Fail

Create `/data/adb/vr25/acc-data/curr` (persistent) or `/dev/.vr25/acc/curr` (volatile) to disable enhanced battery status check.
In the enhanced mode, if battery status is "charging" and the absolute value of current is <= 50 mA, the status is considered "not charging".
If the device reports abnormal current values (e.g., due to a hardware issue) and acc fails to notice the issue, charging control will not work.
Create a file `/data/adb/vr25/acc-data/curr` (persistent) or `/dev/.vr25/acc/curr` (volatile) to disable enhanced battery status check.
In enhanced mode, if battery status is "charging" and the absolute value of current is <= 50 mA, the status is considered "not charging".
Although rare, this can cause charging control issues on some devices.
Hence, one may want to see if disabling it makes a difference.
However, before trying this, it's recommend to test a different power source.
Fast charging, in particular, is known for overriding/blocking custom charging control settings.


### Battery Capacity (% Level) Doesn't Seem Right
Expand All @@ -978,7 +981,7 @@ If your device shuts down before the battery is actually empty, capacity_sync or
Refer to the [default configuration](#default-configuration) section above for details.


### Bootloop
### Bootloop or Unexpected Reboots

While uncommon, it may happen.

Expand All @@ -990,6 +993,11 @@ Once booted, one can run `acc --uninstall` (or `acc -U`) to remove ACC.

From recovery, one can flash `/data/adb/vr25/acc-data/acc-uninstaller.zip` or run `mount -o ro /system; /data/adb/vr25/acc/uninstall.sh`.

Troublesome charging switches trigger unexpected reboots on some systems.
Those can be quickly identified after running `acc -x -t`.
After the reboot, `/sdcard/acc-*.log` reveals the problematic switch.
It can then be removed from `ctrl-files.sh` or blacklisted.


### Charging Switch

Expand Down Expand Up @@ -1376,16 +1384,6 @@ A common workaround is having `resume_capacity = pause_capacity - 1`. e.g., resu
---
## LATEST CHANGES

**v2021.10.30 (202110300)**
- Additional charging switches
- All control files (switches, current and voltage) are now contained in a single file (ctrl-files.sh) and it can be overridden by a plugin with the same name.
- Fixed issue #117 (@onokatio).
- General optimizations
- Shutdown warning notifications are less annoying (non-repetitive), but are still disabled by default. To enable, create the file `/data/adb/vr25/acc-data/warn`.
- Strip newlines from the output of acc -p.
- The logs tarball now also includes the outputs of `getprop` and `acc -p` (potential/new charging switches).
- Updated Documentation

**v2021.11.3 (202111030)**
- Fixed installation issues
- Improved support for the current Magisk canary.
Expand All @@ -1400,3 +1398,12 @@ A common workaround is having `resume_capacity = pause_capacity - 1`. e.g., resu
- Reverted `acc mA` resume difference to 50;
- Updated build script;
- Updated links in the README.

**v2021.12.20 (202112200)**
- [accd, misc-functions]: prevent unwanted crashes related to `eval` and `set -eu`;
- [batt-info]: filter out the unreliable `POWER_SUPPLY_CHARGE_TYPE` property (note: this change makes AccA always display "unknown" charge type);
- [batt-info]: fixed current reading issue;
- [batt-info]: round current and voltage values to two decimal places;
- [ctrl-files]: added `battery/op_disable_charge 0 1` switch;
- [README]: updated troubleshooting section;
- General optimizations.
3 changes: 2 additions & 1 deletion acc/accd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ if ! $init; then
fi

# run custom code
(set +eu
eval "${loopCmd[@]-}"
eval "${loopCmd_-}"
eval "${loopCmd_-}") || :

# shutdown if battery temp >= shutdown_temp
[ $(cat $temp) -lt $(( ${temperature[3]} * 10 )) ] || shutdown
Expand Down
10 changes: 6 additions & 4 deletions acc/batt-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ batt_info() {


# calculator
calc() { awk "BEGIN { print $* }"; }
calc() {
awk "BEGIN {print $*}" | xargs printf %.2f
}


# (determine conversion factor)
dtr_conv_factor() {
factor=${2-}
if [ -z "$factor" ]; then
Expand All @@ -25,14 +26,15 @@ batt_info() {


# raw battery info from the kernel's battery interface

info="$(
set +e
cat $batt/uevent *bms*/uevent 2>/dev/null \
| sort -u \
| sed -e '/^POWER_SUPPLY_NAME=/d' \
-e 's/^POWER_SUPPLY_//' \
-e 's/^BATT_VOL=/VOLTAGE_NOW=/' \
-e 's/^BATT_TEMP=/TEMP=/'
-e 's/^BATT_TEMP=/TEMP=/' \
-e '/^CHARGE_TYPE=/d'
)"


Expand Down
5 changes: 4 additions & 1 deletion acc/batt-interface.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ if ${init:-false}; then
[ ! -f $currFile ] || break
done

curr=$(sed s/-// $currFile)
currThreshold=50 # mA
ampFactor_=1000

if [ $(sed s/-// $currFile) -le $currThreshold ]; then
if [ $curr -le $currThreshold ]; then
ampFactor_=
currThreshold=
else
Expand All @@ -60,6 +61,8 @@ if ${init:-false}; then
}
fi

unset curr

echo "ampFactor_=$ampFactor_
batt=$batt
currFile=$currFile
Expand Down
1 change: 1 addition & 0 deletions acc/ctrl-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ list_ch_switches() {
battery/batt_slate_mode 0 1
battery/device/Charging_Enable 1 0
battery/device/*stop_charging 0 1
battery/op_disable_charge 0 1
battery/store_mode 0 1
idt/pin_enabled 1 0
Expand Down
7 changes: 4 additions & 3 deletions acc/misc-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ disable_charging() {
chargingDisabled=true
fi

(set +eu
eval "${runCmdOnPause[@]-}"
eval "${runCmdOnPause_-}"
eval "${runCmdOnPause_-}") || :

if [ -n "${1-}" ]; then
case $1 in
Expand Down Expand Up @@ -300,7 +301,7 @@ print_wait_plug() {
sleep_sd() {
local i=
for i in $(seq 4); do
eval "$@" && return 0 || sleep $switchDelay
(set +eu; eval "$@") && return 0 || sleep $switchDelay
done
return 1
}
Expand Down Expand Up @@ -361,7 +362,7 @@ write() {
id=acc
domain=vr25
switchDelay=2
loopDelay=(10 10)
loopDelay=(10 15)
execDir=/data/adb/$domain/acc
export TMPDIR=/dev/.vr25/acc
config=/data/adb/$domain/${id}-data/config.txt
Expand Down
4 changes: 2 additions & 2 deletions module.prop
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
id=acc
domain=vr25
name=Advanced Charging Controller (ACC)
version=v2021.12.14
versionCode=202112140
version=v2021.12.20
versionCode=202112200
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 c609dfb

Please sign in to comment.