From 5fced461f013162209bbd4371e1ce63f63000bc0 Mon Sep 17 00:00:00 2001 From: VR-25 <28943176+VR-25@users.noreply.github.com> Date: Sat, 24 Oct 2020 13:03:43 +0100 Subject: [PATCH] **v2020.10.24 (202010240)** - [Experimental] Current-based charging control - enabled by setting charging_switch=milliamps (e.g., 250). - cooldown_current is no longer the default cooldown method due to issues observed on some devices. - Fixed `acc -ss`. - Major optimizations - New charging switch for OnePlus Devices - Shutdown if battery temp hits shutdown_temp, default: 65 degrees Celsius. - Updated default config, project framework and readme. Release Notes - AccA has been found to be behind several issues, e.g., unwanted config resets, changes to config not sticking. - If you still face issues after uninstalling AccA, see whether resetting acc config (`acc -sr`) helps. - Recall that if you feel uncomfortable with terminal, you don't have to use it at all! The config file can be edited manually (text editor). The process is very straightforward. Just do not edit in Windows Notepad, ever! It replaces LF (Linux/Unix) with CRLF (Windows) line endings. --- META-INF/com/google/android/update-binary | 25 +++-- README.md | 120 +++++++++++++--------- TODO.txt | 24 ----- acc/acc.sh | 23 +++-- acc/acca.sh | 6 +- acc/accd.sh | 37 +++++-- acc/acquire-lock.sh | 1 + acc/alt-functions.sh | 14 +++ acc/charging-switches.txt | 3 +- acc/default-config.txt | 49 +++++---- acc/logf.sh | 6 +- acc/misc-functions.sh | 26 ++--- acc/oem-custom.sh | 15 +-- acc/post-fs-data.sh | 7 +- acc/power-supply-logger.sh | 2 +- acc/print-config.sh | 4 +- acc/release-lock.sh | 6 +- acc/service.sh | 16 ++- acc/set-prop.sh | 47 ++++----- acc/strings.sh | 4 +- acc/uninstall.sh | 11 +- acc/wizard.sh | 14 +-- acc/write-config.sh | 9 +- bin/acc-uninstaller.zip | Bin 1952 -> 1962 bytes build.sh | 10 ++ customize.sh | 25 +++-- framework-details.txt | 2 +- install-online.sh | 5 +- install-tarball.sh | 7 +- install.sh | 25 +++-- module.prop | 5 +- 31 files changed, 312 insertions(+), 236 deletions(-) create mode 100644 acc/alt-functions.sh diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary index 6df606d..c1318e6 100644 --- a/META-INF/com/google/android/update-binary +++ b/META-INF/com/google/android/update-binary @@ -12,8 +12,9 @@ SKIPUNZIP=1 echo id=acc +domain=vr25 umask 0077 -data_dir=/sdcard/Documents/vr25/$id +data_dir=/sdcard/Documents/$domain/$id # log @@ -26,7 +27,7 @@ set -x exxit() { local e=$? set +eu - rm -rf /dev/.${id}-install /data/adb/modules_update/$id + rm -rf /dev/.$domain.${id}-install /data/adb/modules_update/$id (abort) > /dev/null echo exit $e @@ -92,7 +93,7 @@ srcDir=${srcDir/#"${0##*/}"/"."} # extract flashable zip if source code is unavailable [ -f $srcDir/module.prop ] || { - srcDir=/dev/.${id}-install + srcDir=/dev/.$domain.${id}-install rm -rf $srcDir 2>/dev/null || : mkdir $srcDir unzip "${3:-${ZIPFILE}}" -d $srcDir/ >&2 @@ -138,6 +139,7 @@ GPLv3+ # migrate #legacy data + if [ -d /data/adb/${id}-data ]; then mv -f /data/adb/${id}-data/* /data/adb/${id}-data/.* \ $data_dir/ 2>/dev/null || : @@ -145,11 +147,14 @@ elif [ -d /sdcard/Download/$id ]; then mv -f /sdcard/Download/$id/* /sdcard/Download/$id/.* \ $data_dir/ 2>/dev/null || : else - mv -f /sdcard/vr25/$id/* /sdcard/vr25/$id/.* \ + mv -f /sdcard/$domain/$id/* /sdcard/$domain/$id/.* \ $data_dir/ 2>/dev/null || : fi rm -rf $data_dir/info 2>/dev/null || : +mkdir -p /dev/.$domain +mv /dev/.$id /dev/.$domain/$id 2>/dev/null || : + /system/bin/sh $srcDir/$id/uninstall.sh install cp -R $srcDir/$id/ $installDir/ @@ -193,7 +198,7 @@ if $acca; then sleep 60 - [ -e /data/data/mattecarra.${id}app/files/$id ] || rm -rf \$0 /data/adb/vr25/$id /data/adb/modules/$id 2>/dev/null + [ -e /data/data/mattecarra.${id}app/files/$id ] || rm -rf \$0 /data/adb/$domain/$id /data/adb/modules/$id 2>/dev/null exit 0" | sed 's/^ //' > /data/adb/service.d/${id}-cleanup.sh chmod 0700 /data/adb/service.d/${id}-cleanup.sh @@ -201,9 +206,9 @@ if $acca; then fi -[ $installDir = /data/adb/vr25/$id ] || { +[ $installDir = /data/adb/$domain/$id ] || { mkdir -p /data/adb/vr25 - ln -s $installDir /data/adb/vr25/ + ln -s $installDir /data/adb/$domain/ } @@ -261,15 +266,15 @@ echo " (i) Rebooting is unnecessary -- $id commands may require the /dev/ prefix (e.g., /dev/$id) until system is rebooted. +- $id commands may require the "/dev/.$domain/$id/" prefix (e.g., /dev/.$domain/$id/$id -v) until system is rebooted. - Daemon started." [ $installDir = /data/adb ] && echo " -(i) Non-Magisk users can enable $id auto-start by running /data/adb/vr25/$id/service.sh, a copy of, or a link to it - with init.d or an app that emulates it." +(i) Non-Magisk users can enable $id auto-start by running /data/adb/$domain/$id/service.sh, a copy of, or a link to it - with init.d or an app that emulates it." # initialize $id -/data/adb/vr25/$id/service.sh --init +/data/adb/$domain/$id/service.sh --init exit 0 diff --git a/README.md b/README.md index 9761cee..5073359 100644 --- a/README.md +++ b/README.md @@ -174,11 +174,11 @@ In interactive mode, it also asks the user whether they want to download and ins ``` #DC# -configVerCode=202010120 -capacity=(-1 60 70 75 false) -temperature=(40 60 90) +configVerCode=202010240 +capacity=(0 60 70 75 false) +temperature=(40 60 90 65) cooldownRatio=() -cooldownCurrent=0 +cooldownCurrent= cooldownCustom=() resetBattStats=(false false) chargingSwitch=() @@ -187,7 +187,6 @@ applyOnPlug=() maxChargingCurrent=() maxChargingVoltage=() language=en -prioritizeBattIdleMode=true runCmdOnPause=() ampFactor= voltFactor= @@ -196,21 +195,31 @@ loopCmd=() # WARNINGS +# Do not edit this in Windows Notepad, ever! +# It replaces LF (Linux/Unix) with CRLF (Windows) line endings. + # As seen above, whatever is null can be null. # Nullifying values that should not be null causes nasty errors. # However, doing so with "--set var=" restores the default value of "var". # In other words, for regular users, "--set" is safer than modifying the config file directly. -# Do NOT feel like you must configure everything! -# If you don't know EXACTLY how to and why you want to do it, it's a very dumb idea. -# Help is always available, from multiple sources - plus, you don't have to pay a penny for it. +# Do not feel like you must configure everything! +# Do not change what you don't understand. +# Help is always available, from multiple sources - besides, I don't charge a penny for it. + + +# NOTES + +# The daemon does not have to be restarted after making changes to this file - unless one of the changes is charging_switch and the following logical condition is true: not_charging AND capacity >= resume_capacity. +# If charging_switch is changed with --set (e.g., -ss, -s s="...", --set charging_switch="..."), accd is restarted automatically, according to the aforementioned condition. -# BASIC CONFIG EXPLANATION + +# BASICS # capacity=(shutdown_capacity cooldown_capacity resume_capacity pause_capacity capacity_freeze2) -# temperature=(cooldown_temp max_temp max_temp_pause) +# temperature=(cooldown_temp max_temp max_temp_pause shutdown_temp) # cooldownRatio=(cooldown_charge cooldown_pause) @@ -232,8 +241,6 @@ loopCmd=() # language=lang=language_code -# prioritizeBattIdleMode=prioritize_batt_idle_mode=true/false - # runCmdOnPause=run_cmd_on_pause=(. script) # ampFactor=amp_factor=[multiplier] @@ -258,6 +265,8 @@ loopCmd=() # mt max_temp # mtp max_temp_pause +# st shutdown_temp + # ccu cooldown_custom # cdc cooldown_current @@ -273,7 +282,6 @@ loopCmd=() # mcv max_charging_voltage # l lang -# pbim prioritize_batt_idle_mode # rcp run_cmd_on_pause # af amp_factor @@ -312,6 +320,8 @@ loopCmd=() # acc -s cooldown_current=500 +# acc -s st=60 + # FINE, BUT WHAT DOES EACH OF THESE VARIABLES ACTUALLY MEAN? @@ -319,8 +329,7 @@ loopCmd=() # This is checked during updates to determine whether config should be patched. Do NOT modify. # shutdown_capacity (sc) # -# When the battery is discharging and its capacity <= 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 voltages below the operating range. -# On capacity <= shutdown_capacity + 5, accd enables Android battery saver, triggers 5 vibrations once - and again on each subsequent capacity drop. +# When the battery is discharging and its capacity <= 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. # cooldown_capacity (cc) # # Capacity at which the cooldown cycle starts. @@ -349,6 +358,9 @@ loopCmd=() # Unlike the cooldown cycle, which aims at reducing BOTH high temperature and high voltage induced stress - this is ONLY meant specifically for reducing high temperature induced stress. # Even though both are separate features, this complements the cooldown cycle when environmental temperatures are off the charts. +# shutdown_temp (st) # +# Shutdown the system if battery temperature >= this value. + # cooldown_charge (cch) # # cooldown_pause (cp) # # These two dictate the cooldown cycle intervals (seconds). @@ -363,8 +375,7 @@ loopCmd=() # Refer back the command examples. # cooldown_current (cdc) # -# Instead of pausing charging periodically during the cooldown phase, lower the charging current. -# This is the default behavior (smoother). +# Instead of pausing charging periodically during the cooldown phase, limit the max charging current (e.g., to 500 mA) # reset_batt_stats_on_pause (rbsp) # # Reset battery stats after pausing charging. @@ -398,10 +409,6 @@ loopCmd=() # lang (l) # # acc language, managed with "acc --set --lang" (acc -s l). -# prioritize_batt_idle_mode (pbim) # -# Several devices can draw power directly from the external power supply when charging is paused. Test yours with "acc -t". -# This setting dictates whether charging switches that support such feature should take precedence. - # run_cmd_on_pause (rcp) # # Run commands* after pausing charging. # * Usually a script ("sh some_file" or ". some_file") @@ -435,7 +442,6 @@ It's a wizard you'll either love or hate. If you feel uncomfortable with the command line, skip this section and use the [ACC App](https://github.com/MatteCarra/AccA/releases/) to manage ACC. Alternatively, you can use a `text editor` to modify `/sdcard/Documents/vr25/acc/config.txt`. -Restart the [daemon](https://en.wikipedia.org/wiki/Daemon_(computing)) afterwards, by running `accd`. The config file itself has configuration instructions. These instructions are the same found in the `DEFAULT CONFIG` section, above. @@ -600,7 +606,7 @@ Options acc -t battery/charging_enabled 1 0 acc -t /proc/mtk_battery_cmd/current_cmd 0::0 0::1 /proc/mtk_battery_cmd/en_power_path 1 0 ("::" is a placeholder for " ") - -t|--test [file] Test charging switches from a file (default: /dev/.acc/ch-switches) + -t|--test [file] Test charging switches from a file (default: /dev/.vr25/acc/ch-switches) This will also report whether "battery idle" mode is supported e.g., acc -t (test known switches) @@ -647,7 +653,7 @@ Exit Codes 10. "--test" failed 11. Current (mA) out of range 12. Initialization failed - 13. Failed to lock /dev/.acc/acc.lock + 13. Failed to lock /dev/.vr25/acc/acc.lock Logs are exported automatically ("--log --export") on exit codes 1, 2, 7 and 10. @@ -671,10 +677,10 @@ Tips --- ## NOTES/TIPS FOR FRONT-END DEVELOPERS -Use `/dev/acca` over `acc` commands. +Use `/dev/.vr25/acc/acca` over `acc` commands. These are optimized for front-ends - guaranteed to be readily available after installation/initialization and significantly faster than regular acc commands. -It may be best to use long options over short equivalents - e.g., `/dev/acca --set charging_switch=` instead of `/dev/acca -s s=`. +It may be best to use long options over short equivalents - e.g., `/dev/.vr25/acc/acca --set charging_switch=` instead of `/dev/.vr25/acc/acca -s s=`. This makes code more readable (less cryptic). Include provided descriptions for ACC features/settings in your app(s). @@ -684,14 +690,12 @@ Explain settings/concepts as clearly and with as few words as possible. Take advantage of exit codes. Refer back to `SETUP/USAGE > Terminal Commands > Exit Codes`. -Note: after updating charging_switch or shutdown_capacity, accd has to be restarted (`/dev/accd`) by the front-end itself for these changes to take effect immediately. - ### Online Install ``` 1) Check whether ACC is installed (exit code 0) -"/dev/acca --version" +"/dev/.vr25/acc/acca --version" 2) Download the installer (https://raw.githubusercontent.com/VR-25/acc/master/install-online.sh) - e.g., @@ -759,13 +763,15 @@ From recovery, one can flash `/sdcard/Documents/vr25/acc/acc-uninstaller.zip` or By default, ACC uses whichever [charging switch](https://github.com/VR-25/acc/blob/dev/acc/charging-switches.txt) works. However, things don't always go well. -- Some switches are unreliable under certain conditions (e.g., screen off). +- Some switches are unreliable under certain conditions (e.g., while display is off). - Others hold a [wakelock](https://duckduckgo.com/lite/?q=wakelock). This causes fast battery drain when charging is paused and the device remains plugged. -Refer back to `DEFAULT CONFIGURATION (wake_unlock)`. -- High CPU load and inability to re-enable charging were also reported. +- Charging keeps being re-enabled by the system, seconds after acc daemon disables it. +As a result, the battery eventually charges to 100% capacity, regardless of pause_capacity. + +- High CPU load (drains battery) was also reported. - In the worst case scenario, the battery status is reported as `discharging`, while it's actually `charging`. @@ -776,7 +782,7 @@ 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., MTK, Asus, 1+7pro) to prevent charging switch issues. +Since not everyone is tech savvy, ACC daemon automatically applies certain settings for specific devices (e.g., MediaTek, OnePlus, Razer) to prevent charging switch issues. These are are in `acc/oem-custom.sh`. @@ -807,7 +813,7 @@ These are simply ignored. ### Diagnostics/Logs -Volatile logs (gone on reboot) are stored in `/dev/.acc/`, persistent logs - `/sdcard/Documents/vr25/acc/logs/`. +Volatile logs (gone on reboot) are stored in `/dev/.vr25/acc/`, persistent logs - `/sdcard/Documents/vr25/acc/logs/`. `acc -le` exports all acc logs, plus Magisk's and extras to `/sdcard/acc-$device_codename.tar.bz2`. The logs do not contain any personal information and are never automatically sent to the developer. @@ -874,6 +880,16 @@ Alternatively, a _compressed_ archive of translated `strings.sh` and `README.md` ## TIPS +### Current-based Charging Control (EXPERIMENTAL) + +Enabled by setting charging_switch=milliamps (e.g., 0, 250 mA). + +Essentially, this turns current control files into pseudo charging switches. +Charging may not actually stop, but it'll at least slowdown to the point where it would take a _very long_ time to fill the battery. + +A common positive side effect of this is pseudo idle mode - i.e., the battery may work just as a power buffer. + + ### Generic Emulate _battery idle mode_ with a voltage limit: `acc 101 0; acc -s v 3920`. @@ -882,7 +898,7 @@ The latter sets a voltage limit that will dictate how much the battery should ch The battery enters a _pseudo idle mode_ when its voltage peaks. Essentially, it works as a power buffer. -Limiting the charging current to zero mA (`acc -sc 0`) may produce the same effect. +Limiting the charging current to 0-250 mA or so (`acc -sc 250`) may produce the same effect. `acc -sc -` restores the default limit. Force fast charge: `appy_on_boot="/sys/kernel/fast_charge/force_fast_charge::1::0 usb/boost_current::1::0 charger/boost_current::1::0"` @@ -904,8 +920,6 @@ This extends the battery's lifespan and may even _reduce_ its discharge rate. 500mA is a comfortable minimum - and also very compatible. -0mA is for idle mode. - If your device does not support custom current limits, use a dedicated ("slow") power adapter. @@ -1039,17 +1053,6 @@ A common workaround is having `resume_capacity = pause_capacity - 1`. e.g., resu ## LATEST CHANGES -**v2020.10.8 (202010080)** - -- Changelog is sorted in reverse order (older first). -- Enhanced dynamic switch delay. -- Fixed capacity_freeze2 and capacity_sync. -- General optimizations -- Move persistent data to /sdcard/Documents/vr25/acc/ for compatibility with Android 11 storage isolation. -- Updated documentation (FAQ, tips, voltage issues, Samsung's "70% problem", etc.). -- Use `cmd` in place of most `dumpsys` calls. - - **v2020.10.14 (202010140)** - acc -i: show additional power supply info, if any. @@ -1066,3 +1069,24 @@ A common workaround is having `resume_capacity = pause_capacity - 1`. e.g., resu - Current control optimizations - Dynamically determine the right temperature reporter; use a dummy file (25°C) if none is found. + + +**v2020.10.24 (202010240)** + +- [Experimental] Current-based charging control - enabled by setting charging_switch=milliamps (e.g., 250). +- cooldown_current is no longer the default cooldown method due to issues observed on some devices. +- Fixed `acc -ss`. +- Major optimizations +- New charging switch for OnePlus Devices +- Shutdown if battery temp hits shutdown_temp, default: 65 degrees Celsius. +- Updated default config, project framework and readme. + +Release Notes + +- AccA has been found to be behind several issues, e.g., unwanted config resets, changes to config not sticking. +- If you still face issues after uninstalling AccA, see whether resetting acc config (`acc -sr`) helps. +- Recall that if you feel uncomfortable with terminal, you don't have to use it at all! +The config file can be edited manually (text editor). +The process is very straightforward. +Just do not edit in Windows Notepad, ever! +It replaces LF (Linux/Unix) with CRLF (Windows) line endings. diff --git a/TODO.txt b/TODO.txt index 91f1878..73ece1a 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,27 +1,3 @@ remove #legacy -support voltage control files with space-separated values (Samsung) - alerts - - -alternate charging control logic - - disable_charging() { - maxChargingCurrent0=${maxChargingCurrent[0]-} - set +e - set_ch_curr 0 - set -e - touch $TMPDIR/.ch-disabled - } - - enable_charging() { - set +e - set_ch_curr ${maxChargingCurrent0:--} - set -e - rm $TMPDIR/.ch-disabled - } - - not_charging() { - grep -Eiq "${1-dis|not}" $batt/status && [ ! -f $TMPDIR/.ch-disabled ] - } diff --git a/acc/acc.sh b/acc/acc.sh index 9e75ebe..5771bf7 100644 --- a/acc/acc.sh +++ b/acc/acc.sh @@ -20,7 +20,7 @@ daemon_ctrl() { return 8 else print_started - exec /dev/accd $config + exec /dev/.vr25/acc/accd $config fi ;; @@ -41,7 +41,7 @@ daemon_ctrl() { else print_started fi - exec /dev/accd $config + exec /dev/.vr25/acc/accd $config ;; *) @@ -172,7 +172,8 @@ misc_stuff "${1-}" # reset broken/obsolete config -(set +x; . $config) > /dev/null 2>&1 || cp -f $execDir/default-config.txt $config +(set +x; . $config) > /dev/null 2>&1 \ + || cp -f $execDir/default-config.txt $config . $config @@ -201,6 +202,16 @@ grep -q .. $execDir/translations/$language/README.md 2>/dev/null \ } +case "${1:-.}" in + -d|--disable|-e|--enable) + ! test ${chargingSwitch[0]:--1} -ge 0 2>/dev/null || { + . $execDir/alt-functions.sh + . $execDir/set-ch-curr.sh + } + ;; +esac + + case "${1-}" in "") @@ -256,14 +267,14 @@ case "${1-}" in pause_capacity=${2:-100} resume_capacity=$(( pause_capacity - 5 )) - run_cmd_on_pause="exec /dev/accd" + run_cmd_on_pause="exec /dev/.vr25/acc/accd" cp -f $config $TMPDIR/.acc-f-config config=$TMPDIR/.acc-f-config . $execDir/write-config.sh print_charging_enabled_until ${2:-100}% echo - exec /dev/accd $config + exec /dev/.vr25/acc/accd $config ;; @@ -392,7 +403,7 @@ case "${1-}" in config=$TMPDIR/.config set +e - trap '! $daemonWasUp || exec /dev/accd $config_' EXIT + trap '! $daemonWasUp || exec /dev/.vr25/acc/accd $config_' EXIT not_charging && enable_charging > /dev/null diff --git a/acc/acca.sh b/acc/acca.sh index b759c52..6528f6e 100644 --- a/acc/acca.sh +++ b/acc/acca.sh @@ -7,7 +7,7 @@ daemon_ctrl() { case "${1-}" in start|restart) - exec /dev/accd $config + exec /dev/.vr25/acc/accd $config ;; stop) . $execDir/release-lock.sh @@ -25,7 +25,7 @@ set -eu execDir=/data/adb/vr25/acc config=/sdcard/Documents/vr25/acc/config.txt defaultConfig=$execDir/default-config.txt -TMPDIR=/dev/.acc +TMPDIR=/dev/.vr25/acc verbose=false export execDir TMPDIR verbose @@ -120,4 +120,4 @@ esac # other acc commands set +eu -exec /dev/acc $config "$@" +exec /dev/.vr25/acc/acc $config "$@" diff --git a/acc/accd.sh b/acc/accd.sh index 16bff56..2c1c270 100644 --- a/acc/accd.sh +++ b/acc/accd.sh @@ -12,7 +12,7 @@ umask 0077 case "$1" in -i|--init) init=true; shift;; - *) test -f $TMPDIR/.config-ver && init=false || init=true;; ### + *) [ -f $TMPDIR/.config-ver ] && init=false || init=true;; ### esac @@ -29,7 +29,7 @@ pgrep zygote > /dev/null && { } -if [ -f $TMPDIR/.config-ver ] && ! $init; then ### +if ! $init; then exxit() { exitCode=$? @@ -75,12 +75,18 @@ if [ -f $TMPDIR/.config-ver ] && ! $init; then ### local file="" value="" isCharging=false . $config - not_charging || isCharging=true # run custom code eval "${loopCmd[@]-}" + # shutdown if battery temp >= shutdown_temp + [ $(cat $temp) -lt $(( ${temperature[3]} * 10 )) ] || { + am start -n android/com.android.internal.app.ShutdownActivity < /dev/null > /dev/null 2>&1 \ + || reboot -p 2>/dev/null \ + || /system/bin/reboot -p || : + } + if $isCharging; then # read chgStatusCode once @@ -100,11 +106,13 @@ if [ -f $TMPDIR/.config-ver ] && ! $init; then ### } $cooldown || resetBattStatsOnUnplug=true - - apply_on_plug + ${chargingDisabled:-false} || apply_on_plug + [ -z "${chargingDisabled-}" ] || enable_charging else + [ -z "${chargingDisabled-}" ] || chargingDisabled=false + # read dischgStatusCode once # and dynamically enable/disable capacitySync [ -n "$dischgStatusCode" ] || { @@ -296,6 +304,9 @@ if [ -f $TMPDIR/.config-ver ] && ! $init; then ### . $config + ! test ${chargingSwitch[0]:--1} -ge 0 2>/dev/null= || . $execDir/alt-functions.sh + + apply_on_boot ctrl_charging exit $? @@ -313,18 +324,28 @@ else # prepare executables ### + #legacy ln -fs $execDir/${id}.sh /dev/$id ln -fs $execDir/${id}.sh /dev/${id}d, ln -fs $execDir/${id}.sh /dev/${id}d. ln -fs $execDir/${id}a.sh /dev/${id}a ln -fs $execDir/service.sh /dev/${id}d + mkdir -p /dev/.$domain/$id + + ln -fs $execDir/${id}.sh /dev/.$domain/$id/$id + ln -fs $execDir/${id}.sh /dev/.$domain/$id/${id}d, + ln -fs $execDir/${id}.sh /dev/.$domain/$id/${id}d. + ln -fs $execDir/${id}a.sh /dev/.$domain/$id/${id}a + ln -fs $execDir/service.sh /dev/.$domain/$id/${id}d + test -d /sbin && { ! grep -q "^tmpfs / " /proc/mounts \ || /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 + for h in /dev/.$domain/$id/$id \ + /dev/.$domain/$id/${id}d, /dev/.$domain/$id/${id}d. \ + /dev/.$domain/$id/${id}a /dev/.$domain/$id/${id}d do ln -fs $h /sbin/ 2>/dev/null || break done @@ -442,7 +463,7 @@ else # start $id daemon - rm /dev/.$id/.ghost-charging 2>/dev/null ### + rm /dev/.$domain/$id/.ghost-charging 2>/dev/null ### exec $0 "$@" fi diff --git a/acc/acquire-lock.sh b/acc/acquire-lock.sh index 4bdcc86..fe33927 100644 --- a/acc/acquire-lock.sh +++ b/acc/acquire-lock.sh @@ -1,3 +1,4 @@ +# usage: . $0 id=acc set +o sh 2>/dev/null || : exec 4<>$TMPDIR/${id}.lock || exit 13 diff --git a/acc/alt-functions.sh b/acc/alt-functions.sh new file mode 100644 index 0000000..cd46848 --- /dev/null +++ b/acc/alt-functions.sh @@ -0,0 +1,14 @@ +disable_charging() { + maxChargingCurrent0=${maxChargingCurrent[0]-} + set +e + set_ch_curr ${chargingSwitch[0]:-0} + set -e + chargingDisabled=true +} + +enable_charging() { + set +e + set_ch_curr ${maxChargingCurrent0:--} + set -e + chargingDisabled=false +} diff --git a/acc/charging-switches.txt b/acc/charging-switches.txt index 38d8038..e864249 100644 --- a/acc/charging-switches.txt +++ b/acc/charging-switches.txt @@ -4,7 +4,7 @@ # # "::" = " " # PWD=/sys/class/power_supply -# Last updated: Wed, Sep 23, 2020 +# Last updated: Fri, Oct 23, 2020 battery/charger_control 1 0 */charge_disable 0 1 @@ -36,6 +36,7 @@ battery/store_mode 0 1 *-charger/charging_enabled 1 0 dc/input_suspend 0 1 battery/op_disable_charge 0 1 battery/input_suspend 0 0 +wireless/op_disable_charge 0 1 battery/device/smartchg_stop_charging 0 1 /proc/smb*_disable_chrg 0 1 diff --git a/acc/default-config.txt b/acc/default-config.txt index f9e5459..f2d683f 100644 --- a/acc/default-config.txt +++ b/acc/default-config.txt @@ -1,8 +1,8 @@ -configVerCode=202010120 -capacity=(-1 60 70 75 false) -temperature=(40 60 90) +configVerCode=202010240 +capacity=(0 60 70 75 false) +temperature=(40 60 90 65) cooldownRatio=() -cooldownCurrent=0 +cooldownCurrent= cooldownCustom=() resetBattStats=(false false) chargingSwitch=() @@ -11,7 +11,6 @@ applyOnPlug=() maxChargingCurrent=() maxChargingVoltage=() language=en -prioritizeBattIdleMode=true runCmdOnPause=() ampFactor= voltFactor= @@ -20,21 +19,31 @@ loopCmd=() # WARNINGS +# Do not edit this in Windows Notepad, ever! +# It replaces LF (Linux/Unix) with CRLF (Windows) line endings. + # As seen above, whatever is null can be null. # Nullifying values that should not be null causes nasty errors. # However, doing so with "--set var=" restores the default value of "var". # In other words, for regular users, "--set" is safer than modifying the config file directly. -# Do NOT feel like you must configure everything! -# If you don't know EXACTLY how to and why you want to do it, it's a very dumb idea. -# Help is always available, from multiple sources - plus, you don't have to pay a penny for it. +# Do not feel like you must configure everything! +# Do not change what you don't understand. +# Help is always available, from multiple sources - besides, I don't charge a penny for it. + + +# NOTES + +# The daemon does not have to be restarted after making changes to this file - unless one of the changes is charging_switch and the following logical condition is true: not_charging AND capacity >= resume_capacity. + +# If charging_switch is changed with --set (e.g., -ss, -s s="...", --set charging_switch="..."), accd is restarted automatically, according to the aforementioned condition. -# BASIC CONFIG EXPLANATION +# BASICS # capacity=(shutdown_capacity cooldown_capacity resume_capacity pause_capacity capacity_freeze2) -# temperature=(cooldown_temp max_temp max_temp_pause) +# temperature=(cooldown_temp max_temp max_temp_pause shutdown_temp) # cooldownRatio=(cooldown_charge cooldown_pause) @@ -56,8 +65,6 @@ loopCmd=() # language=lang=language_code -# prioritizeBattIdleMode=prioritize_batt_idle_mode=true/false - # runCmdOnPause=run_cmd_on_pause=(. script) # ampFactor=amp_factor=[multiplier] @@ -82,6 +89,8 @@ loopCmd=() # mt max_temp # mtp max_temp_pause +# st shutdown_temp + # ccu cooldown_custom # cdc cooldown_current @@ -97,7 +106,6 @@ loopCmd=() # mcv max_charging_voltage # l lang -# pbim prioritize_batt_idle_mode # rcp run_cmd_on_pause # af amp_factor @@ -136,6 +144,8 @@ loopCmd=() # acc -s cooldown_current=500 +# acc -s st=60 + # FINE, BUT WHAT DOES EACH OF THESE VARIABLES ACTUALLY MEAN? @@ -143,8 +153,7 @@ loopCmd=() # This is checked during updates to determine whether config should be patched. Do NOT modify. # shutdown_capacity (sc) # -# When the battery is discharging and its capacity <= 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 voltages below the operating range. -# On capacity <= shutdown_capacity + 5, accd enables Android battery saver, triggers 5 vibrations once - and again on each subsequent capacity drop. +# When the battery is discharging and its capacity <= 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. # cooldown_capacity (cc) # # Capacity at which the cooldown cycle starts. @@ -173,6 +182,9 @@ loopCmd=() # Unlike the cooldown cycle, which aims at reducing BOTH high temperature and high voltage induced stress - this is ONLY meant specifically for reducing high temperature induced stress. # Even though both are separate features, this complements the cooldown cycle when environmental temperatures are off the charts. +# shutdown_temp (st) # +# Shutdown the system if battery temperature >= this value. + # cooldown_charge (cch) # # cooldown_pause (cp) # # These two dictate the cooldown cycle intervals (seconds). @@ -187,8 +199,7 @@ loopCmd=() # Refer back the command examples. # cooldown_current (cdc) # -# Instead of pausing charging periodically during the cooldown phase, lower the charging current. -# This is the default behavior (smoother). +# Instead of pausing charging periodically during the cooldown phase, limit the max charging current (e.g., to 500 mA) # reset_batt_stats_on_pause (rbsp) # # Reset battery stats after pausing charging. @@ -222,10 +233,6 @@ loopCmd=() # lang (l) # # acc language, managed with "acc --set --lang" (acc -s l). -# prioritize_batt_idle_mode (pbim) # -# Several devices can draw power directly from the external power supply when charging is paused. Test yours with "acc -t". -# This setting dictates whether charging switches that support such feature should take precedence. - # run_cmd_on_pause (rcp) # # Run commands* after pausing charging. # * Usually a script ("sh some_file" or ". some_file") diff --git a/acc/logf.sh b/acc/logf.sh index 8c0585d..7c74ebe 100644 --- a/acc/logf.sh +++ b/acc/logf.sh @@ -2,6 +2,9 @@ logf() { if [[ "${1:-x}" = -*e* ]]; then + data_dir=/sdcard/Documents/vr25/acc + mkdir -p $data_dir/logs + exec 2>> ${log:-/dev/null} cd $TMPDIR set +e @@ -22,9 +25,6 @@ logf() { [ -f $file ] && cp $file ./ && break done - data_dir=/sdcard/Documents/vr25/acc - mkdir -p $data_dir - cp $data_dir/logs/* ./ 2>/dev/null grep -Ev '^#|^$' $config_ > ./config.txt set +x diff --git a/acc/misc-functions.sh b/acc/misc-functions.sh index e9ef3f4..26c792a 100644 --- a/acc/misc-functions.sh +++ b/acc/misc-functions.sh @@ -21,7 +21,8 @@ apply_on_boot() { apply_on_plug() { local entry="" file="" value="" default="" arg=${1:-value} - for entry in "${applyOnPlug[@]-}" "${maxChargingCurrent[@]-}" \ + for entry in "${applyOnPlug[@]-}" \ + "${maxChargingCurrent[@]:-$([ .$arg != .default ] || cat $TMPDIR/ch-curr-ctrl-files 2>/dev/null)}" \ "${maxChargingVoltage[@]-}" do set -- ${entry//::/ } @@ -77,12 +78,6 @@ cycle_switches() { } -cycle_switches_off() { - ! $prioritizeBattIdleMode || cycle_switches off not - not_charging || cycle_switches off -} - - disable_charging() { local autoMode=true @@ -99,25 +94,25 @@ disable_charging() { chmod u+w ${chargingSwitch[3]} && run_xtimes "echo ${chargingSwitch[5]//::/ } > ${chargingSwitch[3]}" || { $isAccd || print_switch_fails unset_switch - cycle_switches_off + cycle_switches off } } if $autoMode && ! sleep_sd not_charging; then unset_switch - cycle_switches_off + cycle_switches off fi else $isAccd || print_switch_fails unset_switch - cycle_switches_off + cycle_switches off fi else $isAccd || print_invalid_switch unset_switch - cycle_switches_off + cycle_switches off fi else - cycle_switches_off + cycle_switches off fi not_charging || ! $autoMode || return 7 # total failure @@ -290,13 +285,14 @@ wait_plug() { # environment id=acc +domain=vr25 umask 0077 switchDelay=2 loopDelay=(10 10) -execDir=/data/adb/vr25/acc +execDir=/data/adb/$domain/acc ctrlFileWrites=(3 0.3) -export TMPDIR=/dev/.acc -config=/sdcard/Documents/vr25/$id/config.txt +export TMPDIR=/dev/.vr25/acc +config=/sdcard/Documents/$domain/$id/config.txt config_=$config [ -f $TMPDIR/.ghost-charging ] \ diff --git a/acc/oem-custom.sh b/acc/oem-custom.sh index 5068402..a3e9380 100644 --- a/acc/oem-custom.sh +++ b/acc/oem-custom.sh @@ -1,5 +1,4 @@ -( -grep_() { grep -Eq "$1" ${2:-$config}; } +(grep_() { grep -Eq "$1" ${2:-$config}; } get_prop() { sed -n "\|^$1=|s|.*=||p" ${2:-$config} 2>/dev/null || :; } @@ -13,17 +12,20 @@ if (set +x; . $config) > /dev/null 2>&1; then [ $configVer -eq $defaultConfVer ] || { if [ $configVer -lt 202009230 ]; then cp -f $execDir/default-config.txt $config + elif [ $configVer -lt 202010220 ]; then + ! grep_ cooldownCurrent=0 || /dev/.vr25/acc/acca --set cooldown_current= else - /dev/acca --set dummy= + /dev/.vr25/acc/acca --set dummy= fi + ! grep_ prioritize || /dev/.vr25/acc/acca --set dummy= } else cp -f $execDir/default-config.txt $config fi 2>/dev/null -# battery idle mode for OnePlus 7/Pro -if grep_ '^chargingSwitch=.*/op_disable_charge'; then +# battery idle mode for OnePlus devices +if grep_ '^chargingSwitch=.*battery/op_disable_charge'; then [ -f $TMPDIR/oem-custom ] \ || echo "run_xtimes 'echo 1 > battery/op_disable_charge; echo 0 > battery/input_suspend'" > $TMPDIR/oem-custom grep_ "^loopCmd=.*$TMPDIR/oem-custom" \ @@ -79,5 +81,4 @@ set -e sed -i /charge_control_limit/d $TMPDIR/ch-switches sed -i /charge_control_limit/d $execDir/charging-switches.txt } -} -) +}) diff --git a/acc/post-fs-data.sh b/acc/post-fs-data.sh index 1cbbf0b..8ba700d 100644 --- a/acc/post-fs-data.sh +++ b/acc/post-fs-data.sh @@ -2,6 +2,9 @@ # Workaround for EdXposed's service.sh bug id=acc -ls -d /data/adb/modules/riru_edxposed_* > /dev/null 2>&1 \ - && exec /data/adb/vr25/$id/service.sh +domain=vr25 +for f in /data/adb/modules/riru_edxposed_*/module.prop +do + [ -f $f ] && exec /data/adb/$domain/$id/service.sh +done exit 0 diff --git a/acc/power-supply-logger.sh b/acc/power-supply-logger.sh index ebd714e..83ab5ed 100644 --- a/acc/power-supply-logger.sh +++ b/acc/power-supply-logger.sh @@ -37,7 +37,7 @@ gather_ps_data() { } -export TMPDIR=/dev/.acc +export TMPDIR=/dev/.vr25/acc execDir=/data/adb/vr25/acc logsDir=/sdcard/Documents/vr25/acc/logs diff --git a/acc/print-config.sh b/acc/print-config.sh index 93c206e..b844ba0 100644 --- a/acc/print-config.sh +++ b/acc/print-config.sh @@ -13,6 +13,8 @@ cooldown_pause=${cooldownRatio[1]} max_temp=${temperature[1]} max_temp_pause=${temperature[2]} +shutdown_temp=${temperature[3]} + cooldown_current=$cooldownCurrent cooldown_custom=${cooldownCustom[@]} @@ -32,8 +34,6 @@ max_charging_voltage=${maxChargingVoltage[@]} lang=$language -prioritize_batt_idle_mode=$prioritizeBattIdleMode - run_cmd_on_pause=${runCmdOnPause[@]} amp_factor=$ampFactor diff --git a/acc/release-lock.sh b/acc/release-lock.sh index 19f141c..7a4d414 100644 --- a/acc/release-lock.sh +++ b/acc/release-lock.sh @@ -1,6 +1,6 @@ -#!/system/bin/sh -id=acc -(pid= +# usage: . $0 +(id=acc +pid= set +euo sh 2>/dev/null || : flock -n 0 || { read pid diff --git a/acc/service.sh b/acc/service.sh index 5921278..792d4e0 100644 --- a/acc/service.sh +++ b/acc/service.sh @@ -1,19 +1,17 @@ #!/system/bin/sh -# Advanced Charging Controller (ACC) Initializer +# $id initializer # Copyright 2017-2020, VR25 # License: GPLv3+ -# -# devs: triple hashtags (###) mark non-generic code - id=acc -TMPDIR=/dev/.$id -execDir=/data/adb/vr25/$id +domain=vr25 +TMPDIR=/dev/.$domain/$id +execDir=/data/adb/$domain/$id umask 0077 mkdir -p $TMPDIR -export id execDir TMPDIR +export domain execDir id TMPDIR . $execDir/setup-busybox.sh -$execDir/release-lock.sh -exec start-stop-daemon -bx $execDir/${id}d.sh -S -- "$@" || exit 12 ### +. $execDir/release-lock.sh +exec start-stop-daemon -bx $execDir/${id}d.sh -S -- "$@" || exit 12 diff --git a/acc/set-prop.sh b/acc/set-prop.sh index 915bd17..b8a88d9 100644 --- a/acc/set-prop.sh +++ b/acc/set-prop.sh @@ -1,32 +1,29 @@ -set_prop() { +print_charging_enabled() { + : +} + + +reset_switch() { + if not_charging && \ + [ $(cat $batt/capacity) -ge ${capacity[2]} ] + then + enable_charging + fi +} - local daemonWasUp=true restartDaemon=false - daemon_ctrl > /dev/null || daemonWasUp=false +set_prop() { - (case ${1-} in + case ${1-} in # set multiple properties *=*) - case "$*" in - s=*|*\ s=*|*charging_switch=*|*sc=*|*shutdown_capacity=*) - ! $daemonWasUp || daemon_ctrl stop > /dev/null - restartDaemon=true - ;; - esac - . $defaultConfig . $config export "$@" - case "$*" in - *ab=*|*apply_on_boot=*) - apply_on_boot - ;; - esac - [ .${mcc-${max_charging_current-x}} = .x ] || { . $execDir/set-ch-curr.sh set_ch_curr ${mcc:-${max_charging_current:--}} || : @@ -40,10 +37,9 @@ set_prop() { # reset config r|--reset) - ! $daemonWasUp || daemon_ctrl stop > /dev/null + reset_switch cp -f $defaultConfig $config print_config_reset - ! $daemonWasUp || /dev/accd return 0 ;; @@ -62,21 +58,20 @@ set_prop() { # set charging switch s|--charging*witch) - ! $daemonWasUp || daemon_ctrl stop > /dev/null - restartDaemon=true IFS=$'\n' PS3="$(print_choice_prompt)" print_known_switches . $execDir/select.sh - select_ charging_switch $(print_auto; cat $TMPDIR/ch-switches; print_exit) - [ ${chargingSwitch:-x} != $(print_exit) ] || exit 0 - [ ${chargingSwitch:-x} != $(print_auto) ] || charging_switch= + select_ charging_switch $(print_auto; cat $TMPDIR/ch-switches; ! grep -q / $TMPDIR/ch-curr-ctrl-files || printf '0\n250\n'; print_exit) + [ ${charging_switch:-x} != $(print_exit) ] || exit 0 + [ ${charging_switch:-x} != $(print_auto) ] || charging_switch= unset IFS ;; # print switches s:|--charging*witch:) cat $TMPDIR/ch-switches + ! grep -q / $TMPDIR/ch-curr-ctrl-files || printf '0\n250\n' return 0 ;; @@ -118,8 +113,8 @@ set_prop() { esac + [ ".${s-${charging_switch-x}}" = .x ] || reset_switch + # update config.txt . $execDir/write-config.sh - - ! $restartDaemon || { ! $daemonWasUp || /dev/accd; }) } diff --git a/acc/strings.sh b/acc/strings.sh index 2e2cd96..a0c31cb 100644 --- a/acc/strings.sh +++ b/acc/strings.sh @@ -243,7 +243,7 @@ Options acc -t battery/charging_enabled 1 0 acc -t /proc/mtk_battery_cmd/current_cmd 0::0 0::1 /proc/mtk_battery_cmd/en_power_path 1 0 ("::" is a placeholder for " ") - -t|--test [file] Test charging switches from a file (default: /dev/.acc/ch-switches) + -t|--test [file] Test charging switches from a file (default: /dev/.vr25/acc/ch-switches) This will also report whether "battery idle" mode is supported e.g., acc -t (test known switches) @@ -290,7 +290,7 @@ Exit Codes 10. "--test" failed 11. Current (mA) out of range 12. Initialization failed - 13. Failed to lock /dev/.$id/${id}.lock + 13. Failed to lock /dev/.vr25/acc/acc.lock Logs are exported automatically ("--log --export") on exit codes 1, 2, 7 and 10. diff --git a/acc/uninstall.sh b/acc/uninstall.sh index 22202ed..257f64d 100644 --- a/acc/uninstall.sh +++ b/acc/uninstall.sh @@ -8,7 +8,8 @@ set -u id=acc -export TMPDIR=/dev/.$id +domain=vr25 +export TMPDIR=/dev/.$domain/$id # set up busybox #BB# @@ -54,11 +55,11 @@ pgrep -f "/($id|${id}a) (-|--)[det]|/${id}d" > /dev/null && { #legacy } # uninstall $id ### -rm -rf /data/adb/vr25/$id \ +rm -rf /data/adb/$domain/$id \ /data/adb/modules/$id \ /data/adb/service.d/${id}-*.sh \ /data/data/mattecarra.accapp/files/$id \ - $(test "${1:-}" = install || echo "/sdcard/Documents/vr25/$id") + $(test "${1:-}" = install || echo "/sdcard/Documents/$domain/$id") #legacy rm -rf $(readlink -f /data/adb/$id) \ @@ -69,8 +70,8 @@ rm -rf $(readlink -f /data/adb/$id) \ /sdcard/${id}-uninstaller.zip \ /sdcard/.${id}-config-backup.txt \ /sdcard/Download/$id \ - /sdcard/vr25 \ - /sdcard/Documents/vr25/$id/.acc-config-backup.txt \ + /sdcard/$domain \ + /sdcard/Documents/$domain/$id/.acc-config-backup.txt \ /data/data/com.termux/files/home/.termux/boot/${id}-init.sh 2>/dev/null exit 0 diff --git a/acc/wizard.sh b/acc/wizard.sh index cff8b54..830801a 100644 --- a/acc/wizard.sh +++ b/acc/wizard.sh @@ -32,7 +32,7 @@ e) $(print_exit) 1) . $execDir/set-prop.sh; set_prop --lang - exec /dev/acc + exec /dev/.vr25/acc/acc ;; 2) @@ -47,7 +47,7 @@ e) $(print_exit) ;; 4) - /dev/accd + /dev/.vr25/acc/accd sleep 1 exec wizard ;; @@ -76,7 +76,7 @@ e) $(print_exit) echo -n "%? " read level clear - /dev/acc --full ${level-} + /dev/.vr25/acc/acc --full ${level-} exit $? ;; @@ -100,17 +100,17 @@ e) $(print_exit) ;; b) - /dev/acc --test || : + /dev/.vr25/acc/acc --test || : print_press_key read -n 1 exec wizard ;; c) - /dev/acc --upgrade --changelog || : + /dev/.vr25/acc/acc --upgrade --changelog || : print_press_key read -n 1 - exec /dev/acc + exec /dev/.vr25/acc/acc ;; d) @@ -122,7 +122,7 @@ e) $(print_exit) echo print_press_key read -n 1 - exec /dev/acc + exec /dev/.vr25/acc/acc ;; e) diff --git a/acc/write-config.sh b/acc/write-config.sh index 6b90187..3c03907 100644 --- a/acc/write-config.sh +++ b/acc/write-config.sh @@ -9,6 +9,7 @@ cft=${capacity_freeze2-${cft-${capacity[4]}}} ct=${cooldown_temp-${ct-${temperature[0]}}} mt=${max_temp-${mt-${temperature[1]}}} mtp=${max_temp_pause-${mtp-${temperature[2]}}} +st=${shutdown_temp-${st-${temperature[3]}}} cdc=${cooldown_current-${cdc-$cooldownCurrent}} @@ -30,7 +31,6 @@ mcv="${max_charging_voltage-${mcv-${maxChargingVoltage[@]}}}" l=${lang-${l-${language}}} -pbim=${prioritize_batt_idle_mode-${pbim-${prioritizeBattIdleMode}}} rcp="${run_cmd_on_pause-${rcp-${runCmdOnPause[@]}}}" af=${amp_factor-${af-$ampFactor}} @@ -41,10 +41,10 @@ lc="${loop_cmd-${lc-${loopCmd[@]}}}" { echo "configVerCode=$(cat $TMPDIR/.config-ver) -capacity=(${sc:--1} ${cc:-60} ${rc:-70} ${pc:-75} ${cft:-false}) -temperature=(${ct:-40} ${mt:-60} ${mtp:-90}) +capacity=(${sc:-0} ${cc:-60} ${rc:-70} ${pc:-75} ${cft:-false}) +temperature=(${ct:-40} ${mt:-60} ${mtp:-90} ${st:-65}) cooldownRatio=($cch $cp) -cooldownCurrent=${cdc-0} +cooldownCurrent=$cdc cooldownCustom=($ccu) resetBattStats=(${rbsp:-false} ${rbsu:-false}) chargingSwitch=($s) @@ -53,7 +53,6 @@ applyOnPlug=($ap) maxChargingCurrent=($mcc) maxChargingVoltage=($mcv) language=${lang:-en} -prioritizeBattIdleMode=${pbim:-false} runCmdOnPause=($rcp) ampFactor=$af voltFactor=$vf diff --git a/bin/acc-uninstaller.zip b/bin/acc-uninstaller.zip index 9a35e409b124cfb5bb00152155c20814ccf9f8cc..9f45258cfff481bb9db4af5d8b23a53a014b761a 100644 GIT binary patch delta 1145 zcmZ3$zlxtXz?+$civa|ZX9Z2P$P^2d}v+BN%T?@_(o z`(%ZV-^0Ie>(Bl=tMBNM&vd)Z(=_Y*VD%0x#=v?fY89z4S}CG4Y+sMN{E>_$h2 zhl=Z%G}C%MJG^M}G>w+#YMdP;%|8F%zP-El&0czBu9`Eyhvv+NM_126$+K_kpbs^hd>3y+QVmWGe{k3ZHMPmW>OsP|&742G*rf4UcZ%g>j!X58A?{PvAZJ8H0tLllt&KeyL+h=^filW6c)~Tolu0w8GFzxeZ09rW4$&Td=lls1x!>|Mq<^^YC$>VH{dxYu-zI##O8+Wq>x&;3 z{^t0%Bj@Dhhs`3tm$0#Kx$3ynB;wj;a}Rfw?CUckSr%7_AHOKx_^$4G?U4ny(<=T- z$tj#EJo#hVlqq&Ex+`AQ1@P}&7jk*$!xNA8PjN0`bTY5qY&mJw=fivIS1*6@U!#|8 z3&)ZIztU*I?h9P=UCgFdF1%8Eci-{Vw@cRP)z8*cFuU9O_KxX~<>t{_xoOk+gQjY-eXPtQpu(=-_zrX}X36y;~85HwYUfr)_w99rS6PPPHe z3=H?#85lGPm|9wpl30?eo0OTCSX7BGG^d8%&%bRZQ1?8(aB7d!DYcV@f+EG!7+y1# z95hnk=-Ruba>2^Yt`SP6lZxIR`***5%9A5So6M>WU+jKwSGOmg>wZd^T4)-#*ddQ+ z7c^F`d7RqWrjs&3OlOx*Msk3~nZ#|4k;e?4}>^~uWd-u$jS*`MREpLofvR?%3 zwbj^`@LhMzp2OgyCc!Q+kK z>He>Ex=S>^l{TN|TQX~tO+c4+oRdKp+l?RAPaIF@ZR{3nZBwWcK3vLw|Nb)Gh{&r? z*4)e=2K>FF!0Z{8M#va{6NSneT)6 z(@YMoiIZ4U`<^w@Wz)8`vyTg?-d5?ffBxd#_E;Y|nQ4;u_O-Hec*hiMR8%c3f4RD% z#&$)UlliK(cQiKr;NPog*B-OIbhGNDRhMh`*ME-vQa|MwBQKNYoWOh2j!epK^;f!m zW>3(obJO1!9^N+fbEdJV%Cmxm@U)_7mG7rJCSQ~>Q@tf_BX+iHTJEg!a8>m!bNChB z`X8O^e6aVS=G(xy>o;TMHuWmCUkfaf^ILvWuYvo<>m_@m4BX>zhZm%|J$v+J8t<;yZ?(lW$zZf4Oh6mJqzwE zQP{F$gg&T8TU0HjVp=9a)RY9Nscvimu@YBLcZn@Uym;d$u zEidAXU0Qc(c4_=_r|=nXeT~<~{+C#}Vi!uvJ@a0)$Uq^S(U~jGfZ$>6LW?aRo1kg?p5McP>2%?b+S5`>jiczrQ zHjbA8**Irp;~)hs=|+m67}0Wd-p7t2=o@ diff --git a/build.sh b/build.sh index 8d1690c..165720b 100644 --- a/build.sh +++ b/build.sh @@ -22,6 +22,8 @@ set_prop() { id=$(sed -n "s/^id=//p" module.prop) +domain=$(sed -n "s/^domain=//p" module.prop) + version=$(grep '\*\*.*\(.*\)\*\*' README.md \ | tail -n 1 | sed 's/\*\*//; s/ .*//') @@ -46,6 +48,14 @@ for file in ./install*.sh ./$id/*.sh ./bundle.sh; do done +# set domain +for file in ./install*.sh ./$id/*.sh ./bundle.sh; do + if [ -f "$file" ] && grep -Eq '(^|\()domain=' $file; then + grep -Eq "(^|\()domain=$domain" $file || set_prop domain $domain $file + fi +done + + # update README if [ README.md -ot $id/default-config.txt ] \ diff --git a/customize.sh b/customize.sh index 6df606d..c1318e6 100644 --- a/customize.sh +++ b/customize.sh @@ -12,8 +12,9 @@ SKIPUNZIP=1 echo id=acc +domain=vr25 umask 0077 -data_dir=/sdcard/Documents/vr25/$id +data_dir=/sdcard/Documents/$domain/$id # log @@ -26,7 +27,7 @@ set -x exxit() { local e=$? set +eu - rm -rf /dev/.${id}-install /data/adb/modules_update/$id + rm -rf /dev/.$domain.${id}-install /data/adb/modules_update/$id (abort) > /dev/null echo exit $e @@ -92,7 +93,7 @@ srcDir=${srcDir/#"${0##*/}"/"."} # extract flashable zip if source code is unavailable [ -f $srcDir/module.prop ] || { - srcDir=/dev/.${id}-install + srcDir=/dev/.$domain.${id}-install rm -rf $srcDir 2>/dev/null || : mkdir $srcDir unzip "${3:-${ZIPFILE}}" -d $srcDir/ >&2 @@ -138,6 +139,7 @@ GPLv3+ # migrate #legacy data + if [ -d /data/adb/${id}-data ]; then mv -f /data/adb/${id}-data/* /data/adb/${id}-data/.* \ $data_dir/ 2>/dev/null || : @@ -145,11 +147,14 @@ elif [ -d /sdcard/Download/$id ]; then mv -f /sdcard/Download/$id/* /sdcard/Download/$id/.* \ $data_dir/ 2>/dev/null || : else - mv -f /sdcard/vr25/$id/* /sdcard/vr25/$id/.* \ + mv -f /sdcard/$domain/$id/* /sdcard/$domain/$id/.* \ $data_dir/ 2>/dev/null || : fi rm -rf $data_dir/info 2>/dev/null || : +mkdir -p /dev/.$domain +mv /dev/.$id /dev/.$domain/$id 2>/dev/null || : + /system/bin/sh $srcDir/$id/uninstall.sh install cp -R $srcDir/$id/ $installDir/ @@ -193,7 +198,7 @@ if $acca; then sleep 60 - [ -e /data/data/mattecarra.${id}app/files/$id ] || rm -rf \$0 /data/adb/vr25/$id /data/adb/modules/$id 2>/dev/null + [ -e /data/data/mattecarra.${id}app/files/$id ] || rm -rf \$0 /data/adb/$domain/$id /data/adb/modules/$id 2>/dev/null exit 0" | sed 's/^ //' > /data/adb/service.d/${id}-cleanup.sh chmod 0700 /data/adb/service.d/${id}-cleanup.sh @@ -201,9 +206,9 @@ if $acca; then fi -[ $installDir = /data/adb/vr25/$id ] || { +[ $installDir = /data/adb/$domain/$id ] || { mkdir -p /data/adb/vr25 - ln -s $installDir /data/adb/vr25/ + ln -s $installDir /data/adb/$domain/ } @@ -261,15 +266,15 @@ echo " (i) Rebooting is unnecessary -- $id commands may require the /dev/ prefix (e.g., /dev/$id) until system is rebooted. +- $id commands may require the "/dev/.$domain/$id/" prefix (e.g., /dev/.$domain/$id/$id -v) until system is rebooted. - Daemon started." [ $installDir = /data/adb ] && echo " -(i) Non-Magisk users can enable $id auto-start by running /data/adb/vr25/$id/service.sh, a copy of, or a link to it - with init.d or an app that emulates it." +(i) Non-Magisk users can enable $id auto-start by running /data/adb/$domain/$id/service.sh, a copy of, or a link to it - with init.d or an app that emulates it." # initialize $id -/data/adb/vr25/$id/service.sh --init +/data/adb/$domain/$id/service.sh --init exit 0 diff --git a/framework-details.txt b/framework-details.txt index 609d1db..bc3158a 100644 --- a/framework-details.txt +++ b/framework-details.txt @@ -58,7 +58,7 @@ Tasks Carried Out By build.sh 2. Update version and versionCode in module.prop (values come from README.md > LATEST CHANGES). -3. Set the correct id (from module.prop) in install*.sh, $id/*.sh and bundle.sh. +3. Set the correct id and domain (from module.prop) in install*.sh, $id/*.sh and bundle.sh. 4. Patch README.md. diff --git a/install-online.sh b/install-online.sh index 509f832..3f2b46d 100644 --- a/install-online.sh +++ b/install-online.sh @@ -14,8 +14,9 @@ set +x echo id=acc +domain=vr25 umask 0077 -data_dir=/sdcard/Documents/vr25/$id +data_dir=/sdcard/Documents/$domain/$id # log [ -z "${LINENO-}" ] || export PS4='$LINENO: ' @@ -79,7 +80,7 @@ reference=$(echo "$*" | sed -E 's/%.*%|-c|--changelog|-f|--force|-k|--insecure|- tarball=https://github.com/VR-25/$id/archive/${reference}.tar.gz -installedVersion=$(get_ver /data/adb/vr25/$id/module.prop 2>/dev/null || :) +installedVersion=$(get_ver /data/adb/$domain/$id/module.prop 2>/dev/null || :) onlineVersion=$(curl -L $insecure https://raw.githubusercontent.com/VR-25/$id/${reference}/module.prop | get_ver) diff --git a/install-tarball.sh b/install-tarball.sh index 0dd9ddb..f690925 100644 --- a/install-tarball.sh +++ b/install-tarball.sh @@ -4,8 +4,9 @@ # License: GPLv3+ id=acc +domain=vr25 umask 0077 -data_dir=/sdcard/Documents/vr25/${1:-$id} +data_dir=/sdcard/Documents/$domain/${1:-$id} # log [ -z "${LINENO-}" ] || export PS4='$LINENO: ' @@ -76,9 +77,9 @@ case "$PWD" in *mattecarra.accapp*) get_ver() { sed -n '/^versionCode=/s/.*=//p' $1/module.prop 2>/dev/null || echo 0; } bundled_ver=$(get_ver ${1:-$id}[-_]*) - regular_ver=$(get_ver /data/adb/vr25/$id) + regular_ver=$(get_ver /data/adb/$domain/$id) if [ $bundled_ver -le $regular_ver ] && [ $regular_ver -ne 0 ]; then - ln -s $(readlink -f /data/adb/vr25/$id) . + ln -s $(readlink -f /data/adb/$domain/$id) . (cd ./${1:-$id}/; ln -fs service.sh ${1:-$id}-init.sh) exit 0 fi 2>/dev/null || : diff --git a/install.sh b/install.sh index 6df606d..c1318e6 100644 --- a/install.sh +++ b/install.sh @@ -12,8 +12,9 @@ SKIPUNZIP=1 echo id=acc +domain=vr25 umask 0077 -data_dir=/sdcard/Documents/vr25/$id +data_dir=/sdcard/Documents/$domain/$id # log @@ -26,7 +27,7 @@ set -x exxit() { local e=$? set +eu - rm -rf /dev/.${id}-install /data/adb/modules_update/$id + rm -rf /dev/.$domain.${id}-install /data/adb/modules_update/$id (abort) > /dev/null echo exit $e @@ -92,7 +93,7 @@ srcDir=${srcDir/#"${0##*/}"/"."} # extract flashable zip if source code is unavailable [ -f $srcDir/module.prop ] || { - srcDir=/dev/.${id}-install + srcDir=/dev/.$domain.${id}-install rm -rf $srcDir 2>/dev/null || : mkdir $srcDir unzip "${3:-${ZIPFILE}}" -d $srcDir/ >&2 @@ -138,6 +139,7 @@ GPLv3+ # migrate #legacy data + if [ -d /data/adb/${id}-data ]; then mv -f /data/adb/${id}-data/* /data/adb/${id}-data/.* \ $data_dir/ 2>/dev/null || : @@ -145,11 +147,14 @@ elif [ -d /sdcard/Download/$id ]; then mv -f /sdcard/Download/$id/* /sdcard/Download/$id/.* \ $data_dir/ 2>/dev/null || : else - mv -f /sdcard/vr25/$id/* /sdcard/vr25/$id/.* \ + mv -f /sdcard/$domain/$id/* /sdcard/$domain/$id/.* \ $data_dir/ 2>/dev/null || : fi rm -rf $data_dir/info 2>/dev/null || : +mkdir -p /dev/.$domain +mv /dev/.$id /dev/.$domain/$id 2>/dev/null || : + /system/bin/sh $srcDir/$id/uninstall.sh install cp -R $srcDir/$id/ $installDir/ @@ -193,7 +198,7 @@ if $acca; then sleep 60 - [ -e /data/data/mattecarra.${id}app/files/$id ] || rm -rf \$0 /data/adb/vr25/$id /data/adb/modules/$id 2>/dev/null + [ -e /data/data/mattecarra.${id}app/files/$id ] || rm -rf \$0 /data/adb/$domain/$id /data/adb/modules/$id 2>/dev/null exit 0" | sed 's/^ //' > /data/adb/service.d/${id}-cleanup.sh chmod 0700 /data/adb/service.d/${id}-cleanup.sh @@ -201,9 +206,9 @@ if $acca; then fi -[ $installDir = /data/adb/vr25/$id ] || { +[ $installDir = /data/adb/$domain/$id ] || { mkdir -p /data/adb/vr25 - ln -s $installDir /data/adb/vr25/ + ln -s $installDir /data/adb/$domain/ } @@ -261,15 +266,15 @@ echo " (i) Rebooting is unnecessary -- $id commands may require the /dev/ prefix (e.g., /dev/$id) until system is rebooted. +- $id commands may require the "/dev/.$domain/$id/" prefix (e.g., /dev/.$domain/$id/$id -v) until system is rebooted. - Daemon started." [ $installDir = /data/adb ] && echo " -(i) Non-Magisk users can enable $id auto-start by running /data/adb/vr25/$id/service.sh, a copy of, or a link to it - with init.d or an app that emulates it." +(i) Non-Magisk users can enable $id auto-start by running /data/adb/$domain/$id/service.sh, a copy of, or a link to it - with init.d or an app that emulates it." # initialize $id -/data/adb/vr25/$id/service.sh --init +/data/adb/$domain/$id/service.sh --init exit 0 diff --git a/module.prop b/module.prop index f4b67bd..5e8af18 100644 --- a/module.prop +++ b/module.prop @@ -1,6 +1,7 @@ id=acc +domain=vr25 name=Advanced Charging Controller (ACC) -version=v2020.10.15 -versionCode=202010150 +version=v2020.10.24 +versionCode=202010240 author=VR25 description=ACC is an Android software mainly intended for extending battery service life. In a nutshell, this is achieved through limiting charging current, temperature and voltage. Any root solution is supported. The installation is always "systemless", whether or not the system is rooted with Magisk. If you're reading this from Magisk Manager > Downloads, tap here to open the documentation. Once there, if you feel lazy, scroll down to the quick start section.