diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary index 6905175..f5ae00a 100644 --- a/META-INF/com/google/android/update-binary +++ b/META-INF/com/google/android/update-binary @@ -1,6 +1,6 @@ #!/system/bin/sh # ACC Installer/Upgrader -# Copyright (c) 2019-2020, VR25 (xda-developers) +# Copyright 2019-2020, VR25 (xda-developers) # License: GPLv3+ # # devs: triple hashtags (###) mark non-generic code @@ -175,8 +175,8 @@ if $acca; then echo "#!/system/bin/sh # AccA post-uninstall cleanup script - until test -d /sdcard/?ndroid \\ - -a .\$(getprop sys.boot_completed) == .1 + until test -d /data/data \\ + && test .\$(getprop sys.boot_completed) = .1 do sleep 60 done @@ -192,7 +192,7 @@ if $acca; then fi -[ $installDir == /data/adb/$id ] || ln -s $installDir /data/adb/ +[ $installDir = /data/adb/$id ] || ln -s $installDir /data/adb/ # restore config backup @@ -258,7 +258,7 @@ echo " - Daemon started." -[ $installDir == /data/adb ] && echo " +[ $installDir = /data/adb ] && echo " (i) Non-Magisk users can enable $id auto-start by running /data/adb/$id/service.sh, a copy of, or a link to it - with init.d or an app that emulates it." diff --git a/README.md b/README.md index ca98604..061ef99 100644 --- a/README.md +++ b/README.md @@ -185,9 +185,9 @@ In interactive mode, it also asks the user whether they want to download and ins ``` #DC# -configVerCode=202006080 -capacity=(-1 101 70 75 false) -temperature=(70 80 90) +configVerCode=202007170 +capacity=(-1 60 70 75 false) +temperature=(40 60 90) cooldownRatio=() cooldownCustom=() resetBattStats=(false false) @@ -204,7 +204,6 @@ wakeUnlock=() prioritizeBattIdleMode=true forceChargingStatusFullAt100= runCmdOnPause=() -dynPowerSaving=0 autoShutdownAlertCmd=(vibrate 5 0.1) chargDisabledNotifCmd=(vibrate 3 0.1) chargEnabledNotifCmd=(vibrate 4 0.1) @@ -265,8 +264,6 @@ loopCmd=() # runCmdOnPause=run_cmd_on_pause=(. script) -# dynPowerSaving=dyn_power_saving=seconds - # autoShutdownAlertCmd=auto_shutdown_alert_cmd=(. script) # chargDisabledNotifCmd=charg_disabled_notif_cmd=(. script) @@ -322,7 +319,6 @@ loopCmd=() # pbim prioritize_batt_idle_mode # ff force_charging_status_full_at_100 # rcp run_cmd_on_pause -# dps dyn_power_saving # asac auto_shutdown_alert_cmd # cdnc charg_disabled_notif_cmd @@ -343,7 +339,7 @@ loopCmd=() # acc --set pause_capacity=85 resume_capacity=80 # acc -s "s=battery/charging_enabled 1 0" -# acc --set "charging_switch=/proc/mtk_battery_cmd/current_cmd 0::0 0::1 /proc/mtk_battery_cmd/en_power_path 1 0" ("::" == " ") +# acc --set "charging_switch=/proc/mtk_battery_cmd/current_cmd 0::0 0::1 /proc/mtk_battery_cmd/en_power_path 1 0" ("::" = " ") # acc -s sd=5 # acc -s switch_delay=5 @@ -457,7 +453,7 @@ loopCmd=() # If this doesn't make sense to you, you probably don't need it. # Essentially, this is a timeout (seconds) before rebooting - after pausing charging. # This reboot is a workaround for a firmware issue that causes abnormally fast battery drain after charging is paused on certain devices. -# The issue has reportedly been fixed by the OEMs. This setting will eventually be removed. +# The issue has reportedly been fixed by the OEMs. This feature will eventually be removed. # switch_delay (sd) # # This is a delay (seconds) between charging status checks after toggling charging switches. It exists because some switches don't react immediately after being toggled. @@ -489,11 +485,6 @@ loopCmd=() # Run commands* after pausing charging. # * Usually a script ("sh some_file" or ". some_file") -# dyn_power_saving (dps) # -# This is the maximum number of seconds accd will dynamically sleep* for (while unplugged) to save resources. -# If dyn_power_saving == 0, the feature is disabled. -# * On top of loop_delay_discharging - # auto_shutdown_alert_cmd (asac) # # charg_disabled_notif_cmd (cdnc) # # charg_enabled_notif_cmd (cenc) # @@ -1153,6 +1144,16 @@ A common workaround is having `resume_capacity = pause_capacity - 1`. e.g., resu --- ## LATEST CHANGES +**v2020.7.19 (202007190)** +- accd stop timeout set to 15 seconds (more time for graceful termination). +- Do not remount /sbin/. +- Faster accd termination +- Fixed "--upgrade not recognizing the latest version is already installed". +- Fixed "max_temp_pause not honored". +- General optimizations +- Minor changes to default config, for convenience +- Note: config will be reset to fix the accd crash issue several users have been facing. + **v2020.7.3 (202007030)** - Blacklisted problematic MTK charging switch. - Fixed "battery saver mode can't be turned off". @@ -1163,7 +1164,3 @@ A common workaround is having `resume_capacity = pause_capacity - 1`. e.g., resu **v2020.6.16 (202006160)** - Magisk related fixes - -**v2020.6.15.2 (202006152)** -- Fixed Magisk related issues -- General fixes & optimizations diff --git a/TODO.txt b/TODO.txt index fa28497..b9d9638 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,26 +1,10 @@ -cooldown - cooldownTemp=(min_temp charge_seconds pause_seconds max_temp max_temp_pause) - cooldownCapacity=(capacity charge_seconds pause_seconds) - -# getval index $var -getval() { - local index=$1 - shift - eval "echo \$$index" -} - -# setval index val var -setval() { - local val_=$1 val="$2" values="" var=$3 - shift 3 - values="$(eval "echo \$$var")" - val_="$(getval $val_ $values)" - eval $var=\""${values/$val_/$val}"\" -} - install.sh upgrade acc_bundle.tar.gz and install-tarball.sh remove "# legacy" -acc -u +review automatic switch setting + switch being reset for invalid reasons? + +sometimes, battery % gets stuck if capacity_freeze2 is enabled + stuck in a wait_plug loop? diff --git a/acc/acc.sh b/acc/acc.sh index 2ee9457..09e8738 100644 --- a/acc/acc.sh +++ b/acc/acc.sh @@ -1,6 +1,6 @@ #!/system/bin/sh # Advanced Charging Controller -# Copyright (c) 2017-2020, VR25 (xda-developers) +# Copyright 2017-2020, VR25 (xda-developers) # License: GPLv3+ @@ -124,14 +124,15 @@ exxit() { local exitCode=$? set +eux ! ${noEcho:-false} && ${verbose:-true} && echo - [[ $exitCode == [05689] ]] || { - [[ $exitCode == [127] || $exitCode == 10 ]] && { + [[ $exitCode = [05689] ]] || { + [[ $exitCode = [127] || $exitCode = 10 ]] && { logf --export eval "${errorAlertCmd[@]-}" } echo } rm /dev/.acc-config 2>/dev/null + cd / exit $exitCode } @@ -282,7 +283,7 @@ case "${1-}" in dsys="$(dumpsys battery)" - { if [[ "$dsys" == *reset* ]] > /dev/null; then + { if [[ "$dsys" = *reset* ]] > /dev/null; then status=$(echo "$dsys" | sed -n 's/^ status: //p') level=$(echo "$dsys" | sed -n 's/^ level: //p') powered=$(echo "$dsys" | grep ' powered: true' > /dev/null && echo true || echo false) @@ -440,31 +441,24 @@ case "${1-}" in -u|--upgrade) + shift - local reference="" + local reference=$(echo "$*" | sed -E 's/-c|--changelog|-f|--force|-k|--insecure|-n|--non-interactive| //g') - case "$@" in - *beta*|*dev*|*rc\ *|*\ rc*) - reference=dev - ;; - *master*|*stable*) - reference=master - ;; - *) - grep -Eq '^version=.*-(beta|rc)' $execDir/module.prop \ - && reference=dev \ - || reference=master - ;; - esac + test -n "$reference" || { + grep -Eq '^version=.*-(beta|rc)' $execDir/module.prop \ + && reference=dev \ + || reference=master + } - case "$@" in + case "$*" in *--insecure*|*-k*) insecure=--insecure;; *) insecure=;; esac - [ ! -f /data/adb/bin/curl ] || { - [ -x /data/adb/bin/curl ] || chmod -R 0700 /data/adb/bin - export curlPath=true PATH=/data/adb/bin:$PATH + ! test -f /data/adb/bin/curl || { + test -x /data/adb/bin/curl \ + || chmod -R 0700 /data/adb/bin } curl $insecure -Lo $TMPDIR/install-online.sh https://raw.githubusercontent.com/VR-25/acc/$reference/install-online.sh diff --git a/acc/acca.sh b/acc/acca.sh index 452544a..ed1bd6b 100644 --- a/acc/acca.sh +++ b/acc/acca.sh @@ -100,12 +100,12 @@ case "$@" in ;; esac - [ .${mcc-${max_charging_current-x}} == .x ] || { + [ .${mcc-${max_charging_current-x}} = .x ] || { . ./set-ch-curr.sh set_ch_curr ${mcc:-${max_charging_current:--}} || : } - [ .${mcv-${max_charging_voltage-x}} == .x ] || { + [ .${mcv-${max_charging_voltage-x}} = .x ] || { . ./set-ch-volt.sh set_ch_volt ${mcv:-${max_charging_voltage:--}} || : } @@ -117,7 +117,7 @@ case "$@" in # print default config -s\ d*|-s\ --print-default*|--set\ d*|--set\ --print-default*|-sd*) - [ $1 == -sd ] && shift || shift 2 + [ $1 = -sd ] && shift || shift 2 . $defaultConfig . ./print-config.sh | grep -E "${1:-...}" || : exit 0 @@ -125,7 +125,7 @@ case "$@" in # print current config -s\ p*|-s\ --print|-s\ --print\ *|--set\ p|--set\ --print|--set\ --print\ *|-sp*) - [ $1 == -sp ] && shift || shift 2 + [ $1 = -sp ] && shift || shift 2 . $config . ./print-config.sh | grep -E "${1:-...}" || : exit 0 diff --git a/acc/accd.sh b/acc/accd.sh index d9a0895..67af216 100644 --- a/acc/accd.sh +++ b/acc/accd.sh @@ -1,32 +1,20 @@ #!/system/bin/sh # Advanced Charging Controller Daemon (accd) -# Copyright (c) 2017-2020, VR25 (xda-developers) +# Copyright 2017-2020, VR25 (xda-developers) # License: GPLv3+ # # devs: triple hashtags (###) mark non-generic code -# wait until the system is ready -pgrep -fl zygote > /dev/null && { - until test -d /sdcard/?ndroid -a -d /data/data/com.android.providers.media \ - -a .$(getprop sys.boot_completed) == .1 \ - && dumpsys battery > /dev/null 2>&1 -do - sleep 10 - done -} - - umask 0077 . $execDir/acquire-lock.sh + case "$1" in -i|--init) init=true; shift;; - *) init=false + *) test -f $TMPDIR/.config-ver && init=false || init=true;; esac -which ${id}d > /dev/null || init=true - if [ -f $TMPDIR/ch-switches ] && ! $init; then ### @@ -34,6 +22,7 @@ if [ -f $TMPDIR/ch-switches ] && ! $init; then ### local exitCode=$? set +eux trap - EXIT + vibrate() { :; } { dumpsys battery reset & cp $config /dev/.${id}-config config=/dev/.${id}-config @@ -43,14 +32,14 @@ if [ -f $TMPDIR/ch-switches ] && ! $init; then ### } > /dev/null 2>&1 [ -n "$1" ] && exitCode=$1 [ -n "$2" ] && print "$2" - echo "***EXIT $exitCode***" - [[ $exitCode == [127] ]] && { + [[ $exitCode = [127] ]] && { . $execDir/logf.sh logf --export > /dev/null 2>&1 & eval "${errorAlertCmd[@]-}" & } wait rm $config 2>/dev/null + cd / exit $exitCode } @@ -69,7 +58,6 @@ if [ -f $TMPDIR/ch-switches ] && ! $init; then ### if $isCharging; then # reset auto-shutdown warning thresholds - #lowPower=false warningThresholds=$_warningThresholds # read chgStatusCode once @@ -153,7 +141,7 @@ if [ -f $TMPDIR/ch-switches ] && ! $init; then ### && dumpsys battery set status $dischgStatusCode || : fi } - if ! [ ${capacity[4]} == true -a $(cat $batt/capacity) -lt 2 ]; then + if ! [ ${capacity[4]} = true -a $(cat $batt/capacity) -lt 2 ]; then dumpsys battery set level $(cat $batt/capacity) || : fi } @@ -178,9 +166,9 @@ if [ -f $TMPDIR/ch-switches ] && ! $init; then ### || rm ${config%/*}/.rebootedOnPause 2>/dev/null || : # disable charging under - if [ $(cat $batt/temp 2>/dev/null || cat $batt/batt_temp) -ge $(( ${temperature[1]} * 10 )) ] \ - || [ $(cat $batt/capacity) -ge ${capacity[3]} ] - then + test $(cat $batt/temp 2>/dev/null || cat $batt/batt_temp) -ge $(( ${temperature[1]} * 10 )) \ + && maxTempPause=true || maxTempPause=false + if $maxTempPause || test $(cat $batt/capacity) -ge ${capacity[3]}; then [ -f ${config%/*}/.rebootedOnPause ] || { disable_charging ! ${resetBattStats[0]} || { @@ -209,6 +197,8 @@ if [ -f $TMPDIR/ch-switches ] && ! $init; then ### } fi + ! $maxTempPause || sleep ${temperature[2]} + [ -f ${config%/*}/.rebootedOnPause ] || { # cooldown cycle @@ -261,15 +251,12 @@ if [ -f $TMPDIR/ch-switches ] && ! $init; then ### [ $c -ne $i ] || { eval "${autoShutdownAlertCmd[@]-}" warningThresholds=${warningThresholds/$i} - # $lowPower || { - # ! settings put global low_power 1 || lowPower=true - # } } done unset i c # auto-shutdown if battery is not charging and capacity is less than - [ ! $(cat $batt/capacity) -le ${capacity[0]} ] || { + ! test $(cat $batt/capacity) -le ${capacity[0]} || { sleep ${loopDelay[1]} ! not_charging \ || am start -n android/com.android.internal.app.ShutdownActivity < /dev/null > /dev/null 2>&1 \ @@ -292,7 +279,6 @@ if [ -f $TMPDIR/ch-switches ] && ! $init; then ### isAccd=true cooldown=false hibernate=true - #lowPower=false readChCurr=true chgStatusCode="" capacitySync=false @@ -308,7 +294,6 @@ if [ -f $TMPDIR/ch-switches ] && ! $init; then ### # verbose echo "###$(date)###" >> $log echo "versionCode=$(sed -n s/versionCode=//p $execDir/module.prop 2>/dev/null)" >> $log - export PS4='[${EPOCHREALTIME:-+}] ' exec >> $log 2>&1 set -x @@ -330,6 +315,17 @@ if [ -f $TMPDIR/ch-switches ] && ! $init; then ### apply_on_boot + + # wait until the system is ready + pgrep -fl zygote > /dev/null && { + until test -d /data/data \ + && test .$(getprop sys.boot_completed) = .1 \ + && dumpsys battery > /dev/null 2>&1 + do + sleep 10 + done + } + ctrl_charging exit $? @@ -351,15 +347,11 @@ else ln -fs $execDir/${id}a.sh /dev/${id}a ln -fs $execDir/service.sh /dev/${id}d - [ -d /sbin ] && { - /system/bin/mount -o remount,rw / 2>/dev/null \ - || mount -o remount,rw / - for h in /dev/$id /dev/${id}d, /dev/${id}d. \ - /dev/${id}a /dev/${id}d - do - ln -fs $h /sbin/ - done - } + for h in /dev/$id /dev/${id}d, /dev/${id}d. \ + /dev/${id}a /dev/${id}d + do + ln -fs $h /sbin/ 2>/dev/null || break + done # fix Termux's PATH (missing /sbin/) @@ -459,7 +451,7 @@ else # start $id daemon rm /dev/.$id/.ghost-charging 2>/dev/null ### - exec $0 "$1" + exec $0 "$@" fi exit 0 diff --git a/acc/charging-switches.txt b/acc/charging-switches.txt index 779867c..9a64d74 100644 --- a/acc/charging-switches.txt +++ b/acc/charging-switches.txt @@ -1,8 +1,8 @@ # ACC Charging Switches Database -# Copyright (c) 2017-2020, VR25 (xda-developers) +# Copyright 2017-2020, VR25 (xda-developers) # License: GPLv3+ # -# "::" == " " +# "::" = " " # PWD=/sys/class/power_supply # Last updated: Thu, Jul 2, 2020 diff --git a/acc/default-config.txt b/acc/default-config.txt index caf4227..92b6601 100644 --- a/acc/default-config.txt +++ b/acc/default-config.txt @@ -1,6 +1,6 @@ -configVerCode=202006150 -capacity=(-1 101 70 75 false) -temperature=(70 80 90) +configVerCode=202007170 +capacity=(-1 60 70 75 false) +temperature=(40 60 90) cooldownRatio=() cooldownCustom=() resetBattStats=(false false) @@ -152,7 +152,7 @@ loopCmd=() # acc --set pause_capacity=85 resume_capacity=80 # acc -s "s=battery/charging_enabled 1 0" -# acc --set "charging_switch=/proc/mtk_battery_cmd/current_cmd 0::0 0::1 /proc/mtk_battery_cmd/en_power_path 1 0" ("::" == " ") +# acc --set "charging_switch=/proc/mtk_battery_cmd/current_cmd 0::0 0::1 /proc/mtk_battery_cmd/en_power_path 1 0" ("::" = " ") # acc -s sd=5 # acc -s switch_delay=5 diff --git a/acc/flash-zips.sh b/acc/flash-zips.sh index 69ffdb0..0e91337 100644 --- a/acc/flash-zips.sh +++ b/acc/flash-zips.sh @@ -1,6 +1,6 @@ #!/dev/.busybox/ash # Universal shell-based-zip flasher -# Copyright (c) 2020, VR25 (xda-developers) +# Copyright 2020, VR25 (xda-developers) # License: GPLv3+ # # usage: $0 or $0 "file1 file2 ..." @@ -22,17 +22,17 @@ pick_zips() { echo print -n "Add more zips to the queue: a\nStart flashing: [enter]\nExit: CTRL-C\n> " read -n1 target - [ "$target" == a ] && pick_zips . + [ "$target" = a ] && pick_zips . elif [ -d "$target" ]; then echo pick_zips "$target" - elif [ "$target" == "" ]; then + elif [ "$target" = "" ]; then cd .. echo pick_zips . - elif [ "$target" == "" ]; then + elif [ "$target" = "" ]; then exit 0 - elif [ "$target" == "" ]; then + elif [ "$target" = "" ]; then echo -n "> " read target cd "${target:-.}" @@ -87,7 +87,7 @@ for zipFile in $zipFiles; do unzip -o "${zipFile//__/ }" 'META-INF/*' -d /dev/.install-zip >&2 && { $noClear && echo || clear echo - sh /dev/.install-zip/META-INF/*/*/*/update-binary dummy 1 "${zipFile//__/ }" # $3 == outfd + sh /dev/.install-zip/META-INF/*/*/*/update-binary dummy 1 "${zipFile//__/ }" # $3 = outfd } # on failure: next or abort diff --git a/acc/logf.sh b/acc/logf.sh index eb67bf8..250887d 100644 --- a/acc/logf.sh +++ b/acc/logf.sh @@ -1,6 +1,6 @@ logf() { - if [[ "${1:-x}" == -*e* ]]; then + if [[ "${1:-x}" = -*e* ]]; then exec 2>> ${log:-/dev/null} cd $TMPDIR @@ -35,7 +35,7 @@ logf() { echo "(i) /sdcard/acc-logs-$device.tar.gz" else - if [[ "${1:-x}" == -*a* ]]; then + if [[ "${1:-x}" = -*a* ]]; then shift edit $log "$@" else diff --git a/acc/misc-functions.sh b/acc/misc-functions.sh index a7bc4ef..6865bc0 100644 --- a/acc/misc-functions.sh +++ b/acc/misc-functions.sh @@ -15,7 +15,7 @@ apply_on_boot() { [ -f "$file" ] && chmod u+w $file && run_xtimes "echo \$$arg > $file" || : done - $exitCmd && [ $arg == value ] && exit 0 || : + $exitCmd && [ $arg = value ] && exit 0 || : } @@ -96,7 +96,7 @@ disable_charging() { apply_on_plug default fi - if [[ "${chargingSwitch[0]-}" == */* ]]; then + if [[ "${chargingSwitch[0]-}" = */* ]]; then if [ -f ${chargingSwitch[0]} ]; then # toggle primary switch if chmod u+w ${chargingSwitch[0]} && run_xtimes "echo ${chargingSwitch[2]//::/ } > ${chargingSwitch[0]}"; then @@ -178,10 +178,10 @@ enable_charging() { ! $isAccd || not_charging || return 0 - if ! $ghostCharging || { $ghostCharging && [[ $(cat */online) == *1* ]]; }; then + if ! $ghostCharging || { $ghostCharging && [[ $(cat */online) = *1* ]]; }; then $isAccd || { - [ "${2-}" == noap ] || apply_on_plug + [ "${2-}" = noap ] || apply_on_plug } chmod u+w ${chargingSwitch[0]-} ${chargingSwitch[3]-} 2>/dev/null \ @@ -292,7 +292,7 @@ unset_switch() { vibrate() { - [ $1 != "-" -a $isAccd == false ] || return 0 + [ $1 != "-" -a $isAccd = false ] || return 0 local count=0 for count in $(seq $1); do ${fd3-false} && print -n '\a' >&3 || print -n '\a' || : @@ -337,9 +337,10 @@ cd /sys/class/power_supply/ for batt in $(ls */uevent); do chmod u+r $batt \ - && grep -q '^POWER_SUPPLY_CAPACITY=' $batt \ - && grep -q '^POWER_SUPPLY_STATUS=' $batt \ - && batt=${batt%/*} && break + && grep -q '^POWER_SUPPLY_CAPACITY=' $batt \ + && grep -q '^POWER_SUPPLY_STATUS=' $batt \ + && batt=${batt%/*} \ + && break done 2>/dev/null || : # dumpsys wrapper for Termux diff --git a/acc/oem-custom.sh b/acc/oem-custom.sh index c492ad9..b7af270 100644 --- a/acc/oem-custom.sh +++ b/acc/oem-custom.sh @@ -9,19 +9,16 @@ set_prop_() { sed -i "\|^${1}=|s|=.*|=$2|" ${3:-$config}; } # patch/reset [broken/obsolete] config configVer=0$(get_prop configVerCode 2>/dev/null || :) defaultConfVer=$(get_prop configVerCode $execDir/default-config.txt) -if (set +x; . $config) > /dev/null 2>&1 \ - && ! grep_ '^dynPowerSaving=120|^versionCode=|^(capacity|loopDelay)=.*,|^temperature=.*-' -then +if (set +x; . $config) > /dev/null 2>&1; then [ $configVer -eq $defaultConfVer ] || { - if [ $configVer -lt 202005170 ]; then - /dev/acca --set ctrl_file_writes= + if [ $configVer -lt 202007170 ]; then + cp -f $execDir/default-config.txt $config else /dev/acca --set dummy= fi } else cp -f $execDir/default-config.txt $config - rm /sdcard/acc-logs-*.tar.bz2 || : ### legacy fi 2>/dev/null diff --git a/acc/power-supply-logger.sh b/acc/power-supply-logger.sh index b13beac..0235190 100644 --- a/acc/power-supply-logger.sh +++ b/acc/power-supply-logger.sh @@ -1,6 +1,6 @@ #!/system/bin/sh # Advanced Charging Controller Power Supply Logger -# Copyright (c) 2019-2020, VR25 (xda-developers) +# Copyright 2019-2020, VR25 (xda-developers) # License: GPLv3+ diff --git a/acc/release-lock.sh b/acc/release-lock.sh index 84e0dbd..5277736 100644 --- a/acc/release-lock.sh +++ b/acc/release-lock.sh @@ -5,5 +5,5 @@ set +o sh 2>/dev/null || : flock -n 0 || { read pid kill $pid - timeout 6 flock 0 || kill -KILL $pid + timeout 15 flock 0 || kill -KILL $pid }) <>$TMPDIR/${id}.lock diff --git a/acc/set-ch-curr.sh b/acc/set-ch-curr.sh index 83d25ac..c140921 100644 --- a/acc/set-ch-curr.sh +++ b/acc/set-ch-curr.sh @@ -31,7 +31,7 @@ set_ch_curr() { if [ -n "${1-}" ]; then # restore - if [ $1 == - ]; then + if [ $1 = - ]; then apply_on_plug default max_charging_current= ! ${verbose:-true} || print_curr_restored diff --git a/acc/set-ch-volt.sh b/acc/set-ch-volt.sh index 7273d3b..af39c16 100644 --- a/acc/set-ch-volt.sh +++ b/acc/set-ch-volt.sh @@ -9,7 +9,7 @@ set_ch_volt() { } # restore - if [ $1 == - ]; then + if [ $1 = - ]; then apply_on_boot default force max_charging_voltage= ! ${verbose:-true} || print_volt_restored @@ -25,7 +25,7 @@ set_ch_volt() { } || return 1 } - # == [3700-4200] millivolts + # = [3700-4200] millivolts if [ $1 -ge 3700 -a $1 -le 4200 ]; then apply_voltage $1 ${2-} || return 1 diff --git a/acc/set-prop.sh b/acc/set-prop.sh index 6cd268c..240496c 100644 --- a/acc/set-prop.sh +++ b/acc/set-prop.sh @@ -27,12 +27,12 @@ set_prop() { ;; esac - [ .${mcc-${max_charging_current-x}} == .x ] || { + [ .${mcc-${max_charging_current-x}} = .x ] || { . $execDir/set-ch-curr.sh set_ch_curr ${mcc:-${max_charging_current:--}} || : } - [ .${mcv-${max_charging_voltage-x}} == .x ] || { + [ .${mcv-${max_charging_voltage-x}} = .x ] || { . $execDir/set-ch-volt.sh set_ch_volt ${mcv:-${max_charging_voltage:--}} || : } diff --git a/acc/setup-busybox.sh b/acc/setup-busybox.sh index 213a691..4c73afb 100644 --- a/acc/setup-busybox.sh +++ b/acc/setup-busybox.sh @@ -1,5 +1,5 @@ # Busybox Setup -# Copyright (c) 2019-2020, VR25 (xda-developers) +# Copyright 2019-2020, VR25 (xda-developers) # License: GPLv3+ # # Usage: . $0 diff --git a/acc/strings.sh b/acc/strings.sh index fecab0f..cba0426 100644 --- a/acc/strings.sh +++ b/acc/strings.sh @@ -255,10 +255,10 @@ Options -u|--upgrade [-c|--changelog] [-f|--force] [-k|--insecure] [-n|--non-interactive] Online upgrade/downgrade (requires curl) e.g., - acc -u beta (upgrade to the latest beta version) + acc -u dev (upgrade to the latest dev version) acc -u (latest version from the current branch) - acc -u stable^1 -f (previous stable release) - acc -u -f beta^2 (two dev versions below the latest beta) + acc -u master^1 -f (previous stable release) + acc -u -f dev^2 (two dev versions below the latest dev) acc -u v2020.4.8-beta --force (force upgrade/downgrade to v2020.4.8-beta) acc -u -c -n (if update is available, prints version code (integer) and changelog link) acc -u -c (same as above, but with install prompt) diff --git a/acc/uninstall.sh b/acc/uninstall.sh index c21470b..527a431 100644 --- a/acc/uninstall.sh +++ b/acc/uninstall.sh @@ -1,7 +1,7 @@ #!/system/bin/sh # $id uninstaller # id is set/corrected by build.sh -# Copyright (c) 2019-2020, VR25 (xda-developers) +# Copyright 2019-2020, VR25 (xda-developers) # License: GPLv3+ # # devs: triple hashtags (###) mark non-generic code @@ -42,12 +42,12 @@ mkdir -p $TMPDIR/$id (flock -n 0 || { read pid kill $pid - timeout 6 flock 0 || kill -KILL $pid + timeout 15 flock 0 || kill -KILL $pid }) <>$TMPDIR/${id}.lock ### pgrep -f "/($id|${id}a) (-|--)[det]|/${id}d" > /dev/null && { # legacy pkill -f "/($id|${id}a) (-|--)[det]|/${id}d" - for count in $(seq 6); do + for count in $(seq 15); do sleep 1 [ -z "$(pgrep -f "/($id|${id}a) (-|--)[det]|/${id}d")" ] && break done @@ -63,7 +63,7 @@ rm -rf $(readlink -f /data/adb/$id) \ /data/media/0/${id}-logs-*.tar.* \ /data/data/mattecarra.accapp/files/$id \ /data/data/com.termux/files/home/.termux/boot/${id}-init.sh \ - $([ "${1:-}" == install ] || echo "/data/adb/${id}-data") + $(test "${1:-}" = install || echo "/data/adb/${id}-data /data/media/0/.${id}-config-backup.txt") # remove flashable uninstaller rm ${3:-/data/media/0/${id}-uninstaller.zip} diff --git a/acc/write-config.sh b/acc/write-config.sh index bc2c876..49207d2 100644 --- a/acc/write-config.sh +++ b/acc/write-config.sh @@ -60,8 +60,8 @@ lc="${loop_cmd-${lc-${loopCmd[@]}}}" { echo "configVerCode=$(cat $TMPDIR/.config-ver) -capacity=(${sc:--1} ${cc:-101} ${rc:-70} ${pc:-75} ${cft:-false}) -temperature=(${ct:-70} ${mt:-80} ${mtp:-90}) +capacity=(${sc:--1} ${cc:-60} ${rc:-70} ${pc:-75} ${cft:-false}) +temperature=(${ct:-40} ${mt:-60} ${mtp:-90}) cooldownRatio=($cch $cp) cooldownCustom=($ccu) resetBattStats=(${rbsp:-false} ${rbsu:-false}) diff --git a/bin/acc-uninstaller.zip b/bin/acc-uninstaller.zip index 15c4f5b..31d7a2e 100644 Binary files a/bin/acc-uninstaller.zip and b/bin/acc-uninstaller.zip differ diff --git a/build.sh b/build.sh index 8f4fe08..f9875ff 100644 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh # Installation Archives Builder -# Copyright (c) 2018-2020, VR25 (xda-developers) +# Copyright 2018-2020, VR25 (xda-developers) # License: GPLv3+ # # usage: $0 [any_random_arg] diff --git a/bundle.sh b/bundle.sh index edb8a3d..394c9e4 100644 --- a/bundle.sh +++ b/bundle.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh # $id Bundler for Front-end Apps -# Copyright (c) 2019-2020, VR25 (xda-developers) +# Copyright 2019-2020, VR25 (xda-developers) # License: GPLv3+ diff --git a/check-syntax.sh b/check-syntax.sh index d18c069..42ebcd2 100644 --- a/check-syntax.sh +++ b/check-syntax.sh @@ -1,6 +1,6 @@ #!/usr/bin/env sh # Basic Shell Syntax Checker -# Copyright (c) 2018-2020, VR25 (xda-developers) +# Copyright 2018-2020, VR25 (xda-developers) # License: GPLv3+ (echo diff --git a/customize.sh b/customize.sh index 6905175..f5ae00a 100644 --- a/customize.sh +++ b/customize.sh @@ -1,6 +1,6 @@ #!/system/bin/sh # ACC Installer/Upgrader -# Copyright (c) 2019-2020, VR25 (xda-developers) +# Copyright 2019-2020, VR25 (xda-developers) # License: GPLv3+ # # devs: triple hashtags (###) mark non-generic code @@ -175,8 +175,8 @@ if $acca; then echo "#!/system/bin/sh # AccA post-uninstall cleanup script - until test -d /sdcard/?ndroid \\ - -a .\$(getprop sys.boot_completed) == .1 + until test -d /data/data \\ + && test .\$(getprop sys.boot_completed) = .1 do sleep 60 done @@ -192,7 +192,7 @@ if $acca; then fi -[ $installDir == /data/adb/$id ] || ln -s $installDir /data/adb/ +[ $installDir = /data/adb/$id ] || ln -s $installDir /data/adb/ # restore config backup @@ -258,7 +258,7 @@ echo " - Daemon started." -[ $installDir == /data/adb ] && echo " +[ $installDir = /data/adb ] && echo " (i) Non-Magisk users can enable $id auto-start by running /data/adb/$id/service.sh, a copy of, or a link to it - with init.d or an app that emulates it." diff --git a/install-online.sh b/install-online.sh index 08406c6..4e0ba00 100644 --- a/install-online.sh +++ b/install-online.sh @@ -3,7 +3,7 @@ # $id Online Installer # https://raw.githubusercontent.com/VR-25/$id/$branch/install-online.sh # -# Copyright (c) 2019-2020, VR25 (xda-developers) +# Copyright 2019-2020, VR25 (xda-developers) # License: GPLv3+ # # Usage: sh install-online.sh [-c|--changelog] [-f|--force] [-k|--insecure] [-n|--non-interactive] [%install dir%] [reference] @@ -60,9 +60,9 @@ set -eu get_ver() { sed -n 's/^versionCode=//p' ${1:-}; } -[ ! -f /data/adb/bin/curl ] || { - [ -x /data/adb/bin/curl ] || chmod -R 0700 /data/adb/bin - ${curlPath:-false} || export PATH=/data/adb/bin:$PATH +! test -f /data/adb/bin/curl || { + test -x /data/adb/bin/curl \ + || chmod -R 0700 /data/adb/bin } @@ -72,12 +72,12 @@ case "$@" in esac -reference=$(echo "$@" | sed -E 's/%.*%|-c|--changelog|-f|--force|-k|--insecure|-n|--non-interactive| //g') +reference=$(echo "$*" | sed -E 's/%.*%|-c|--changelog|-f|--force|-k|--insecure|-n|--non-interactive| //g') : ${reference:=master} tarball=https://github.com/VR-25/$id/archive/${reference}.tar.gz -installedVersion=$(get_ver /dev/.$id/$id/module.prop 2>/dev/null || :) +installedVersion=$(get_ver /data/adb/$id/module.prop 2>/dev/null || :) onlineVersion=$(curl -L $insecure https://raw.githubusercontent.com/VR-25/$id/${reference}/module.prop | get_ver) @@ -87,7 +87,7 @@ rm -rf "./${id}-${reference}/" 2>/dev/null || : if [ ${installedVersion:-0} -lt ${onlineVersion:-0} ] \ - || [[ "$*" == *-f* ]] || [[ "$*" == *--force* ]] + || [[ "$*" = *-f* ]] || [[ "$*" = *--force* ]] then ! echo "$@" | grep -Eq '\-\-changelog|\-c' || { diff --git a/install-tarball.sh b/install-tarball.sh index 3875e7b..a777315 100644 --- a/install-tarball.sh +++ b/install-tarball.sh @@ -1,6 +1,6 @@ #!/system/bin/sh # ${1:-$id}[-_]*.tar.gz Installer -# Copyright (c) 2019-2020, VR25 (xda-developers.com) +# Copyright 2019-2020, VR25 (xda-developers.com) # License: GPLv3+ id=acc diff --git a/install.sh b/install.sh index 6905175..f5ae00a 100644 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/system/bin/sh # ACC Installer/Upgrader -# Copyright (c) 2019-2020, VR25 (xda-developers) +# Copyright 2019-2020, VR25 (xda-developers) # License: GPLv3+ # # devs: triple hashtags (###) mark non-generic code @@ -175,8 +175,8 @@ if $acca; then echo "#!/system/bin/sh # AccA post-uninstall cleanup script - until test -d /sdcard/?ndroid \\ - -a .\$(getprop sys.boot_completed) == .1 + until test -d /data/data \\ + && test .\$(getprop sys.boot_completed) = .1 do sleep 60 done @@ -192,7 +192,7 @@ if $acca; then fi -[ $installDir == /data/adb/$id ] || ln -s $installDir /data/adb/ +[ $installDir = /data/adb/$id ] || ln -s $installDir /data/adb/ # restore config backup @@ -258,7 +258,7 @@ echo " - Daemon started." -[ $installDir == /data/adb ] && echo " +[ $installDir = /data/adb ] && echo " (i) Non-Magisk users can enable $id auto-start by running /data/adb/$id/service.sh, a copy of, or a link to it - with init.d or an app that emulates it." diff --git a/module.prop b/module.prop index f6b9bfc..f4e95d6 100644 --- a/module.prop +++ b/module.prop @@ -1,6 +1,6 @@ id=acc name=Advanced Charging Controller (ACC) -version=v2020.7.3 -versionCode=202007030 +version=v2020.7.19 +versionCode=202007190 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.