Skip to content

Commit

Permalink
**v2020.4.20-beta (202004200)**
Browse files Browse the repository at this point in the history
- Blacklisted troublesome Pixel [1-3]* charging switches
- Fixed absurd charging current and voltage reports (AccA)
- Fixed upgrade and downgrade issues (AccA)
- Include AccA logcat in log archive
- Optimized installers
- prioritizeBattIdleMode=true by default
- Removed `acc --calibrate`, in favor of universal and comprehensive calibration instructions (README > FAQ)
- Under the hood enhancements
- Updated documentation
- Workaround for encryption preventing AccA from initializing ACC
  • Loading branch information
VR-25 committed Apr 20, 2020
1 parent 1c7bec0 commit 84bcfc9
Show file tree
Hide file tree
Showing 31 changed files with 632 additions and 343 deletions.
114 changes: 58 additions & 56 deletions META-INF/com/google/android/update-binary
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ SKIPUNZIP=1

echo
id=acc
umask 077
umask 0077


# log
mkdir -p /data/adb/${id}-data/logs
chmod -R 700 /data/adb/${id}-data/logs
chmod -R 0700 /data/adb/${id}-data/logs
exec 2>/data/adb/${id}-data/logs/install.log
set -x

Expand All @@ -26,9 +26,14 @@ exxit() {
local e=$?
set +eo pipefail
rm -rf /dev/.${id}-install
[ $e -ne 0 ] && echo || {
rm /sbin/.$id/.ghost-charging ###
/sbin/acca --daemon > /dev/null || /sbin/accd ### workaround, Magisk 20.4+
[ $e -ne 0 ] && echo || { ###
rm /sbin/.$id/.ghost-charging
/sbin/acca --daemon > /dev/null || /sbin/accd || {
pkill -9 -f $installDir/service.sh
$installDir/service.sh --override
rm /sbin/.$id/.ghost-charging
/sbin/acca --daemon > /dev/null || /sbin/accd
} || e=12
}
exit $e
} 2>/dev/null
Expand All @@ -45,19 +50,19 @@ if [ -d /sbin/.magisk/busybox ]; then
esac
else
mkdir -p /dev/.busybox
chmod 700 /dev/.busybox
chmod 0700 /dev/.busybox
case $PATH in
/dev/.busybox:*) :;;
*) PATH=/dev/.busybox:$PATH;;
esac
[ -x /dev/.busybox/busybox ] || {
if [ -f /data/adb/magisk/busybox ]; then
[ -x /data/adb/magisk/busybox ] || chmod 700 /data/adb/magisk/busybox
[ -x /data/adb/magisk/busybox ] || chmod 0700 /data/adb/magisk/busybox
/data/adb/magisk/busybox --install -s /dev/.busybox
elif which busybox > /dev/null; then
busybox --install -s /dev/.busybox
elif [ -f /data/adb/busybox ]; then
[ -x /data/adb/busybox ] || chmod 700 /data/adb/busybox
[ -x /data/adb/busybox ] || chmod 0700 /data/adb/busybox
/data/adb/busybox --install -s /dev/.busybox
else
echo "(!) Install busybox or simply place it in /data/adb/"
Expand All @@ -78,8 +83,8 @@ fi
get_prop() { sed -n "s|^$1=||p" ${2:-$srcDir/module.prop}; }

set_perms() {
local owner=${2:-0} perms=600 target=$(readlink -f $1)
if echo $target | grep -q '.*\.sh$' || [ -d $target ]; then perms=700; fi
local owner=${2:-0} perms=0600 target=$(readlink -f $1)
if echo $target | grep -q '.*\.sh$' || [ -d $target ]; then perms=0700; fi
chmod $perms $target
chown $owner:$owner $target
restorecon $target > /dev/null 2>&1 || :
Expand Down Expand Up @@ -110,15 +115,23 @@ srcDir=${srcDir/#"${0##*/}"/"."}
name=$(get_prop name)
author=$(get_prop author)
version=$(get_prop version)
magiskModDir=/sbin/.magisk/modules
versionCode=$(get_prop versionCode)
installDir=${1:-/data/data/mattecarra.${id}app/files} ###
: ${installDir:=/data/data/mattecarra.${id}app/files} ###
config=/data/adb/${id}-data/config.txt

[ -d $magiskModDir ] && magisk=true || magisk=false


# check/set parent installation directory
[ -d $installDir ] || installDir=/sbin/.magisk/modules

[ -d $installDir ] || installDir=$magiskModDir
[ -d $installDir ] || installDir=/data/adb
[ -d $installDir ] || { echo "(!) /data/adb/ not found\n"; exit 1; }

[ -d $installDir ] || {
echo "(!) /data/adb/ not found\n"
exit 1
}


###
Expand All @@ -129,59 +142,54 @@ GPLv3+
(i) Installing in $installDir/$id/..."


# install
ash $srcDir/$id/uninstall.sh install
rm /data/adb/${id}-data/logs/bootlooped 2>/dev/null || :
cp -R $srcDir/$id/ $installDir/
installDir=$(readlink -f $installDir/$id)
cp $srcDir/module.prop $installDir/
mkdir -p ${config%/*}/info
cp -f $srcDir/*.md ${config%/*}/info
[ $installDir == /data/adb/$id ] || ln -s $installDir /data/adb/


if [ $installDir != /sbin/.magisk/modules/$id ]; then

mv $installDir/service.sh $installDir/${id}-init.sh

# enable upgrading through Magisk Manager
ln -s $installDir /sbin/.magisk/modules/$id 2>/dev/null || :

[ ! -d /data/adb/service.d ] || {

# alternate initialization script
echo "#!/system/bin/sh
# alternate $id initializer
(until [ -d /storage/emulated/0/?ndroid ]; do sleep 10; done
if [ -f $installDir/${id}-init.sh ]; then
$installDir/${id}-init.sh
else
rm \$0
fi
exit 0 &) &
exit 0" > /data/adb/service.d/${id}-init.sh
case $installDir in
/data/*/files/*$id)
! $magisk || {
cp -R $installDir $magiskModDir/

# post-uninstall cleanup script
# front-end post-uninstall cleanup script
echo "#!/system/bin/sh
# $id post-uninstall cleanup
(until [ -d /storage/emulated/0/?ndroid ]; do sleep 15; done
# $id front-end post-uninstall cleanup script
(until [ -d /sdcard/?ndroid ]; do sleep 15; done
if [ ! -f $installDir/module.prop ]; then
rm /data/adb/$id /data/adb/${id}-data /data/adb/modules/$id \$0 2>/dev/null
rm -rf /data/adb/$id /data/adb/${id}-data /data/adb/modules/$id \$0 2>/dev/null
fi
exit 0 &) &
exit 0" > /data/adb/service.d/${id}-cleanup.sh

chmod 700 /data/adb/service.d/${id}-*.sh
}
chmod 0700 /data/adb/service.d/${id}-cleanup.sh
}
ln $installDir/service.sh $installDir/${id}-init.sh

# TODO
# upgrade bundled version
#cp -f $srcDir/install-tarball.sh ${installDir%/*}/
#tar -cvf - . -C $srcDir --exclude .git | gzip -9 > ${installDir%/*}/acc_bundle.tar.gz
;;
esac

else
# workaround for Magisk "forgetting service.sh" issue
ln $installDir/service.sh $installDir/post-fs-data.sh
fi

[ $installDir == /data/adb/$id ] || {

# disable magic mount (Magisk)
touch /sbin/.magisk/modules/$id/skip_mount 2>/dev/null || :
ln -s $installDir /data/adb/

! $magisk || {
# workaround for Magisk "forgetting service.sh" issue
ln $magiskModDir/$id/service.sh $magiskModDir/$id/post-fs-data.sh

# disable magic mount (Magisk)
touch $magiskModDir/$id/skip_mount
}
}


# restore config backup
Expand All @@ -204,13 +212,14 @@ cp -f $srcDir/bin/${id}-uninstaller.zip /data/media/0/

# set perms
set_perms_recursive ${config%/*}
chmod 666 /data/media/0/${id}-uninstaller.zip
chmod 0666 /data/media/0/${id}-uninstaller.zip
case $installDir in
/data/*/files/*$id)
pkg=${installDir%/files/*$id}
pkg=${pkg##/data*/}
owner=$(grep $pkg /data/system/packages.list | cut -d ' ' -f 2)
set_perms_recursive $installDir $owner
! $magisk || set_perms_recursive $magiskModDir/$id

# Termux:Boot
! $termux || {
Expand All @@ -232,8 +241,6 @@ echo "- Done
"


# print links and changelog
sed -En "\|## LINKS|,\$p" ${config%/*}/info/README.md \
| grep -v '^---' | sed 's/^## //'
Expand All @@ -249,14 +256,9 @@ echo "


[ $installDir == /data/adb ] && echo -e "\n(i) Use init.d or an app to run $installDir/${id}-init.sh on boot to initialize ${id}."

echo

# initialize $id
if [ -f $installDir/service.sh ]; then
$installDir/service.sh --override
else
$installDir/${id}-init.sh --override
fi
$installDir/service.sh --override

exit 0
70 changes: 44 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ In interactive mode, it also asks the user whether they want to download and ins
```
#DC#
configVerCode=202004170
configVerCode=202004200
capacity=(-1 101 70 75 +0 false)
temperature=(70 80 90)
cooldownRatio=()
Expand All @@ -191,12 +191,11 @@ rebootOnPause=
switchDelay=1.5
language=en
wakeUnlock=()
prioritizeBattIdleMode=false
prioritizeBattIdleMode=true
forceChargingStatusFullAt100=
runCmdOnPause=()
dynPowerSaving=0
autoShutdownAlertCmd=(vibrate 5 0.1)
calibrationAlertCmd=(vibrate 5 0.1)
chargDisabledNotifCmd=(vibrate 3 0.1)
chargEnabledNotifCmd=(vibrate 4 0.1)
errorAlertCmd=(vibrate 6 0.1)
Expand Down Expand Up @@ -254,7 +253,7 @@ errorAlertCmd=(vibrate 6 0.1)
# dynPowerSaving=dyn_power_saving=seconds
#
#
# VARIABLE ALIASES/SORTCUTS
Expand Down Expand Up @@ -299,7 +298,6 @@ errorAlertCmd=(vibrate 6 0.1)
# dps dyn_power_saving
# asac auto_shutdown_alert_cmd
# cac calibration_alert_cmd
# cdnc charg_disabled_notif_cmd
# cenc charg_enabled_notif_cmd
# eac error_alert_cmd
Expand Down Expand Up @@ -465,11 +463,10 @@ errorAlertCmd=(vibrate 6 0.1)
# * On top of loop_delay_discharging
# auto_shutdown_alert_cmd (asac) #
# calibration_alert_cmd (cac) #
# charg_disabled_notif_cmd (cdnc) #
# charg_enabled_notif_cmd (cenc) #
# error_alert_cmd (eac) #
# As the names suggest, these properties dictate commands acc/s run at each event.
# As the names suggest, these properties dictate commands acc/d/s should run at each event.
# The default command is "vibrate <number of vibrations> <interval (seconds)>"
# Termux APIs can be used for notifications, TTS, toasts and more. For details, refer to https://wiki.termux.com/wiki/Termux:API .
Expand Down Expand Up @@ -532,11 +529,6 @@ Options
acc -c less
acc -c cat
-C|--calibrate [update freq] Charge to true 100%
e.g.,
acc -C (update info every 3 seconds)
acc -C 0.5 (update info every half a second)
-d|--disable [#%, #s, #m or #h (optional)] Disable charging
e.g.,
acc -d 70% (do not recharge until capacity <= 70%)
Expand Down Expand Up @@ -623,7 +615,9 @@ Options
-s|--set p|--print [egrep regex (default: ".")] Print current config without blank lines (refer to previous examples)
-s|--set r|--reset Restore default config
e.g., acc -s r
e.g.,
acc -s r
rm /data/adb/acc-data/config.txt (failsafe)
-s|--set s|charging_switch Enforce a specific charging switch
e.g., acc -s s
Expand Down Expand Up @@ -688,6 +682,8 @@ Exit Codes
8. Daemon already running ("--daemon start")
9. Daemon not running ("--daemon" and "--daemon stop")
10. "--test" failed
11. Current (mA) out of range
12. install.sh failed to initialize acc or start accd
Logs are exported automatically ("--log --export") on exit codes 1, 2, 7 and 10.
Expand Down Expand Up @@ -759,7 +755,7 @@ Refer back to `DEFAULT CONFIGURATION (switch_delay)`.

### Battery Capacity (% Level) Doesn't Seem Right

The "smart" battery may need calibration.
The "smart" battery may require calibration.
Refer to the `FAQ` section below for details.

If we're talking about a Pixel device, the issue goes beyond that.
Expand All @@ -771,7 +767,7 @@ Refer back to `DEFAULT CONFIGURATION > capacity_sync`.
Recent/custom kernels (e.g., Kirisakura) support battery idle mode.
However, at the time of this writing, the feature is not production quality.
ACC has custom code to cover its pitfalls, though.
`battery/op_disable_charge 0 1` must be enforced manually (`acc -s s` or `acc -s s="battery/op_disable_charge 0 1"`).
`battery/op_disable_charge 0 1` must be enforced manually (`acc -s s` or `acc -s s="battery/op_disable_charge 0 1"`) and accd, restarted afterwards.


### Bootloop, ACC Not Found
Expand Down Expand Up @@ -833,7 +829,9 @@ Automatic exporting happens under specific conditions (refer back to `SETUP/USAG

### Restore Default Config

`acc --set --reset` or `acc -s r`
This can save you a lot of time and grief.

`acc --set --reset`, `acc -s r` or `rm /data/adb/acc-data/config.txt` (failsafe)


### Slow Charging
Expand Down Expand Up @@ -934,8 +932,24 @@ Refer back to `POWER SUPPLY LOGS (HELP NEEDED)`.
> Why, when and how should I calibrate the battery?
With modern battery management systems, that's generally unnecessary.
If your battery is underperforming, refer to https://batteryuniversity.com/index.php/learn/article/battery_calibration .
The calibration command is `acc -C`.

However, if your battery is underperforming, you may want to try the following procedure:

1. Let the battery charge until VOLTAGE_NOW >= VOLTAGE_MAX* and CURRENT_NOW drops to 3% of the rated mAh capacity, or less.

2. Let it discharge until the phone shuts off.

3. Turn the phone back on to consume any "residual" charge left.
Repeat this until the device refuses to stay/turn on.
Next, try booting straight into download, fastboot or recovery mode.
Repeat until the phone totally refuses to stay/turn on.

4. Charge to 100% without turning it on.
Leave the device plugged in for another hour or so.
This emulates step 1.
Done.

For additional information, refer to https://batteryuniversity.com/index.php/learn/article/battery_calibration .


> What if even after calibrating the battery, ACC and Android battery level reports still differ?
Expand Down Expand Up @@ -1042,6 +1056,18 @@ A common workaround is having `resume_capacity = pause_capacity - 1`.
---
## LATEST CHANGES

**v2020.4.20-beta (202004200)**
- Blacklisted troublesome Pixel [1-3]* charging switches
- Fixed absurd charging current and voltage reports (AccA)
- Fixed upgrade and downgrade issues (AccA)
- Include AccA logcat in log archive
- Optimized installers
- prioritizeBattIdleMode=true by default
- Removed `acc --calibrate`, in favor of universal and comprehensive calibration instructions (README > FAQ)
- Under the hood enhancements
- Updated documentation
- Workaround for encryption preventing AccA from initializing ACC

**v2020.4.17-beta (202004170)**
- acc -C: replace misleading 100% with 99%
- acc -s: restoring individual defaults is as simple as running `acc -s var1= var2= ...`
Expand All @@ -1058,11 +1084,3 @@ A common workaround is having `resume_capacity = pause_capacity - 1`.
- Renamed cooldown(_c|C)urrent/cooldown(_c|C)ustom
- Native support for MediaTek mt6795 devices, e.g., Redmi Note 2 (hermes)
- Updated build script and documentation

**v2020.4.8-beta (202004080)**
- acc -t: fixed "charging-switches: no such file" error
- accd: fixed crash on plug/unplug that affected some users
- Current control optimizations
- Enhanced battery calibration helper (acc -C)
- More intuitive versioning scheme
- Stricter config integrity checks (auto-reset broken config)
Loading

0 comments on commit 84bcfc9

Please sign in to comment.