Skip to content

Commit

Permalink
**v2021.10.30 (202110300)**
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
VR-25 committed Oct 30, 2021
1 parent 3eaf5d4 commit 5ad7b43
Show file tree
Hide file tree
Showing 17 changed files with 235 additions and 175 deletions.
2 changes: 1 addition & 1 deletion META-INF/com/google/android/update-binary
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ set -eu
srcDir="$(cd "${0%/*}" 2>/dev/null || :; echo "$PWD")"

# extract flashable zip if source code is unavailable
[ -f $srcDir/module.prop ] || {
[ -f $srcDir/$id ] || {
srcDir=/dev/.$domain.${id}-install
rm -rf $srcDir 2>/dev/null || :
mkdir $srcDir
Expand Down
49 changes: 29 additions & 20 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ <h4 id="notes-2">Notes</h4>
<h2 id="default-configuration">DEFAULT CONFIGURATION</h2>
<pre><code><code><div>#DC#

configVerCode=202109200
configVerCode=202110020
capacity=(-1 60 70 75 false false)
temperature=(40 60 90 65)
cooldownRatio=()
Expand Down Expand Up @@ -347,9 +347,13 @@ <h2 id="default-configuration">DEFAULT CONFIGURATION</h2>

# chargingSwitch=charging_switch=(3700)

# applyOnBoot=apply_on_boot=(ctrl_file1::value1::default1 ctrl_file2::value2::default2 ... --exit)
# applyOnBoot=apply_on_boot=(ctrl_file1::value[::default] ctrl_file2::value[::default] ... --exit)

# applyOnPlug=apply_on_plug=(ctrl_file1::value1::default1 ctrl_file2::value2::default2 ...)
# applyOnPlug=apply_on_plug=(ctrl_file1::value[::default] ctrl_file2::value[::default] ...)

# maxChargingCurrent=max_charging_current=([value] ctrl_file1::value::default ctrl_file2::value::default ...)

# maxChargingVoltage=max_charging_voltage=([value] ctrl_file1::value::default ctrl_file2::value::default ...) --exit)

# maxChargingCurrent=max_charging_current=([value] ctrl_file1::value::default1 ctrl_file2::value::default2 ...)

Expand Down Expand Up @@ -454,8 +458,8 @@ <h2 id="default-configuration">DEFAULT CONFIGURATION</h2>

# shutdown_capacity (sc) #
# When the battery is discharging and its capacity/voltage_now_millivolts &lt;= sc and phone has been running for 15 minutes or more, acc daemon turns the phone off to reduce the discharge rate and protect the battery from potential damage induced by voltage below the operating range.
# sc=0 disables it.
# [Beta] if the file /data/adb/vr25/acc-data/warn exists, accd posts Android shutdown warning notifications at sc+10%, sc+5%, sc+300mV and sc+100mV.
# sc=-1 disables it.
# [Beta] if the file /data/adb/vr25/acc-data/warn exists, accd posts Android shutdown warning notifications at sc + 5% or sc + 200 mV.

# cooldown_capacity (cc) #
# Capacity/voltage_now_millivolts at which the cooldown cycle starts.
Expand All @@ -470,12 +474,13 @@ <h2 id="default-configuration">DEFAULT CONFIGURATION</h2>

# capacity_sync (cs) #
# Some devices, notably from the Pixel lineup, have a capacity discrepancy issue between Android and the kernel.
# This forces Android to report the actual battery capacity supplied by the kernel.
# capacity_sync forces Android to report the actual battery capacity supplied by the kernel.
# The discrepancy is usually detected and corrected automatically by accd.
# This setting overrides the automatic behavior.
# Besides, it also prevents Android from getting capacity readings below 2%, since some systems shutdown before battery level actually drops to 0%.

# capacity_mask (cm) #
# Implies capacity_sync.
# This forces Android to report &quot;capacity = capacity * (100 / pause_capacity)&quot;, effectively masking capacity limits (more like capacity_sync on steroids).
# It also prevents Android from getting capacity readings below 2%, since some systems shutdown before battery level actually drops to 0%.

Expand Down Expand Up @@ -527,7 +532,7 @@ <h2 id="default-configuration">DEFAULT CONFIGURATION</h2>
# If charging switch is set to 3700 (millivolts), acc stops charging by limiting voltage.
# For details, refer to the readme's tips section.
# Unlike the original variant, this kind of switch is never unset automatically.
# Thus, in this case, ppending &quot; --&quot; to it leads to invalid syntax.
# Thus, in this case, appending &quot; --&quot; to it leads to invalid syntax.
# A daemon restart is required after changing this (automated by &quot;acc --set&quot;).

# apply_on_boot (ab) #
Expand Down Expand Up @@ -839,6 +844,7 @@ <h2 id="plugins">PLUGINS</h2>
Hidden files and those without the <code>.sh</code> extension are ignored.</p>
<p>There are also <em>volatile</em> plugins (gone on reboot, useful for debugging): <code>/dev/.vr25/acc/plugins/</code>.
Those override the permanent.</p>
<p>A daemon restart is required to load new/modified plugins.</p>
<hr>
<h2 id="notestips-for-front-end-developers">NOTES/TIPS FOR FRONT-END DEVELOPERS</h2>
<h3 id="basics">Basics</h3>
Expand Down Expand Up @@ -967,11 +973,8 @@ <h3 id="charging-switch">Charging Switch</h3>
<li>Run <code>acc --set charging_switch</code> (or <code>acc -ss</code>) to enforce a working switch.</li>
<li>Test the reliability of the set switch. If it doesn't work properly, try another.</li>
</ol>
<p>Since not everyone is tech savvy, ACC daemon automatically applies certain settings for specific devices (e.g., MediaTek, OnePlus, Razer) to minimize charging switch issues.
<p>Since not everyone is tech savvy, ACC daemon automatically applies settings for certain devices to minimize charging switch issues.
These are are in <code>acc/oem-custom.sh</code>.</p>
<p>Note: as part of the output of <code>acc -ss</code> and <code>acc -ss:</code>, you may see plain numbers alone or in addition to charging switches.
These are presets the current and voltage (3700) based charging control feature.
For details, refer to <a href="#tips">tips</a> section below.</p>
<h3 id="custom-max-charging-voltage-and-current-limits">Custom Max Charging Voltage And Current Limits</h3>
<p>Unfortunately, not all kernels support these features.
While custom current limits are supported by most (at least to some degree), voltage tweaking support is <em>exceptionally</em> rare.</p>
Expand All @@ -991,6 +994,9 @@ <h3 id="custom-max-charging-voltage-and-current-limits">Custom Max Charging Volt
These are simply ignored.</p>
<p>If low current values don't work, try setting <code>current_workaround=true</code> (takes effect after <code>accd --init</code>.
Refer to the <a href="#default-configuration">default configuration</a> section for details.</p>
<p>One can override the default lists of max charging current/voltage control files by copying <code>acc/ctrl-files.sh</code> to <code>/data/adb/vr25/acc-data/plugins/</code> and modifying it accordingly.
Note that default limits must be restored prior to that to avoid the need for a system reboot.
Reminder: a daemon restart is required to load new/modified plugins.</p>
<h3 id="diagnosticslogs">Diagnostics/Logs</h3>
<p>Volatile logs (gone on reboot) are stored in <code>/dev/.vr25/acc/</code> (.log files only).
Persistent logs reside in <code>/data/adb/vr25/acc-data/logs/</code>.</p>
Expand Down Expand Up @@ -1210,6 +1216,7 @@ <h2 id="links">LINKS</h2>
<ul>
<li><a href="https://batteryuniversity.com/article/bu-808-how-to-prolong-lithium-based-batteries/">Must read - how to prolong lithium ion batteries lifespan</a></li>
<li><a href="https://github.com/MatteCarra/AccA/releases/">ACC app</a></li>
<li><a href="https://app.airtm.com/send-or-request/send">Airtm, username: ivandro863auzqg</a></li>
<li><a href="https://github.com/VR-25/djs/">Daily Job Scheduler</a></li>
<li><a href="https://fb.me/vr25xda/">Facebook page</a></li>
<li><a href="https://github.com/VR-25/acc/">Git repository</a></li>
Expand All @@ -1223,15 +1230,6 @@ <h2 id="links">LINKS</h2>
</ul>
<hr>
<h2 id="latest-changes">LATEST CHANGES</h2>
<p><strong>v2021.9.5 (202109050)</strong></p>
<ul>
<li>Additional charging switches (including a group of 3 for OnePlus that allegedly enable idle mode)</li>
<li>Fixed plugins path typo</li>
<li>General fixes</li>
<li>Major optimizations</li>
<li>Support for charging switch groups with unlimited number of elements (e.g., s=&quot;file1 on off file2 on off file3 on off...&quot;)</li>
<li>Use charge_type in addition to status to determine the real battery status.</li>
</ul>
<p><strong>v2021.9.19 (202109190)</strong></p>
<ul>
<li>Additional charging switches - the database is more concise with the extensive use of wildcards.</li>
Expand All @@ -1251,6 +1249,17 @@ <h2 id="latest-changes">LATEST CHANGES</h2>
<li>Manual capacitySync toggle (<code>[capacity_sync|cs] = [true|false]</code>) - it overrides the automatic. Both include the <code>freeze at 2%</code> feature. This is the actual <code>capacity_freeze2</code> replacement now. <code>capacity_mask</code> implies <code>capacity_sync</code>.</li>
<li>Unlike in previous versions, changes to <code>capacity_mask</code> and <code>capacity_sync</code> take effect (within a few seconds) without a daemon restart.</li>
<li>Updated documentation</li>
</ul>
<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>

</body>
Expand Down
53 changes: 28 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ In interactive mode, it also asks the user whether they want to download and ins
```
#DC#
configVerCode=202109200
configVerCode=202110020
capacity=(-1 60 70 75 false false)
temperature=(40 60 90 65)
cooldownRatio=()
Expand Down Expand Up @@ -305,9 +305,13 @@ currentWorkaround=false
# chargingSwitch=charging_switch=(3700)
# applyOnBoot=apply_on_boot=(ctrl_file1::value1::default1 ctrl_file2::value2::default2 ... --exit)
# applyOnBoot=apply_on_boot=(ctrl_file1::value[::default] ctrl_file2::value[::default] ... --exit)
# applyOnPlug=apply_on_plug=(ctrl_file1::value1::default1 ctrl_file2::value2::default2 ...)
# applyOnPlug=apply_on_plug=(ctrl_file1::value[::default] ctrl_file2::value[::default] ...)
# maxChargingCurrent=max_charging_current=([value] ctrl_file1::value::default ctrl_file2::value::default ...)
# maxChargingVoltage=max_charging_voltage=([value] ctrl_file1::value::default ctrl_file2::value::default ...) --exit)
# maxChargingCurrent=max_charging_current=([value] ctrl_file1::value::default1 ctrl_file2::value::default2 ...)
Expand Down Expand Up @@ -412,8 +416,8 @@ currentWorkaround=false
# shutdown_capacity (sc) #
# When the battery is discharging and its capacity/voltage_now_millivolts <= sc and phone has been running for 15 minutes or more, acc daemon turns the phone off to reduce the discharge rate and protect the battery from potential damage induced by voltage below the operating range.
# sc=0 disables it.
# [Beta] if the file /data/adb/vr25/acc-data/warn exists, accd posts Android shutdown warning notifications at sc+10%, sc+5%, sc+300mV and sc+100mV.
# sc=-1 disables it.
# [Beta] if the file /data/adb/vr25/acc-data/warn exists, accd posts Android shutdown warning notifications at sc + 5% or sc + 200 mV.
# cooldown_capacity (cc) #
# Capacity/voltage_now_millivolts at which the cooldown cycle starts.
Expand Down Expand Up @@ -486,7 +490,7 @@ currentWorkaround=false
# If charging switch is set to 3700 (millivolts), acc stops charging by limiting voltage.
# For details, refer to the readme's tips section.
# Unlike the original variant, this kind of switch is never unset automatically.
# Thus, in this case, ppending " --" to it leads to invalid syntax.
# Thus, in this case, appending " --" to it leads to invalid syntax.
# A daemon restart is required after changing this (automated by "acc --set").
# apply_on_boot (ab) #
Expand Down Expand Up @@ -811,6 +815,8 @@ Hidden files and those without the `.sh` extension are ignored.
There are also _volatile_ plugins (gone on reboot, useful for debugging): `/dev/.vr25/acc/plugins/`.
Those override the permanent.

A daemon restart is required to load new/modified plugins.


---
## NOTES/TIPS FOR FRONT-END DEVELOPERS
Expand Down Expand Up @@ -1002,13 +1008,9 @@ Here's how to do it:
2. Run `acc --set charging_switch` (or `acc -ss`) to enforce a working switch.
3. Test the reliability of the set switch. If it doesn't work properly, try another.

Since not everyone is tech savvy, ACC daemon automatically applies certain settings for specific devices (e.g., MediaTek, OnePlus, Razer) to minimize charging switch issues.
Since not everyone is tech savvy, ACC daemon automatically applies settings for certain devices to minimize charging switch issues.
These are are in `acc/oem-custom.sh`.

Note: as part of the output of `acc -ss` and `acc -ss:`, you may see plain numbers alone or in addition to charging switches.
These are presets the current and voltage (3700) based charging control feature.
For details, refer to [tips](#tips) section below.


### Custom Max Charging Voltage And Current Limits

Expand Down Expand Up @@ -1037,6 +1039,10 @@ These are simply ignored.
If low current values don't work, try setting `current_workaround=true` (takes effect after `accd --init`.
Refer to the [default configuration](#default-configuration) section for details.

One can override the default lists of max charging current/voltage control files by copying `acc/ctrl-files.sh` to `/data/adb/vr25/acc-data/plugins/` and modifying it accordingly.
Note that default limits must be restored prior to that to avoid the need for a system reboot.
Reminder: a daemon restart is required to load new/modified plugins.


### Diagnostics/Logs

Expand Down Expand Up @@ -1346,6 +1352,7 @@ A common workaround is having `resume_capacity = pause_capacity - 1`. e.g., resu

- [Must read - how to prolong lithium ion batteries lifespan](https://batteryuniversity.com/article/bu-808-how-to-prolong-lithium-based-batteries/)
- [ACC app](https://github.com/MatteCarra/AccA/releases/)
- [Airtm, username: ivandro863auzqg](https://app.airtm.com/send-or-request/send)
- [Daily Job Scheduler](https://github.com/VR-25/djs/)
- [Facebook page](https://fb.me/vr25xda/)
- [Git repository](https://github.com/VR-25/acc/)
Expand All @@ -1361,19 +1368,7 @@ A common workaround is having `resume_capacity = pause_capacity - 1`. e.g., resu
---
## LATEST CHANGES


**v2021.9.5 (202109050)**

- Additional charging switches (including a group of 3 for OnePlus that allegedly enable idle mode)
- Fixed plugins path typo
- General fixes
- Major optimizations
- Support for charging switch groups with unlimited number of elements (e.g., s="file1 on off file2 on off file3 on off...")
- Use charge_type in addition to status to determine the real battery status.


**v2021.9.19 (202109190)**

- Additional charging switches - the database is more concise with the extensive use of wildcards.
- Battery status detection enhancements
- `capacity_mask=true`: forces Android to report `capacity = capacity * (100 / pause_capacity)`, effectively masking capacity limits. This replaces `capacity_freeze2`.
Expand All @@ -1385,10 +1380,18 @@ A common workaround is having `resume_capacity = pause_capacity - 1`. e.g., resu
- Updated documentation (mainly tips > idle mode and alternatives)
- Upgrade rollback feature (`-b|--rollback` or wizard option `f`)


**v2021.9.20 (202109200)**

- General enhancements
- Manual capacitySync toggle (`[capacity_sync|cs] = [true|false]`) - it overrides the automatic. Both include the `freeze at 2%` feature. This is the actual `capacity_freeze2` replacement now. `capacity_mask` implies `capacity_sync`.
- Unlike in previous versions, changes to `capacity_mask` and `capacity_sync` take effect (within a few seconds) without a daemon restart.
- Updated documentation

**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
6 changes: 6 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ Shutdown warning notifications
printf '\7'
echo 200 > /sys/class/timed_output/vibrator/enable
su -lp 2000 -c "cmd notification post -S bigtext -t 'Title' 'Tag' 'Multiline text'"

current/voltage limits not honored in idle mode?

https://forum.xda-developers.com/t/advanced-charging-controller-acc.3668427/post-85745309
disable fast charging toggle
charge profiles for charger, USB data, USB alternate mode, etc.
8 changes: 4 additions & 4 deletions acc/acc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ edit() {
local file="$1"
shift
if [ -n "${1-}" ]; then
eval "$@ $file"
IFS="$(printf ' \t\n')" eval "$* $file"
else
! ${verbose:-true} || {
case $file in
Expand Down Expand Up @@ -192,7 +192,7 @@ parse_switches() {
i="$(echo "$i $n" | grep -Eiv 'brightness|curr|online|present|runtime|status|temp|volt|wakeup' \
| sed 's|^/.*/power_supply/||')"

if ! grep -q "^$i" $1; then
if [ -n "$i" ] && ! grep -q "^$i" $1; then
echo "$i"
fi

Expand Down Expand Up @@ -293,7 +293,7 @@ case "${1-}" in

[0-9]*)
if [ $1 -gt 3000 ]; then
capacity[2]=${2:-$((${1}-50))}
capacity[2]=${2:-$((${1}-100))}
else
capacity[2]=${2:-$((${1}-5))}
fi
Expand Down Expand Up @@ -349,7 +349,7 @@ case "${1-}" in

pause_capacity=${2:-100}
resume_capacity=$(( pause_capacity - 1 ))
run_cmd_on_pause="exec $TMPDIR/accd"
runCmdOnPause_="exec $TMPDIR/accd"

cp -f $config $TMPDIR/.acc-f-config
config=$TMPDIR/.acc-f-config
Expand Down
Loading

0 comments on commit 5ad7b43

Please sign in to comment.