diff --git a/README.md b/README.md index 79391bf..abcd993 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,8 @@ ACC is primarily intended for extending battery service life. On the flip side, ## PREREQUISITES - Any root solution -- Terminal emulator (running as root) or a text editor. +- Terminal emulator (running as root) +- Text editor (optional) @@ -91,14 +92,14 @@ Notes ### Magisk 18.2+ -Install: flash live (e.g., from Magisk Manager) or from custom recovery (e.g., TWRP). +Install/upgrade: flash live (e.g., from Magisk Manager) or from custom recovery (e.g., TWRP). Uninstall: use Magisk Manager (app) or Magisk Manager for Recovery Mode (utility). -### Older Magisk Versions and Other Root Solutions +### Any Root Solution (Advanced) -Install: extract `acc-*.zip/install-legacy.sh`, run `su`, then execute `sh /path/to/install-legacy.sh /absolute/path/to/acc-*.zip`. +Install/upgrade: extract `acc-*.zip`, run `su`, then execute `sh /absolute/path/to/extracted/install-current.sh`. Uninstall: for Magisk install, use Magisk Manager (app); else, run `su -c rm -rf /data/adb/acc/`. @@ -107,7 +108,7 @@ Uninstall: for Magisk install, use Magisk Manager (app); else, run `su -c rm -rf ACC supports live upgrades - meaning, rebooting after installing/upgrading is unnecessary. -The demon is automatically started/restarted ~30 seconds after installation. +The demon is automatically started ~30 seconds after installation. @@ -178,7 +179,8 @@ language=en ACC is designed to run out of the box, without user intervention. You can simply install it and forget. However, as it's been observed, most people will want to tweak settings - and obviously everyone will want to know whether the thing is actually working. -If you're not comfortable with the command line, skip this section and use the `ACC app` (links section) to manage ACC. +If you feel uncomfortable with the command line, skip this section and use the `ACC app` (links section) to manage ACC. + Alternatively, you can use a `text editor` to modify `/sdcard/acc/config.txt`. Changes to this file take effect almost instantly, and without a daemon restart. @@ -228,6 +230,9 @@ acc -s|--set Show current config e.g., acc -s +s|--set Restore default config + e.g., acc -s r + -s|--set Set config parameters e.g., acc -s capacity 5,60,80-85 (5: shutdown (default), 60: cool down (default), 80: resume, 85: pause) @@ -251,20 +256,20 @@ acc e.g., acc -t battery/charging_enabled 1 0 Return codes: 0 (works), 1 (doesn't work) or 2 (battery must be charging) --v|--voltage Set charging voltage (3920-4349mV) - e.g., acc -v 3920, acc -v /sys/class/power_supply/battery/voltage_max:4100 - --v|--voltage Show current voltage +-v|--voltage Show current charging voltage e.g., acc -v --v|--voltage : List available charging voltage ctrl files +-v|--voltage : List available/default charging voltage ctrl files e.g., acc -v : --v|--voltage - Restore default voltage +-v|--voltage - Restore default charging voltage limit e.g., acc -v - --v|--voltage :millivolts Evaluate and set charging voltage ctrl files - e.g., acc -v :4100 +-v|--voltage Set charging voltage limit (default/set ctrl file) + e.g., acc -v 4100 + +-v|--voltage Set charging voltage limit (custom ctrl file) + e.g., acc -v battery/voltage_max:4100 -x|--xtrace Run under set -x (debugging) acc -x -i @@ -325,7 +330,7 @@ However, things don't always go well. Some switches may be unreliable under certain conditions (e.g., screen off). Others may hold a wakelock - causing faster battery drain - while in plugged in, not charging state. -Run `acc --set chargingSwitch` to enforce a particular switch. +Run `acc --set chargingSwitch` (or `acc -s s` for short) to enforce a particular switch. Test default/set switch(es) with `acc --test`. @@ -394,11 +399,25 @@ Translation Notes +## ASSORTED TIPS + + +### Samsung + +The following files could be used to control charging current and voltage (with `applyOnBoot`): +``` +battery/batt_tune_fast_charge_current (default: 2100) + +battery/batt_tune_input_charge_current (default: 1800) + +battery/batt_tune_float_voltage (max: 43500) +``` + + --- ## LINKS - [ACC app](https://github.com/MatteCarra/AccA/releases/) -- [Battery company](https://cadex.com/) - [Battery University](http://batteryuniversity.com/learn/article/how_to_prolong_lithium_based_batteries/) - [Donate](https://paypal.me/vr25xda/) - [Facebook page](https://facebook.com/VR25-at-xda-developers-258150974794782/) @@ -413,9 +432,22 @@ Translation Notes --- ## LATEST CHANGES +**2019.6.14-r1 (201906141)** +- Added `battery/batt_tune_float_voltage` (Samsung) to the list of supported voltage control files +- Enhanced log exporter (`acc -l --export`) +- Fixed: default voltage limit not restored when accd is stopped +- `From-source` installer for any root solution (install-current.sh) +- General fixes +- Major optimizations +- Redesigned `rebootOnPause` +- Update charging switches database +- Updated documentation (`assorted tips` section and more) +- Updated Portuguese translation +> Note: compatible with ACCApp 1.0.6-1.0.8 + **2019.6.11 (201906110)** - Enhanced power supply logger (psl.sh) and `rebootOnPause` -- Fixed accd not auto-starting and `coolDownRatio` issues +- Fixed: accd not auto-starting and `coolDownRatio` issues - General fixes - `install-legacy.sh` - for older Magisk versions and other root solutions - Major optimizations @@ -424,14 +456,10 @@ Translation Notes **2019.6.8 (201906080)** - Customizable minimum charging on/off toggling interval (`chargingOnOffDelay`) - Enhanced modularity to work even without Magisk (refer to README.md for details) -- Fixed `applyOnBoot` +- Fixed: `applyOnBoot` - Major optimizations - Multi-language support (refer to `README.md` for details) - Partial Portuguese language support (first additional language) - Updated documentation, charging switches database and building/debugging tools - Workaround for re-enabling charging (`rebootOnUnplug`) > Note: compatible with ACCApp 1.0.6-1.0.8 - -**2019.5.16-r2 (201905162)** -- Fixed - ls_voltage_ctrl_files() not working for all -> Note: compatible with ACCApp 1.0.6 diff --git a/acc/acc.sh b/acc/acc.sh index ec9a7f6..18c8cbe 100644 --- a/acc/acc.sh +++ b/acc/acc.sh @@ -7,9 +7,9 @@ daemon() { local isRunning=true - local pid="$(pgrep -f '/acc.sh -?[edf]|/accd.sh' || :)" - - pid="${pid/$$/}" + set +eo pipefail + local pid="$(pgrep -f '/acc -|/accd.sh' | sed s/$$//)" + set -eo pipefail [[ x$pid == *[0-9]* ]] || isRunning=false case ${1:-} in @@ -19,7 +19,7 @@ daemon() { else print_started set +x - accd + /sbin/accd fi ;; stop) @@ -39,7 +39,7 @@ daemon() { print_started fi set +x - accd + /sbin/accd ;; *) if $isRunning; then @@ -91,7 +91,7 @@ set_values() { cp -f $modPath/config.txt $config chmod 0777 $config print_config_reset - accd + /sbin/accd return 0 ;; *) @@ -246,18 +246,15 @@ set_capacity() { switch_loop() { - local file="" on="" off="" default="" + local file="" on="" off="" while IFS= read -r file; do if [ -f $(echo $file | awk '{print $1}') ]; then on=$(echo $file | awk '{print $2}') off=$(echo $file | awk '{print $3}') file=$(echo $file | awk '{print $1}') - default=$(sed -n 1p $file) chmod +w $file && eval "echo \$$1" > $file 2>/dev/null && sleep $(get_value chargingOnOffDelay) || continue - if { [ $1 == off ] && ! not_charging; } \ - || { [ $1 == on ] && not_charging; } - then - echo $default > $file 2>/dev/null || : + if [ $1 == off ] && ! not_charging; then + echo $on > $file 2>/dev/null || : else break fi @@ -320,7 +317,7 @@ set_charging_voltage() { if [ -f $file ]; then oValue=$value value=$(sed "s/^..../$value/" $file) - echo "$file $(sed -n 1p $file)" > $dVolt + [ -f $dVolt ] || echo "$file $(sed -n 1p $file)" > $dVolt if chmod +w $file && echo $value > $file 2>/dev/null && grep -q "^$oValue" $file; then [ x$(get_value chargingVoltageLimit) == x$file:$oValue ] || set_value chargingVoltageLimit $file:$oValue print_cvolt_set @@ -340,7 +337,7 @@ set_charging_voltage() { ls_voltage_ctrl_files() { cat -v ${modPath%/*}/acc-power_supply-*.log \ - | grep -E '/constant_charge_voltage$|/voltage_max$' \ + | grep -E '/constant_charge_voltage$|/voltage_max$|/batt_tune_float_voltage$' \ | sed -e 's|^.*power_supply/||' -e 's/$/\n/' } @@ -383,15 +380,14 @@ test_charging_switch() { local on=$(echo "$@" | awk '{print $2}') local off=$(echo "$@" | awk '{print $3}') local file=$(echo "$@" | awk '{print $1}') - [ -z "$file" ] || local default=$(sed -n 1p $file) - set +e - pgrep -f '/acc.sh -?[edf]|/accd.sh' | xargs kill -9 2>/dev/null - set -e + set +eo pipefail + pgrep -f '/acc -|/accd.sh' | sed s/$$// | xargs kill -9 2>/dev/null + set -eo pipefail if not_charging; then print_unplugged - accd + /sbin/accd return 2 fi @@ -400,20 +396,20 @@ test_charging_switch() { sleep $(get_value chargingOnOffDelay) if not_charging; then print_file_works - echo $default > $file - accd + echo $on > $file + /sbin/accd return 0 else print_file_fails - echo $default > $file - accd + echo $on > $file + /sbin/accd return 1 fi else disable_charging > /dev/null if not_charging; then print_supported - accd + /sbin/accd return 0 else print_unsupported @@ -439,7 +435,15 @@ set -euo pipefail modPath=/sbin/.acc/acc config=/data/media/0/acc/config.txt -[[ $PATH == *magisk/busybox* ]] || PATH=/sbin/.magisk/busybox:$PATH + +if [[ $PATH != */busybox* ]]; then + if [ -d /sbin/.magisk/busybox ]; then + PATH=/sbin/.magisk/busybox:$PATH + elif [ -d /sbin/.core/busybox ]; then + PATH=/sbin/.core/busybox:$PATH + fi +fi + device=$(getprop ro.product.device | grep .. || getprop ro.build.product) batt=$(echo /sys/class/power_supply/*attery/capacity | awk '{print $1}' | sed 's|/capacity||') @@ -476,15 +480,12 @@ case ${1:-} in -e|--enable) shift; enable_charging $@;; -f|--force|--full) - set +e - pgrep -f '/acc.sh -?[ed]|/accd.sh' | xargs kill -9 2>/dev/null - set -e - chargingVoltageLimit=$(set_charging_voltage | sed 's/mV//') - set_charging_voltage - + set +eo pipefail + pgrep -f '/acc -|/accd.sh' | sed s/$$// | xargs kill -9 2>/dev/null + set_charging_voltage - > /dev/null + set -eo pipefail enable_charging ${2:-100}% - set_charging_voltage $chargingVoltageLimit - unset chargingVoltageLimit - accd + /sbin/accd ;; -i|--info) sed s/POWER_SUPPLY_// $batt/uevent | sed "/^CAPACITY=/s/=.*/=$(( $(cat $batt/capacity) $(get_value capacityOffset) ))/";; @@ -492,13 +493,17 @@ case ${1:-} in -l|--log) shift if [[ "${1:-x}" == -*e* ]]; then + set +eo pipefail + ls_charging_switches | grep -v '^$' > ${modPath%/*}/charging-ctrl-files.txt cd ${modPath%/*} set_values > config.txt + ls_voltage_ctrl_files | grep -v '^$' > charging-voltage-ctrl-files.txt for file in /cache/magisk.log /data/cache/magisk.log; do - [ -f $file ] && cp $file ./ && break || : + [ -f $file ] && cp $file ./ && break done - tar -c acc-*-*.log* config.txt magisk.log | bzip2 -9 > /data/media/0/acc-logs-$device.tar.bz2 - rm config.txt magisk.log + tar -c *.log *.txt magisk.log 2>/dev/null | bzip2 -9 > /data/media/0/acc-logs-$device.tar.bz2 + rm *.txt magisk.log 2>/dev/null + echo "(i) /sdcard/acc-logs-$device.tar.bz2" else edit ${modPath%/*}/acc-daemon-*.log $@ fi diff --git a/acc/accd.sh b/acc/accd.sh index 79bc62f..534ef4d 100644 --- a/acc/accd.sh +++ b/acc/accd.sh @@ -10,7 +10,7 @@ exxit() { trap - EXIT { dumpsys battery reset enable_charging - set_charging_voltage; } > /dev/null 2>&1 + /sbin/acc --voltage -; } > /dev/null 2>&1 [ -n "$1" ] && echo "$2" && exitCode=$1 echo "***EXIT $exitCode***" exit $exitCode @@ -77,9 +77,9 @@ disable_charging() { value=$(get_value chargingSwitch | awk '{print $3}') if [ -f $file ]; then chmod +w $file && echo $value > $file 2>/dev/null && sleep $(get_value chargingOnOffDelay) \ - || acc --set chargingSwitch- > /dev/null + || /sbin/acc --set chargingSwitch- > /dev/null else - acc --set chargingSwitch- > /dev/null + /sbin/acc --set chargingSwitch- > /dev/null fi else switch_loop off @@ -100,9 +100,9 @@ enable_charging() { value=$(get_value chargingSwitch | awk '{print $2}') if [ -f $file ]; then chmod +w $file && echo $value > $file 2>/dev/null && sleep $(get_value chargingOnOffDelay) \ - || acc --set chargingSwitch- > /dev/null + || /sbin/acc --set chargingSwitch- > /dev/null else - acc --set chargingSwitch- > /dev/null + /sbin/acc --set chargingSwitch- > /dev/null fi else switch_loop on @@ -211,18 +211,15 @@ apply_on_boot() { switch_loop() { - local file="" on="" off="" default="" + local file="" on="" off="" while IFS= read -r file; do if [ -f $(echo $file | awk '{print $1}') ]; then on=$(echo $file | awk '{print $2}') off=$(echo $file | awk '{print $3}') file=$(echo $file | awk '{print $1}') - default=$(sed -n 1p $file) chmod +w $file && eval "echo \$$1" > $file 2>/dev/null && sleep $(get_value chargingOnOffDelay) || continue - if { [ $1 = off ] && is_charging; } \ - || { [ $1 = on ] && ! is_charging; } - then - echo $default > $file 2>/dev/null || : + if [ $1 = off ] && is_charging; then + echo $on > $file 2>/dev/null || : else break fi @@ -241,7 +238,13 @@ coolDown=false modPath=/sbin/.$modId/$modId config=/data/media/0/$modId/config.txt -[[ $PATH == *magisk/busybox* ]] || PATH=/sbin/.magisk/busybox:$PATH +if [[ $PATH != */busybox* ]]; then + if [ -d /sbin/.magisk/busybox ]; then + PATH=/sbin/.magisk/busybox:$PATH + elif [ -d /sbin/.core/busybox ]; then + PATH=/sbin/.core/busybox:$PATH + fi +fi log=${modPath%/*}/acc-daemon-$(getprop ro.product.device | grep .. || getprop ro.build.product).log @@ -251,7 +254,7 @@ batt=$(echo /sys/class/power_supply/*attery/capacity | awk '{print $1}' | sed 's until [ -d /storage/emulated/0/?ndroid ]; do sleep 10; done set +e -pgrep -f '/acc.sh -?[edf]|/accd.sh' | sed s/$$// | xargs kill -9 2>/dev/null +pgrep -f '/acc -|/accd.sh' | sed s/$$// | xargs kill -9 2>/dev/null set -e mkdir -p ${modPath%/*} ${config%/*} @@ -268,7 +271,7 @@ trap exxit EXIT [ -f $modPath/module.prop ] || exxit 1 "(!) modPath not found" unset modId apply_on_boot -acc --voltage apply > /dev/null 2>&1 || : +/sbin/acc --voltage apply > /dev/null 2>&1 || : check_compatibility ctrl_charging exit $? diff --git a/acc/service.sh b/acc/service.sh index 9e7f7ae..eb15d30 100644 --- a/acc/service.sh +++ b/acc/service.sh @@ -1,17 +1,25 @@ #!/system/bin/sh -# acc/accd initializer +# $modId/${modId}d initializer + +modId=$(sed -n 's/^id=//p' ${0%/*}/module.prop) # prepare working directory -([ -d /sbin/.acc ] && [ ${1:-x} != install ] && exit 0 -mount -o remount,rw /sbin -mkdir -p /sbin/.acc -[ -h /sbin/.acc/acc ] && rm /sbin/.acc/acc \ - || rm -rf /sbin/.acc/acc 2>/dev/null +([ -d /sbin/.$modId ] && [ ${1:-x} != install ] && exit 0 +if ! mount -o remount,rw /sbin 2>/dev/null; then + set -e + rm -rf /dev/.sbin 2>/dev/null || : + cp -a /sbin /dev/.sbin + mount -o bind,rw /dev/.sbin /sbin + set +e +fi +mkdir -p /sbin/.$modId +[ -h /sbin/.$modId/$modId ] && rm /sbin/.$modId/$modId \ + || rm -rf /sbin/.$modId/$modId 2>/dev/null [ ${MAGISK_VER_CODE:-18200} -gt 18100 ] \ - && ln -s ${0%/*} /sbin/.acc/acc \ - || cp -a ${0%/*} /sbin/.acc/acc -ln -fs /sbin/.acc/acc/acc.sh /sbin/acc -ln -fs /sbin/.acc/acc/accd-init.sh /sbin/accd + && ln -s ${0%/*} /sbin/.$modId/$modId \ + || cp -a ${0%/*} /sbin/.$modId/$modId +ln -fs /sbin/.$modId/$modId/$modId.sh /sbin/$modId +ln -fs /sbin/.$modId/$modId/${modId}d-init.sh /sbin/${modId}d # generate power supply log ${0%/*}/psl.sh $(sed -n s/versionCode=//p ${0%/*}/module.prop) & @@ -25,9 +33,9 @@ if [ -f $termuxSu ] && grep -q 'PATH=.*/sbin/su' $termuxSu; then fi unset termuxSu -# start accd +# start ${modId}d sleep 30 -kill -9 $(pgrep -f psl.sh) 2>/dev/null -/sbin/.acc/acc/accd.sh &) & +kill -9 $(pgrep -f /psl.sh) 2>/dev/null +${0%/*}/${modId}d.sh &) & exit 0 diff --git a/acc/strings.sh b/acc/strings.sh index 3ab8898..8138e0a 100644 --- a/acc/strings.sh +++ b/acc/strings.sh @@ -35,7 +35,7 @@ print_cs_reset() { } print_supported_cs() { - echo "(i) supported charging switches" + echo "(i) Supported charging switches" } print_cs_fails() { @@ -72,11 +72,11 @@ print_ch_enabled() { print_dvolt_restored() { - echo "(i) Default voltage ($(grep -o '^....' $file)mV) was successfully restored." + echo "(i) Default charging voltage limit ($(grep -o '^....' $file)mV) successfully restored" } print_dvolt_already_set() { - echo "(i) Default voltage is already set." + echo "(i) Default charging voltage limit is already set" } print_invalid_input() { @@ -84,15 +84,15 @@ print_invalid_input() { } print_accepted_volt() { - echo "- Recall that the accepted voltage range is 3920-4349mV." + echo "- Recall that the accepted voltage range is 3920-4349mV" } print_cvolt_set() { - echo "(i) Charging voltage set to $(grep -o '^....' $file)mV" + echo "(i) Charging voltage limited to $(grep -o '^....' $file)mV" } print_cvolt_unsupported() { - echo "(!) Either [$(echo -n $file)] is not the right file or your kernel doesn't support custom charging voltage." + echo "(!) Either [$(echo -n $file)] is not the right file or your kernel doesn't support custom charging voltage" } print_no_such_file() { @@ -100,7 +100,7 @@ print_no_such_file() { } print_supported_cvolt_files() { - echo "(i) supported charging voltage ctrl files" + echo "(i) Supported charging voltage ctrl files" } print_cvolt_limit_set() { @@ -132,7 +132,7 @@ print_no_modpath() { } print_help() { - cat < -s|--set Show current config e.g., acc -s +s|--set Restore default config + e.g., acc -s r + -s|--set Set config parameters e.g., acc -s capacity 5,60,80-85 (5: shutdown (default), 60: cool down (default), 80: resume, 85: pause) @@ -204,20 +207,20 @@ Usage: acc e.g., acc -t battery/charging_enabled 1 0 Return codes: 0 (works), 1 (doesn't work) or 2 (battery must be charging) --v|--voltage Set charging voltage (3920-4349mV) - e.g., acc -v 3920, acc -v /sys/class/power_supply/battery/voltage_max:4100 - --v|--voltage Show current voltage +-v|--voltage Show current charging voltage e.g., acc -v --v|--voltage : List supported charging voltage ctrl files +-v|--voltage : List available/default charging voltage ctrl files e.g., acc -v : --v|--voltage - Restore default voltage +-v|--voltage - Restore default charging voltage limit e.g., acc -v - --v|--voltage :millivolts Evaluate and set charging voltage ctrl files - e.g., acc -v :4100 +-v|--voltage Set charging voltage limit (default/set ctrl file) + e.g., acc -v 4100 + +-v|--voltage Set charging voltage limit (custom ctrl file) + e.g., acc -v battery/voltage_max:4100 -x|--xtrace Run under set -x (debugging) acc -x -i diff --git a/acc/strings_pt.sh b/acc/strings_pt.sh index 18660fe..037a34f 100644 --- a/acc/strings_pt.sh +++ b/acc/strings_pt.sh @@ -72,11 +72,11 @@ print_ch_enabled() { print_dvolt_restored() { - echo "(i) A voltagem padrão ($(grep -o '^....' $file)mV) foi restaurada com sucesso." + echo "(i) Voltagem padrão ($(grep -o '^....' $file)mV) restaurada com sucesso" } print_dvolt_already_set() { - echo "(i) A voltagem padrão já está definida." + echo "(i) A voltagem padrão já está definida" } print_invalid_input() { @@ -84,15 +84,15 @@ print_invalid_input() { } print_accepted_volt() { - echo "- O intervalo permitido é 3920-4349mV." + echo "- O intervalo permitido é 3920-4349mV" } print_cvolt_set() { - echo "(i) Voltagem definida para $(grep -o '^....' $file)mV" + echo "(i) Voltagem limitada à $(grep -o '^....' $file)mV" } print_cvolt_unsupported() { - echo "(!) [$(echo -n $file)] é o ficheiro errado ou o kernel não suporta alteração de voltagem." + echo "(!) [$(echo -n $file)] é o ficheiro errado ou o kernel não suporta alteração de voltagem" } print_no_such_file() { @@ -128,7 +128,7 @@ print_no_modpath() { } print_help() { - cat < -s|--set Show current config Exemplo: acc -s +s|--set Restaurar configuração padrão + Exemplo acc -s r + -s|--set Set config parameters Exemplo: acc -s capacity 5,60,80-85 (5: shutdown (default), 60: cool down (default), 80: resume, 85: pause) @@ -200,20 +203,20 @@ Uso: acc Exemplo: acc -t battery/charging_enabled 1 0 Return codes: 0 (works), 1 (doesn't work) or 2 (battery must be charging) --v|--voltage Set charging voltage (3920-4349mV) - Exemplo: acc -v 3920, acc -v /sys/class/power_supply/battery/voltage_max:4100 +-v|--voltage Show current charging voltage + e.g., acc -v --v|--voltage Show current voltage - Exemplo: acc -v +-v|--voltage : List available/default charging voltage ctrl files + e.g., acc -v : --v|--voltage : List supported charging voltage ctrl files - Exemplo: acc -v : +-v|--voltage - Restore default charging voltage limit + e.g., acc -v - --v|--voltage - Restore default voltage - Exemplo: acc -v - +-v|--voltage Set charging voltage limit (default/set ctrl file) + e.g., acc -v 4100 --v|--voltage :millivolts Evaluate and set charging voltage ctrl files - Exemplo: acc -v :4100 +-v|--voltage Set charging voltage limit (custom ctrl file) + e.g., acc -v battery/voltage_max:4100 -x|--xtrace Run under set -x (debugging) acc -x -i diff --git a/acc/switches.txt b/acc/switches.txt index bd2fa2c..e1ec93e 100644 --- a/acc/switches.txt +++ b/acc/switches.txt @@ -3,7 +3,7 @@ # License: GPLv3+ # # PWD=/sys/class/power_supply -# Last updated: Sat, Jun 8, 2019 +# Last updated: Thu, Jun 13, 2019 battery/charger_control 1 0 battery/charge_disable 0 1 @@ -49,10 +49,13 @@ dc/input_suspend 0 1 /sys/devices/soc/soc:lge,charging_controller/lge_power/lge_cc/charging_enabled 1 0 # unconfirmed +#battery/charge_control_limit_max 16 -- supposedly works with the next +battery/charge_control_limit 0 1 /sys/devices/soc.0/78b8000.i2c/i2c-4/4-006b/power_supply/ext-charger/charge_enabled 1 0 /sys/devices/soc.0/qpnp-linear-charger-8/power_supply/battery_qpnp/charging_enabled 1 0 # EXPERIMENTAL +#battery/charger_temp_max 803 0 #battery/is_in_call 0 1 #/sys/devices/platform/battery_meter/FG_suspend_current_threshold 100 10 #/sys/devices/platform/battery_meter/FG_daemon_disable 0 1 diff --git a/install-current.sh b/install-current.sh new file mode 100644 index 0000000..28ca417 --- /dev/null +++ b/install-current.sh @@ -0,0 +1,144 @@ +#!/system/bin/sh +# From-source Installer/Upgrader +# Copyright (C) 2019, VR25 @xda-developers +# License: GPLv3+ + + +# enforce absolute path +[[ $0 == /* ]] || exec echo -e "\n(!) You must use the absolute path\n" + +# prepend Magisk's busybox to PATH +if [ -d /sbin/.magisk/busybox ]; then + PATH=/sbin/.magisk/busybox:$PATH +elif [ -d /sbin/.core/busybox ]; then + PATH=/sbin/.core/busybox:$PATH +fi + +which awk > /dev/null || exec echo -e "\n(!) Install busybox first\n" + +print() { sed -n "s|^$1=||p" ${2:-$srcDir/module.prop} 2>/dev/null || :; } + +srcDir=${0%/*} +modId=$(print id) +name=$(print name) +author=$(print author) +version=$(print version) +versionCode=$(print versionCode) +config=/data/media/0/$modId/config.txt +configVer=$(print versionCode $config) + +pgrep -f "/$modId -|/${modId}d.sh" | xargs kill -9 2>/dev/null + +cd /sbin/.magisk/modules 2>/dev/null || cd /sbin/.core/img 2>/dev/null \ + || cd /data/adb || exec echo -e "\n(!) /data/adb/ not found\n" + + +cat << CAT + +$name $version +Copyright (C) 2017-2019, $author +License: GPLv3+ + +(i) Installing to $PWD/$modId/... +CAT + + +umask 022 +rm -rf $modId 2>/dev/null +set -euo pipefail +cp -R $srcDir/$modId/ . +cp $srcDir/module.prop $modId/ +mkdir -p ${config%/*}/info +cp -f $srcDir/*.md ${config%/*}/info + +if [ $PWD == /data/adb ]; then + mv $modId/service.sh $modId/${modId}-init.sh +else + ln $modId/service.sh $modId/post-fs-data.sh + if [ $PWD == /sbin/.core/img ]; then + sed -i s/\.magisk/\.core/ $modId/${modId}.sh + sed -i s/\.magisk/\.core/ $modId/${modId}d.sh + fi +fi +chmod 0755 $modId/*.sh + +# patch/upgrade config +if [ -f $config ]; then + if [ ${configVer:-0} -lt 201905110 ] \ + || [ ${configVer:-0} -gt $(print versionCode $modId/config.txt) ] + then + rm $config + else + [ $configVer -lt 201905111 ] \ + && sed -i -e '/CapacityOffset/s/C/c/' -e '/^versionCode=/s/=.*/=201905111/' $config + [ $configVer -lt 201905130 ] \ + && sed -i -e '/^capacitySync=/s/true/false/' -e '/^versionCode=/s/=.*/=201905130/' $config + if [ $configVer -lt 201906020 ]; then + echo >> $config + grep rebootOnUnplug $modId/config.txt >> $config + echo >> $config + grep "toggling interval" $modId/config.txt >> $config + grep chargingOnOffDelay $modId/config.txt >> $config + sed -i '/^versionCode=/s/=.*/=201906020/' $config + fi + if [ $configVer -lt 201906050 ]; then + echo >> $config + grep language $modId/config.txt >> $config + sed -i '/^versionCode=/s/=.*/=201906050/' $config + fi + fi +fi +chmod -R 0777 ${config%/*} +set +euo pipefail + + +cat << CAT +- Done + + LATEST CHANGES + +CAT + + +println=false +cat ${config%/*}/info/README.md | while IFS= read -r line; do + if $println; then + echo " $line" + else + echo "$line" | grep -q \($versionCode\) && println=true \ + && echo " $line" + fi +done + + +cat << CAT + + LINKS + - ACC app: github.com/MatteCarra/AccA/ + - Battery University: batteryuniversity.com/learn/article/how_to_prolong_lithium_based_batteries/ + - Donate: paypal.me/vr25xda/ + - Facebook page: facebook.com/VR25-at-xda-developers-258150974794782/ + - Git repository: github.com/VR-25/$MODID/ + - Telegram channel: t.me/vr25_xda/ + - Telegram group: t.me/${MODID}_magisk/ + - Telegram profile: t.me/vr25xda/ + - XDA thread: forum.xda-developers.com/apps/magisk/module-magic-charging-switch-cs-v2017-9-t3668427/ + +(i) Important info: https://bit.ly/2TRqRz0 + +(i) Rebooting is unnecessary. +- $modId can be used right now. +- $modId daemon is already initializing. + +CAT + + +[ $PWD == /data/adb ] && echo -e "(i) Use init.d or an app to run /data/adb/$modId/${modId}-init.sh on boot to initialize ${modId}.\n" + +if [ -f $modId/service.sh ]; then + $PWD/$modId/service.sh install +else + $PWD/$modId/${modId}-init.sh install +fi + +exit 0 diff --git a/install-latest.sh b/install-latest.sh index fb04918..0604d73 100644 --- a/install-latest.sh +++ b/install-latest.sh @@ -1,16 +1,16 @@ #!/system/bin/sh # -# ACC installer/upgrader -# https://raw.githubusercontent.com/VR-25/acc/master/install-latest.sh +# $modId installer/upgrader +# https://raw.githubusercontent.com/VR-25/$modId/master/install-latest.sh # # Copyright (C) 2019, VR25 @xda-developers # License: GPLv3+ # -# Run "which acc > /dev/null || sh " to install ACC. +# Run "which $modId > /dev/null || sh " to install $modId. set -euo pipefail echo -echo "Downloading [module.prop], [update-binary] and [acc-*.zip]..." +echo "Downloading [module.prop], [update-binary] and [$modId-*.zip]..." modId=acc log=/sbin/.$modId/install-stderr.log @@ -20,7 +20,7 @@ mkdir -p ${log%/*} get_ver() { sed -n 's/^versionCode=//p' ${1:-}; } -instVer=$(get_ver /sbin/.$modId/acc/module.prop 2>/dev/null || :) +instVer=$(get_ver /sbin/.$modId/$modId/module.prop 2>/dev/null || :) baseUrl=https://github.com/VR-25/$modId rawUrl=https://raw.githubusercontent.com/VR-25/$modId/master currVer=$(curl -#L $rawUrl/module.prop | get_ver) diff --git a/install-legacy.sh b/install-legacy.sh deleted file mode 100644 index 900276f..0000000 --- a/install-legacy.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/system/bin/sh -# ACC installer/upgrader for old Magisk versions and other root solutions - -[[ ${1:-x} == /* ]] || exec echo -e "\n(i) Usage: sh $0 /absolute/path/to/acc-*.zip\n" - -PATH=/sbin/.core/busybox:$PATH -which unzip >/dev/null || exit 1 -rm -rf /data/media/0/acc 2>/dev/null -mkdir -p /data/media/0/acc/info -unzip $1 '*.md' -d /data/media/0/acc/info >/dev/null -chmod -R 0777 /data/media/0/acc - -mount -o remount,rw /sbin -cd /sbin/.core/img 2>/dev/null || cd /data/adb || exit 1 -rm -rf acc 2>/dev/null -unzip $1 'acc/*' module.prop -d . >/dev/null -mv module.prop acc/ - -if [ $PWD == /data/adb ]; then - mv acc/service.sh acc/acc-init.sh - echo -e "\n(i) Use init.d or an app to run /data/adb/acc/acc-init.sh on boot to initialize acc.\n" -else - ln acc/service.sh acc/post-fs-data.sh -fi - -sed -i s/\.magisk/\.core/ acc/acc.sh -sed -i s/\.magisk/\.core/ acc/accd.sh -chmod 0755 acc/*.sh - -if [ -f acc/service.sh ]; then - $PWD/acc/service.sh install -else - $PWD/acc/acc-init.sh install -fi - -exit 0 diff --git a/install.sh b/install.sh index 775ee83..2ab3007 100644 --- a/install.sh +++ b/install.sh @@ -137,7 +137,7 @@ on_install() { #ui_print "- Extracting module files" #unzip -o "$ZIPFILE" 'system/*' -d $MODPATH >&2 - $BOOTMODE && pgrep -f "/$MODID.sh -?[edf]|/${MODID}d.sh" | xargs kill -9 2>/dev/null + $BOOTMODE && pgrep -f "/$MODID -|/${MODID}d.sh" | xargs kill -9 2>/dev/null set -euxo pipefail trap 'exxit $?' EXIT @@ -145,7 +145,8 @@ on_install() { local configVer=$(print versionCode $config) # extract module files - ui_print "- Extracting module files" + ui_print " " + ui_print "(i) Extracting module files..." unzip -o "$ZIPFILE" "$MODID/*" -d ${MODPATH%/*}/ >&2 ln $MODPATH/service.sh $MODPATH/post-fs-data.sh mkdir -p ${config%/*}/info @@ -223,9 +224,12 @@ exxit() { version_info() { + local line="" local println=false + ui_print "- Done" + # a note on untested Magisk versions if [ $MAGISK_VER_CODE -gt 19300 ]; then ui_print " " @@ -248,7 +252,6 @@ version_info() { ui_print " LINKS" ui_print " - ACC app: github.com/MatteCarra/AccA/" - ui_print " - Battery company: cadex.com" ui_print " - Battery University: batteryuniversity.com/learn/article/how_to_prolong_lithium_based_batteries/" ui_print " - Donate: paypal.me/vr25xda/" ui_print " - Facebook page: facebook.com/VR25-at-xda-developers-258150974794782/" @@ -262,7 +265,9 @@ version_info() { ui_print "(i) Important info: https://bit.ly/2TRqRz0" ui_print " " if $BOOTMODE; then - ui_print "(i) Ignore the reboot button. You can use $MODID right away." + ui_print "(i) Ignore the reboot button." + ui_print "- $MODID can be used right now." + ui_print "- $MODID daemon is already initializing." ui_print " " fi } diff --git a/module.prop b/module.prop index 6c0933d..087f7f8 100644 --- a/module.prop +++ b/module.prop @@ -1,6 +1,6 @@ id=acc name=Advanced Charging Controller (acc) -version=2019.6.11 -versionCode=201906110 +version=2019.6.14-r1 +versionCode=201906141 author=VR25 @ xda-developers description=This is primarily intended for extending battery service life. On the flip side, the name says it all. Any root solution is supported. A recent stable Magisk version is recommended. Refer to README.md for details. diff --git a/uninstall.sh b/uninstall.sh index 8eae40d..b24bfe1 100644 --- a/uninstall.sh +++ b/uninstall.sh @@ -1,7 +1,8 @@ #!/system/bin/sh # remove leftovers -(until [ -d /data/media/0/acc ]; do sleep 20; done -rm -rf /data/media/0/acc +(modId=acc +until [ -d /data/media/0/$modId ]; do sleep 20; done +rm -rf /data/media/0/$modId exit 0 &) & exit 0