Skip to content

Commit

Permalink
**2019.6.14-r1 (201906141)**
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
VR-25 committed Jun 14, 2019
1 parent 8dc6ff6 commit 9c947b6
Show file tree
Hide file tree
Showing 13 changed files with 334 additions and 167 deletions.
72 changes: 50 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down Expand Up @@ -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/`.

Expand All @@ -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.



Expand Down Expand Up @@ -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.


Expand Down Expand Up @@ -228,6 +230,9 @@ acc <option(s)> <arg(s)>
-s|--set Show current config
e.g., acc -s
s|--set <r|reset> Restore default config
e.g., acc -s r
-s|--set <var> <value> Set config parameters
e.g., acc -s capacity 5,60,80-85 (5: shutdown (default), 60: cool down (default), 80: resume, 85: pause)
Expand All @@ -251,20 +256,20 @@ acc <option(s)> <arg(s)>
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 <millivolts|file:millivolts> 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 <millivolts> Set charging voltage limit (default/set ctrl file)
e.g., acc -v 4100
-v|--voltage <file:millivolts> Set charging voltage limit (custom ctrl file)
e.g., acc -v battery/voltage_max:4100
-x|--xtrace <other option(s)> Run under set -x (debugging)
acc -x -i
Expand Down Expand Up @@ -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`.

Expand Down Expand Up @@ -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/)
Expand All @@ -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
Expand All @@ -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
77 changes: 41 additions & 36 deletions acc/acc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,7 +19,7 @@ daemon() {
else
print_started
set +x
accd
/sbin/accd
fi
;;
stop)
Expand All @@ -39,7 +39,7 @@ daemon() {
print_started
fi
set +x
accd
/sbin/accd
;;
*)
if $isRunning; then
Expand Down Expand Up @@ -91,7 +91,7 @@ set_values() {
cp -f $modPath/config.txt $config
chmod 0777 $config
print_config_reset
accd
/sbin/accd
return 0
;;
*)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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/'
}

Expand Down Expand Up @@ -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

Expand All @@ -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
Expand All @@ -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||')

Expand Down Expand Up @@ -476,29 +480,30 @@ 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) ))/";;

-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
Expand Down
Loading

0 comments on commit 9c947b6

Please sign in to comment.