Skip to content

Commit

Permalink
**2020.3.11-dev (202003110)**
Browse files Browse the repository at this point in the history
- Fixed capacity_sync issues
  • Loading branch information
VR-25 committed Mar 11, 2020
1 parent 71ec89a commit 0c0960f
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 43 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,10 @@ Additionally, `$installDir/acc/acc-init.sh` must be executed on boot to initiali
```
#DC#
configVerCode=202003030
configVerCode=202003110
capacity=(-1 60 70 75 +0 false)
temperature=(70 80 90)
coolDownRatio=()
coolDownCapacity=()
coolDownCurrent=()
coolDownTemp=()
cooldownRatio=()
resetBattStats=(false false)
loopDelay=(10 15)
chargingSwitch=()
Expand All @@ -227,7 +224,7 @@ dynPowerSaving=0
# temperature=(cooldown_temp max_temp max_temp_pause)
# coolDownRatio=(cooldown_charge cooldown_pause)
# cooldownRatio=(cooldown_charge cooldown_pause)
# resetBattStats=(reset_batt_stats_on_pause reset_batt_stats_on_unplug)
Expand Down Expand Up @@ -904,6 +901,9 @@ It's a software (Android/kernel) issue. Use the `capacity_offset` or `capacity_s
---
## LATEST CHANGES

**2020.3.11-dev (202003110)**
- Fixed capacity_sync issues

**2020.3.10-dev (202003100)**
- ACC Wizard: auto-restart after upgrade
- Installer optimizations
Expand Down
6 changes: 5 additions & 1 deletion TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ cooldown
cooldownCurrent=(current charge/pause)
cooldownTemp=(temp charge/pause)

flasher - spaces
capacity_sync inconsistencies
incorrect battery status
dumpsys

auto-shutdown not happening
57 changes: 32 additions & 25 deletions acc/accd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ is_charging() {
if $isCharging; then

# read chgStatusCode once
[ -z "$chgStatusCode" ] \
|| chgStatusCode=$(dumpsys battery 2>/dev/null | sed -n 's/^ status: //p') || :
[ -n "$chgStatusCode" ] || {
dumpsys battery reset \
&& chgStatusCode=$(dumpsys battery 2>/dev/null | sed -n 's/^ status: //p') || :
}

# read charging current ctrl files (part 2) once
! $readChCurr || . $modPath/read-ch-curr-ctrl-files-p2.sh

$coolDown || resetBattStatsOnUnplug=true
$cooldown || resetBattStatsOnUnplug=true
secondsUnplugged=0

$applyOnUnplug || apply_on_plug
Expand All @@ -56,11 +58,13 @@ is_charging() {

else

# read dischgStatusCode once
[ -z "$dischgStatusCode" ] \
|| dischgStatusCode=$(dumpsys battery 2>/dev/null | sed -n 's/^ status: //p') || :
# read chgStatusCode once
[ -n "$dischgStatusCode" ] || {
dumpsys battery reset \
&& dischgStatusCode=$(dumpsys battery 2>/dev/null | sed -n 's/^ status: //p') || :
}

if ! $coolDown; then
if ! $cooldown; then

# applyOnUnplug
if $applyOnUnplug; then
Expand Down Expand Up @@ -104,11 +108,18 @@ is_charging() {
fi

# capacitySync: corrects the battery capacity reported by Android
if ${capacity[5]}; then
($isCharging || chgStatusCode=$dischgStatusCode
$coolDown || dumpsys battery set status $chgStatusCode || :)
! ${capacity[5]} || {
$cooldown || {
if $isCharging; then
dumpsys battery set ac 1 \
&& dumpsys battery set status $chgStatusCode || :
else
dumpsys battery unplug \
&& dumpsys battery set status $dischgStatusCode || :
fi
}
dumpsys battery set level $(cat $batt/capacity) || :
fi > /dev/null 2>&1
}

# log buffer reset
[ $(du -m $log | cut -f 1) -lt 2 ] || : > $log
Expand Down Expand Up @@ -141,7 +152,7 @@ disable_charging() {
exit 7
fi
fi
# if maxTemp is reached, pause charging regardless of coolDownRatio
# if maxTemp is reached, pause charging regardless of cooldownRatio
! is_charging && [ $(( $(cat $batt/temp 2>/dev/null \
|| cat $batt/batt_temp) / 10 )) -ge ${temperature[1]} ] \
&& sleep ${temperature[2]} || :
Expand Down Expand Up @@ -229,27 +240,23 @@ ctrl_charging() {
fi

if [ ! -f ${config%/*}/.rebootedOnPause ]; then
# cool down
while [ -n "${coolDownRatio[0]:-}" ] && [ $(( ${capacity[3]} - ${capacity[2]} )) -gt 2 ] \
# cooldown
while [ -n "${cooldownRatio[0]:-}" ] && [ $(( ${capacity[3]} - ${capacity[2]} )) -gt 2 ] \
&& is_charging && [ $(( $(cat $batt/capacity) ${capacity[4]} )) -lt ${capacity[3]} ] \
&& [ $(( $(cat $batt/temp 2>/dev/null || cat $batt/batt_temp) / 10 )) -lt ${temperature[1]} ]
do
coolDown=true
cooldown=true
if [ $(( $(cat $batt/temp 2>/dev/null || cat $batt/batt_temp) / 10 )) -ge ${temperature[0]} ] \
|| [ $(( $(cat $batt/capacity) ${capacity[4]} )) -ge ${capacity[1]} ]
then
dumpsys battery set status $chgStatusCode || :
dumpsys battery set status $chgStatusCode || : # to block unwanted display wakeups
disable_charging
sleep ${coolDownRatio[1]:-1}
sleep ${cooldownRatio[1]:-1}
enable_charging
if ${capacity[5]}; then
dumpsys battery set status $chgStatusCode || :
else
dumpsys battery reset || :
fi
${capacity[5]} || dumpsys battery reset || :
count=0
while ! grep -Eiq 'dis|not' $batt/status \
&& [ $count -lt ${coolDownRatio[0]:-1} ]
&& [ $count -lt ${cooldownRatio[0]:-1} ]
do
sleep ${loopDelay[0]}
[ $(( $(cat $batt/capacity) ${capacity[4]} )) -lt ${capacity[3]} ] \
Expand All @@ -260,7 +267,7 @@ ctrl_charging() {
break
fi
done
coolDown=false
cooldown=false
fi

else
Expand Down Expand Up @@ -292,7 +299,7 @@ ctrl_charging() {


umask 077
coolDown=false
cooldown=false
hibernate=true
readChCurr=true
chgStatusCode=""
Expand Down
9 changes: 3 additions & 6 deletions acc/default-config.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
configVerCode=202003030
configVerCode=202003110
capacity=(-1 60 70 75 +0 false)
temperature=(70 80 90)
coolDownRatio=()
coolDownCapacity=()
coolDownCurrent=()
coolDownTemp=()
cooldownRatio=()
resetBattStats=(false false)
loopDelay=(10 15)
chargingSwitch=()
Expand All @@ -28,7 +25,7 @@ dynPowerSaving=0

# temperature=(cooldown_temp max_temp max_temp_pause)

# coolDownRatio=(cooldown_charge cooldown_pause)
# cooldownRatio=(cooldown_charge cooldown_pause)

# resetBattStats=(reset_batt_stats_on_pause reset_batt_stats_on_unplug)

Expand Down
6 changes: 6 additions & 0 deletions acc/oem-custom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,10 @@ fi

# block ghost charging on steroids (Xiaomi Redmi 3 - ido)
[ ! -f $TMPDIR/accd-ido.log ] || touch $TMPDIR/.ghost-charging

# 202003110, patch config, /coolDown/cooldown
! _grep coolDown || {
set_prop configVerCode 202003110
sed -i 's/coolDown/cooldown/' $config
}
)
4 changes: 2 additions & 2 deletions acc/print-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ cooldown_temp=${temperature[0]}
max_temp=${temperature[1]}
max_temp_pause=${temperature[2]}
cooldown_charge=${coolDownRatio[0]}
cooldown_pause=${coolDownRatio[1]}
cooldown_charge=${cooldownRatio[0]}
cooldown_pause=${cooldownRatio[1]}
reset_batt_stats_on_pause=${resetBattStats[0]}
reset_batt_stats_on_unplug=${resetBattStats[1]}
Expand Down
2 changes: 1 addition & 1 deletion acc/write-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set +u
echo "configVerCode=$(cat $TMPDIR/.default-config-ver)
capacity=(${shutdown_capacity-${sc-${capacity[0]}}} ${cooldown_capacity-${cc-${capacity[1]}}} ${resume_capacity-${rc-${capacity[2]}}} ${pause_capacity-${pc-${capacity[3]}}} ${capacity_offset-${co-${capacity[4]}}} ${capacity_sync-${cs-${capacity[5]}}})
temperature=(${cooldown_temp-${ct-${temperature[0]}}} ${max_temp-${mt-${temperature[1]}}} ${max_temp_pause-${mtp-${temperature[2]}}})
coolDownRatio=(${cooldown_charge-${cch-${coolDownRatio[0]}}} ${cooldown_pause-${cp-${coolDownRatio[1]}}})
cooldownRatio=(${cooldown_charge-${cch-${cooldownRatio[0]}}} ${cooldown_pause-${cp-${cooldownRatio[1]}}})
resetBattStats=(${reset_batt_stats_on_pause-${rbsp-${resetBattStats[0]}}} ${reset_batt_stats_on_unplug-${rbsu-${resetBattStats[1]}}})
loopDelay=(${loop_delay_charging-${ldc-${loopDelay[0]}}} ${loop_delay_discharging-${ldd-${loopDelay[1]}}})
chargingSwitch=(${charging_switch-${s-${chargingSwitch[@]}}})
Expand Down
4 changes: 2 additions & 2 deletions module.prop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id=acc
name=Advanced Charging Controller (ACC)
version=2020.3.10-dev
versionCode=202003100
version=2020.3.11-dev
versionCode=202003110
author=VR25 (patreon.com/vr25)
description=ACC is an Android software. It's primarily intended for extending battery service life. In a nutshell, this is achieved through limiting charging current, temperature and voltage. Any root solution is supported. A recent stable Magisk version is recommended. If you're reading this from Magisk Manager > Downloads, tap here to open the documentation. Once there, if you're lazy, jump to the quick start section.

0 comments on commit 0c0960f

Please sign in to comment.