Skip to content

Commit

Permalink
**2019.5.12 (201905120)**
Browse files Browse the repository at this point in the history
- Autofix Termux SU PATH
- Do not use Magic Mount; link everything to /sbin
- Enforce Magisk's busybox to prevent issues caused by outdated binaries
- Enhanced live upgrade; no more command prefix
- Fixed bugs and typos
- Removed nano from fallback editors list.
- Updated build tools and info
  • Loading branch information
VR-25 committed May 12, 2019
1 parent f921e3c commit 2f92195
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 83 deletions.
43 changes: 19 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ ACC is primarily intended for extending battery service life. On the flip side,

Dependencies

- curl (optional)
- git
- zip

Expand Down Expand Up @@ -92,7 +93,7 @@ Install

- Flash live (e.g., from Magisk Manager) or from custom recovery (e.g., TWRP).

- ACC suports live upgrades. This means you don't need to reboot after installing/upgrading to be able to use it. However, after installing it for the first time, you have to prefix `acc` with `/dev/acc/modPath/` (e.g., /dev/acc/*/acc -D) to run it before a reboot.
- ACC suports live upgrades. This means you don't need to reboot after installing/upgrading to be able to use it.

- The daemon is stopped before installation and restarted afterwards. It is started automatically even after the first install. Again, rebooting is unnecessary to get things running.

Expand All @@ -115,7 +116,7 @@ capacity=0,60,70-80
# Change this only if your system reports incorrect battery capacity ("acc -i" (BMS) vs "dumpsys battery" (system)).
capacityOffset=+0
# This is an alternative to CapacityOffset. It tells acc whether the battery capacity reported by Android should be updated every few seconds to reflect the actual value from the battery management system.
# This is an alternative to capacityOffset. It tells acc whether the battery capacity reported by Android should be updated every few seconds to reflect the actual value from the battery management system.
capacitySync=true
# <coolDown-pauseCharging_waitSeconds> - <waitSeconds> allow battery temperature to drop below <pauseCharging>. Temperature values are interpreted in Celsius degrees. To disable temperature control entirely, set absurdly high temperature values (e.g., temperature=90-95_90).
Expand Down Expand Up @@ -165,7 +166,6 @@ If you're not comfortable with the command line, skip this section and use the `
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.

Notes/Tips for Front-end Developers
- Apps should always run `/dev/acc/modPath/acc` (e.g., /dev/acc/modPath/acc --daemon restart) instead of the regular `acc`and `accd` commands. This ensures full compatibility with ACC's live upgrade feature.
- It's best to use full commands over short equivalents - e.g., `--set chargingSwitch` instead of `-s s`.
- Follow auto-install/upgrade instructions in `moduleZip/install-latest.sh`.
- Use provided config descriptions for ACC settings in the app. Include additional information (trusted) where appropriate.
Expand All @@ -176,8 +176,8 @@ Terminal Commands
```
acc <option(s)> <arg(s)>
-c|--config <editor [opts]> Edit config w/ <editor [opts]> (default: nano|vim|vi)
e.g., acc -c vim
-c|--config <editor [opts]> Edit config w/ <editor [opts]> (default: vim|vi)
e.g., acc -c
-d|--disable <#%, #s, #m or #h (optional)> Disable charging or disable charging with <condition>
e.g., acc -d 70% (do not recharge until capacity drops to 70%), acc -d 1h (do not recharge until 1 hour has passed)
Expand All @@ -200,13 +200,13 @@ acc <option(s)> <arg(s)>
-l|--log -e|--export Export all logs to /sdcard/acc-logs-<device>.tar.bz2
e.g., acc -l -e
-l|--log <editor [opts]> Open <acc-daemon-deviceName.log> w/ <editor [opts]> (default: nano|vim|vi)
-l|--log <editor [opts]> Open <acc-daemon-deviceName.log> w/ <editor [opts]> (default: vim|vi)
e.g., acc -l grep ': ' (show explicit errors only)
-L|--logwatch Monitor log
e.g., acc -L
-r|--readme Open <README.md> w/ <editor [opts]> (default: nano|vim|vi)
-r|--readme Open <README.md> w/ <editor [opts]> (default: vim|vi)
e.g., acc -r
-R|--resetbs Reset battery stats
Expand Down Expand Up @@ -296,15 +296,15 @@ Use `acc --voltage :millivolts` (e.g., acc -v :4050) for evaluating charging vol
- Slow charging
Nullify coolDownRatio (`acc --set coolDownRatio`) or change its value. By default, coolDownRatio is null.

- Logs are stored at `/dev/acc/`. You can export all to `/sdcard/acc-logs-$device.tar.bz2` with `acc --log --export`.
- Logs are stored at `/sbin/_acc/`. You can export all to `/sdcard/acc-logs-$device.tar.bz2` with `acc --log --export`.



---
## Power Supply Log


Please upload `/dev/acc/acc-power_supply-*.log` to [this dropbox](https://www.dropbox.com/request/WYVDyCc0GkKQ8U5mLNlH/).
Please upload `/sbin/_acc/acc-power_supply-*.log` to [this dropbox](https://www.dropbox.com/request/WYVDyCc0GkKQ8U5mLNlH/).
This file contains invaluable power supply information, such as battery details and available charging control files.
I'm creating a public database for mutual benefit.
Your cooperation is greatly appreciated.
Expand Down Expand Up @@ -342,14 +342,23 @@ See current submissions [here](https://www.dropbox.com/sh/rolzxvqxtdkfvfa/AABceZ
---
## LATEST CHANGES

**2019.5.12 (201905120)**
- Autofix Termux SU PATH
- Do not use Magic Mount; link everything to /sbin
- Enforce Magisk's busybox to prevent issues caused by outdated binaries
- Enhanced live upgrade; no more command prefix
- Fixed bugs and typos
- Removed nano from fallback editors list.
- Updated build tools and info

**2019.5.11 (201905110)**
- build.sh auto-updates update-binary (module_installer.sh)
- capacityOffset and capacitySync features for better control over battery capacity reported by the system
- Cleaner and more intuitive code - readability and maintenance
- coolDownRatio is null by default
- Enhanced daemon efficiency and flexibility
- Export logs to /sdcard/acc-logs-<device>.tar.bz2 with --log --export
- Fallback editors for --config and --log options:nano > vim > vi
- Fallback editors for --config and --log options: vim|vi
- Improved overall performance
- Live upgrade support - users don't need to reboot after installing/upgrading to use the module
- Major fixes and optimizations
Expand All @@ -368,17 +377,3 @@ See current submissions [here](https://www.dropbox.com/sh/rolzxvqxtdkfvfa/AABceZ

**2019.3.7-r1 (201903071)**
- Hotfix: new users can't install.

**2019.3.7 (201903070)**
- `acc --log` commands determine the target log file based on verbose state.
- Enhanced self-upgrade.
- Fixed installation error faced by some users.
- Generate `/dev/acc/installed` after successful install/upgrade.
- Include version code in log files.
- New (experimental) charging switches (in `switches.txt`)
- Reduced installer verbose.
- `resetUnplugged` doesn't apply within `coolDownRatioRatio` loop.
- Updated documentation (mainly the troubleshooting section).
- Updated installation instructions in `install.sh` (for app developers).
- Use regular `reboot` commands instead of the unreliable `am bla bla` for system reboot and power off.
- `vNow=mV_pauseSeconds` - monitor `voltage_now` as part of `coolDownRatioRatio` (experimental, default: null (off)).
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mkdir -p _builds

if [[ ${1:-x} != f ]]; then
echo "Downloading latest update-binary..."
curl -L https://raw.githubusercontent.com/topjohnwu/Magisk/master/scripts/module_installer.sh 2>/dev/null > _builds/update-binary \
curl -#L https://raw.githubusercontent.com/topjohnwu/Magisk/master/scripts/module_installer.sh > _builds/update-binary \
&& mv -f _builds/update-binary META-INF/com/google/android/
fi

Expand Down
35 changes: 17 additions & 18 deletions common/MODPATH/acc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ daemon() {
else
echo "(i) accd started"
set +x
$accd
accd
fi
;;
stop)
Expand All @@ -39,7 +39,7 @@ daemon() {
echo "(i) accd started"
fi
set +x
$accd
accd
;;
*)
if $isRunning; then
Expand All @@ -60,7 +60,7 @@ edit() {
if [ -n "${1:-}" ]; then
$@ $file
else
nano -$ $file 2>/dev/null || vim $file 2>/dev/null || vi $file
vim $file 2>/dev/null || vi $file
fi
}

Expand All @@ -74,8 +74,8 @@ Version code: $(sed -n 's/versionCode=//p' $modPath/module.prop)
Usage: acc <option(s)> <arg(s)>
-c|--config <editor [opts]> Edit config w/ <editor [opts]> (default: nano|vim|vi)
e.g., acc -c vim
-c|--config <editor [opts]> Edit config w/ <editor [opts]> (default: vim|vi)
e.g., acc -c
-d|--disable <#%, #s, #m or #h (optional)> Disable charging or disable charging with <condition>
e.g., acc -d 70% (do not recharge until capacity drops to 70%), acc -d 1h (do not recharge until 1 hour has passed)
Expand All @@ -98,13 +98,13 @@ Usage: acc <option(s)> <arg(s)>
-l|--log -e|--export Export all logs to /sdcard/acc-logs-<device>.tar.bz2
e.g., acc -l -e
-l|--log <editor [opts]> Open <acc-daemon-deviceName.log> w/ <editor [opts]> (default: nano|vim|vi)
-l|--log <editor [opts]> Open <acc-daemon-deviceName.log> w/ <editor [opts]> (default: vim|vi)
e.g., acc -l grep ': ' (show explicit errors only)
-L|--logwatch Monitor log
e.g., acc -L
-r|--readme Open <README.md> w/ <editor [opts]> (default: nano|vim|vi)
-r|--readme Open <README.md> w/ <editor [opts]> (default: vim|vi)
e.g., acc -r
-R|--resetbs Reset battery stats
Expand Down Expand Up @@ -177,9 +177,9 @@ set_value() {
[ $var = s ] && var=chargingSwitch || :
shift
if grep -q "^$var=" $config; then
sed -i "s|^$var=.*|$var=$@|" $config
sed -i "s|^$var=.*|$var=$*|" $config
elif grep -q "^#$var=" $config; then
sed -i "s|^#$var=.*|$var=$@|" $config
sed -i "s|^#$var=.*|$var=$*|" $config
else
echo "(!) Invalid variable, [$var]"
exit 1
Expand All @@ -198,7 +198,7 @@ set_values() {
cp -f $modPath/config.txt $config
chmod 0777 $config
echo "(i) Config reset"
daemon > /dev/null && daemon restart || :
accd
return 0
;;
*)
Expand Down Expand Up @@ -494,7 +494,7 @@ test_charging_switch() {

if not_charging; then
echo "(!) Battery must be charging"
$accd
accd
return 2
fi

Expand All @@ -504,19 +504,19 @@ test_charging_switch() {
if not_charging; then
echo "(i) [$file $on $off] works"
echo $default > $file
$accd
accd
return 0
else
echo "(!) [$file $on $off] doesn't work"
echo $default > $file
$accd
accd
return 1
fi
else
disable_charging > /dev/null
if not_charging; then
echo "(i) Supported device"
$accd
accd
return 0
else
echo "(!) Unsupported device"
Expand All @@ -540,10 +540,9 @@ umask 0
trap exxit EXIT
set -euo pipefail

modPath=/dev/acc/modPath
accd=$modPath/system/*bin/accd
modPath=/sbin/_acc/acc
config=/data/media/0/acc/config.txt
which busybox > /dev/null || PATH=/sbin/.magisk/busybox:$PATH
[[ $PATH == "*magisk/busybox*" ]] || PATH=/sbin/.magisk/busybox:$PATH
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 @@ -579,7 +578,7 @@ case ${1:-} in
enable_charging ${2:-100}%
set_charging_voltage $chargingVoltageLimit
unset chargingVoltageLimit
$accd
accd
;;

-i|--info) sed s/POWER_SUPPLY_// $batt/uevent | sed "/^CAPACITY=/s/=.*/=$(( $(cat $batt/capacity) $(get_value capacityOffset) ))/";;
Expand Down
19 changes: 9 additions & 10 deletions common/MODPATH/accd
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ disable_charging() {
value=$(get_value chargingSwitch | awk '{print $3}')
if [ -f $file ]; then
chmod +w $file && echo $value > $file 2>/dev/null \
|| $acc --set chargingSwitch- > /dev/null
|| acc --set chargingSwitch- > /dev/null
else
$acc --set chargingSwitch- > /dev/null
acc --set chargingSwitch- > /dev/null
fi
#sleep 1
#! is_charging || $acc --set chargingSwitch- > /dev/null
#! is_charging || acc --set chargingSwitch- > /dev/null
else
switch_loop off
! is_charging || exxit 1 "(!) Unsupported device"
Expand All @@ -89,9 +89,9 @@ enable_charging() {
value=$(get_value chargingSwitch | awk '{print $2}')
if [ -f $file ]; then
chmod +w $file && echo $value > $file 2>/dev/null \
|| $acc --set chargingSwitch- > /dev/null
|| acc --set chargingSwitch- > /dev/null
else
$acc --set chargingSwitch- > /dev/null
acc --set chargingSwitch- > /dev/null
fi
else
switch_loop on
Expand Down Expand Up @@ -223,11 +223,10 @@ set -euo pipefail
modId=acc
coolDown=false
resetBsOnUnplug=false
modPath=/dev/$modId/modPath
acc=$modPath/acc
modPath=/sbin/_$modId/$modId
config=/data/media/0/$modId/config.txt

which busybox > /dev/null || PATH=/sbin/.magisk/busybox:$PATH
[[ $PATH == "*magisk/busybox*" ]] || PATH=/sbin/.magisk/busybox:$PATH

log=${modPath%/*}/acc-daemon-$(getprop ro.product.device | grep .. || getprop ro.build.product).log

Expand All @@ -244,7 +243,7 @@ set -e

mkdir -p ${modPath%/*} ${config%/*}
[ -f $config ] || install -m 0777 $modPath/config.txt $config
cd /sys/class/power_supply
cd /sys/class/power_supply/

# diagnostics and cleanup
echo "###$(date)###" >> $log
Expand All @@ -256,7 +255,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 || :
acc --voltage apply > /dev/null 2>&1 || :
check_compatibility
ctrl_charging
exit $?
2 changes: 2 additions & 0 deletions common/MODPATH/accd-init
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/system/bin/sh
(/sbin/_acc/acc/accd &) &
4 changes: 2 additions & 2 deletions common/MODPATH/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@


# This is used to determine whether config should be patched. Do NOT modify!
versionCode=201905110
versionCode=201905111

# shutdown,coolDown,resume-pause
capacity=0,60,70-80

# Change this only if your system reports incorrect battery capacity ("acc -i" (BMS) vs "dumpsys battery" (system)).
capacityOffset=+0

# This is an alternative to CapacityOffset. It tells acc whether the battery capacity reported by Android should be updated every few seconds to reflect the actual value from the battery management system.
# This is an alternative to capacityOffset. It tells acc whether the battery capacity reported by Android should be updated every few seconds to reflect the actual value from the battery management system.
capacitySync=true

# <coolDown-pauseCharging_waitSeconds> - <waitSeconds> allow battery temperature to drop below <pauseCharging>. Temperature values are interpreted in Celsius degrees. To disable temperature control entirely, set absurdly high temperature values (e.g., temperature=90-95_90).
Expand Down
5 changes: 2 additions & 3 deletions common/MODPATH/psl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Copyright (C) 2019, VR25 @ xda-developers
# License: GPLv3+


gather_ps_data() {
local target="" target2=""
for target in $(ls -1 $1 | grep -Ev '^[0-9]|^block$|^dev$|^fs$|^ram$'); do
Expand All @@ -28,8 +27,8 @@ gather_ps_data() {
done
}

log=/dev/acc/acc-power_supply-$(getprop ro.product.device | grep .. || getprop ro.build.product).log
mkdir -p /dev/acc
log=/sbin/_acc/acc-power_supply-$(getprop ro.product.device | grep .. || getprop ro.build.product).log
mkdir -p /sbin/_acc

{
date
Expand Down
2 changes: 0 additions & 2 deletions common/MODPATH/system/xbin/acc

This file was deleted.

2 changes: 0 additions & 2 deletions common/MODPATH/system/xbin/accd

This file was deleted.

11 changes: 0 additions & 11 deletions common/post-fs-data.sh

This file was deleted.

Loading

0 comments on commit 2f92195

Please sign in to comment.