Skip to content

Commit

Permalink
**v2020.9.14 (202009140)**
Browse files Browse the repository at this point in the history
- Ensure releae-lock.sh does not cause unwanted acc/d termination.
- General fixes & optimizations
- mv /data/adb/acc-data /sdcard/Download/acc
- Reapply voltage limits on plug.

Release Notes
  - All persistent acc data is now stored in /sdcard/Download/acc/.
  - "mx4pro" users, please send me a new log archive after installing this version.
  - Nothing was done in regards to the "MIUI 12" bootloop issue. The root cause is still unknown.

Unannounced Releases (@romanegunkov)
  - v2020.9.01 (202009010): Fixed --upgrade bug.
  - v2020.8.24 (202008240): Prevent auto shutdown if system has been running for less than 15 minutes.
  • Loading branch information
VR-25 committed Sep 14, 2020
1 parent a8d4c23 commit c1b9d30
Show file tree
Hide file tree
Showing 19 changed files with 123 additions and 115 deletions.
26 changes: 13 additions & 13 deletions META-INF/com/google/android/update-binary
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ SKIPUNZIP=1
echo
id=acc
umask 0077
data_dir=/sdcard/Download/$id


# log
[ -z "${LINENO-}" ] || export PS4='$LINENO: '
mkdir -p /data/adb/${id}-data/logs
chmod -R 0700 /data/adb/${id}-data/logs
exec 2>/data/adb/${id}-data/logs/install.log
mkdir -p $data_dir/logs
chmod -R 0700 $data_dir/logs
exec 2>$data_dir/logs/install.log
set -x


Expand Down Expand Up @@ -102,11 +103,10 @@ srcDir=${srcDir/#"${0##*/}"/"."}
name=$(get_prop name)
author=$(get_prop author)
version=$(get_prop version)
userDir=/sdcard/Download/$id
magiskModDir=/data/adb/modules
versionCode=$(get_prop versionCode)
: ${installDir:=/data/data/mattecarra.${id}app/files} ###
config=/data/adb/${id}-data/config.txt
config=$data_dir/config.txt


[ -d $magiskModDir ] && magisk=true || magisk=false
Expand Down Expand Up @@ -141,12 +141,17 @@ GPLv3+
(i) Installing in $installDir/$id/..."


# migrate #legacy data
mv -f /data/adb/${id}-data/* /data/adb/${id}-data/.* \
$data_dir/ 2>/dev/null || :
rm -rf $data_dir/info /data/adb/${id}-data/ 2>/dev/null || :


/system/bin/sh $srcDir/$id/uninstall.sh install
cp -R $srcDir/$id/ $installDir/
installDir=$(readlink -f $installDir/$id)
cp $srcDir/module.prop $installDir/
mkdir -p $userDir
cp -f $srcDir/README.md $userDir/
cp -f $srcDir/README.md $data_dir/


###
Expand Down Expand Up @@ -195,12 +200,8 @@ fi
[ $installDir = /data/adb/$id ] || ln -s $installDir /data/adb/


# restore config backup
[ -f $config ] || cp $userDir/.${id}-config-backup.txt $config 2>/dev/null || :


# install binaries
cp -f $srcDir/bin/${id}-uninstaller.zip $userDir/
cp -f $srcDir/bin/${id}-uninstaller.zip $data_dir/


# Termux, fix shebang
Expand All @@ -214,7 +215,6 @@ cp -f $srcDir/bin/${id}-uninstaller.zip $userDir/


# set perms
set_perms_recursive ${config%/*}
case $installDir in
/data/*/files/*$id)
pkg=${installDir%/files/*$id}
Expand Down
57 changes: 28 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ 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 `/data/adb/acc-data/config.txt`.
Alternatively, you can use a `text editor` to modify `/sdcard/Download/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.
Expand Down Expand Up @@ -654,7 +654,7 @@ Options
-s|--set r|--reset Restore default config
e.g.,
acc -s r
rm /data/adb/acc-data/config.txt (failsafe)
rm /sdcard/Download/acc/config.txt (failsafe)
-sr Same as above
Expand Down Expand Up @@ -738,12 +738,13 @@ Exit Codes
Tips
Commands can be chained for extended functionality.
e.g., acc -e 30m && acc -d 6h && acc -e 85 && accd (recharge for 30 minutes, pause charging for 6 hours, recharge to 85% capacity and restart the daemon)
e.g., charge for 30 minutes, pause charging for 6 hours, charge to 85% and restart the daemon
acc -e 30m && acc -d 6h && acc -e 85 && accd
Bedtime settings...
acc -s /dev/.my-night-config.txt pc=45 rc=43 mcc=500 mcv=3920 && sleep $((60*60*7)) && accd
- "For the next 7 hours, keep battery capacity between 43-45%, limit charging current to 500 mA and voltage to 3920 millivolts"
- For convenience, this can be written to a file and ran as "sh /path/to/file".
- For convenience, this can be written to a file and ran as "su -c sh /path/to/file".
Refer to acc -r (or --readme) for the full documentation (recommended)
Expand Down Expand Up @@ -829,7 +830,7 @@ Most of the time, though, it's just a matter of plugging the phone before turnin
Battery level must be below pause_capacity.
Once booted, one can run `acc --uninstall` (or `acc -U`) to remove ACC.

From recovery, you can flash `/sdcard/Download/acc/acc-uninstaller.zip` or run `mount /system; /data/adb/acc/uninstall.sh`.
From recovery, one can flash `/sdcard/Download/acc/acc-uninstaller.zip` or run `mount /system; /data/adb/acc/uninstall.sh`.


### Charging Switch
Expand Down Expand Up @@ -868,11 +869,16 @@ That said, the existence of potential voltage/current control file doesn't neces
\* Root is not enough.
Kernel level permissions forbid write access to certain interfaces.

Sometimes, restoring the default current may not work without a system reboot.
A workaround is setting an absurdly high current value (e.g., 9000 mA).
Don't worry about frying things.
The phone will only draw the max it can take.


### Diagnostics/Logs

Volatile logs (gone on reboot) are stored in `/dev/.acc/`.
Persistent logs: `/data/adb/acc-data/logs/`.
Persistent logs: `/sdcard/Download/acc/logs/`.

`/dev/.acc-removed` is created by the uninstaller.
The storage location is volatile.
Expand All @@ -894,7 +900,7 @@ Some users may have to set `switch_delay=15` (or higher) or `charging_switch="/p

This can save you a lot of time and grief.

`acc --set --reset`, `acc -sr` or `rm /data/adb/acc-data/config.txt` (failsafe)
`acc --set --reset`, `acc -sr` or `rm /sdcard/Download/acc/config.txt` (failsafe)


### Slow Charging
Expand All @@ -910,7 +916,7 @@ At least one of the following may be the cause:
---
## POWER SUPPLY LOG (HELP NEEDED)

Please run `acc -le` and upload `/data/adb/acc-data/logs/power_supply-*.log` to [my dropbox](https://www.dropbox.com/request/WYVDyCc0GkKQ8U5mLNlH/) (no account/sign-up required).
Please run `acc -le` and upload `/sdcard/Download/acc/logs/power_supply-*.log` to [my dropbox](https://www.dropbox.com/request/WYVDyCc0GkKQ8U5mLNlH/) (no account/sign-up required).
This file contains invaluable power supply information, such as battery details and available charging control files.
A public database is being built for mutual benefit.
Your cooperation is greatly appreciated.
Expand Down Expand Up @@ -999,7 +1005,7 @@ The default command is "vibrate <number of vibrations> <interval (seconds)>"
Let's assume you want the phone to say _Warning! Battery is low. System will shutdown soon._
To set that up, paste and run the following on a terminal, as root:

`echo -e "\nautoShutdownAlertCmd=('! pgrep -f acc-tts.sh || echo \"Warning! Battery is low. System will shutdown soon.\" > /data/data/com.termux/files/home/acc-fifo')" >> /data/adb/acc-data/config.txt`
`echo -e "\nautoShutdownAlertCmd=('! pgrep -f acc-tts.sh || echo \"Warning! Battery is low. System will shutdown soon.\" > /data/data/com.termux/files/home/acc-fifo')" >> /sdcard/Download/acc/config.txt`


That's it.
Expand Down Expand Up @@ -1135,26 +1141,19 @@ A common workaround is having `resume_capacity = pause_capacity - 1`. e.g., resu
---
## LATEST CHANGES

**v2020.9.01 (202009010)**
- Fixed bug with handling `-u|--upgrade` option.

**v2020.8.24 (202008240)**
- Prevent phone off according to `shutdown_capacity`, if phone was power-on less than 15 minutes ago.
**v2020.9.14 (202009140)**

**v2020.8.6 (202008060)**
- Adaptive --info and --print (config) outputs
- Copy README.md to /sdcard/Download/acc/.
- Fixed "capacity_sync freezes when ghost charging is detected".
- Ensure releae-lock.sh does not cause unwanted acc/d termination.
- General fixes & optimizations
- If supported, prepend "$LINENO: " to log lines.
- MTK troubleshooting info (readme > troubleshooting)
- Updated framework (in sync with fbind)

**v2020.7.26 (202007260)**
- General cleanup and optimizations
- Moved acc files in /sdcard/ to /sdcard/Download/acc/.
- Removed acc-init.sh in favor of service.sh.

**v2020.7.25 (202007250)**
- Updated documentation
- Workaround for network issues
- mv /data/adb/acc-data /sdcard/Download/acc
- Reapply voltage limits on plug.

Release Notes
- All persistent acc data is now stored in /sdcard/Download/acc/.
- "mx4pro" users, please send me a new log archive after installing this version.
- Nothing was done in regards to the "MIUI 12" bootloop issue. The root cause is still unknown.

Unannounced Releases (@romanegunkov)
- v2020.9.01 (202009010): Fixed --upgrade bug.
- v2020.8.24 (202008240): Prevent auto shutdown if system has been running for less than 15 minutes.
16 changes: 16 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,19 @@ remove #legacy
add custom config for some mtk devices
sd=15
switch

acca should show capacity from dumpsys to prevent confusion

70% bug, samsung r3q (SM-A908B)


potentially fixed

issues with charge to X once?

accd killing itself; can't restart
probably caused by set -e and release-lock.sh

capacity sync issues

shutdown capacity being set to -1
9 changes: 4 additions & 5 deletions acc/acc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ exxit() {
}
echo
}
rm /dev/.acc-config 2>/dev/null
cd /
exit $exitCode
}
Expand Down Expand Up @@ -191,7 +190,7 @@ if ${verbose:-true} && [ -f $execDir/translations/$language/strings.sh ]; then
fi
grep -q .. $execDir/translations/$language/README.md 2>/dev/null \
&& readMe=$execDir/translations/$language/README.md \
|| readMe=$userDir/README.md
|| readMe=${config%/*}/README.md


# aliases/shortcuts
Expand Down Expand Up @@ -263,7 +262,7 @@ case "${1-}" in
resume_capacity=$(( pause_capacity - 5 ))
run_cmd_on_pause="exec /dev/accd"

cp -f $config $TMPDIR/.acc-f-config
grep -Ev '^$|^#' $config > $TMPDIR/.acc-f-config
config=$TMPDIR/.acc-f-config
. $execDir/write-config.sh
print_charging_enabled_until ${2:-100}%
Expand Down Expand Up @@ -380,8 +379,8 @@ case "${1-}" in

. $execDir/acquire-lock.sh

cp $config /dev/.acc-config
config=/dev/.acc-config
grep -Ev '^$|^#' $config > $TMPDIR/.config
config=$TMPDIR/.config
fd3=true
exec 3>&1

Expand Down
9 changes: 2 additions & 7 deletions acc/acca.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,12 @@ cd /data/adb/acc/
export TMPDIR=/dev/.acc verbose=false
. ./setup-busybox.sh

userDir=/sdcard/Download/acc
config=/data/adb/acc-data/config.txt
config=/sdcard/Download/acc/config.txt
defaultConfig=$PWD/default-config.txt

mkdir -p ${config%/*} $userDir || :
mkdir -p ${config%/*} 2>/dev/null || :
[ -f $config ] || cp $defaultConfig $config

# config backup
! test $config -nt $userDir/.acc-config-backup.txt \
|| cp -f $config $userDir/.acc-config-backup.txt

# custom config path
case "${1-}" in
*/*)
Expand Down
13 changes: 7 additions & 6 deletions acc/accd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pgrep zygote > /dev/null && {
&& test .$(getprop sys.boot_completed) = .1 \
&& dumpsys battery > /dev/null 2>&1
do
sleep 10
sleep 30
done
}

Expand All @@ -35,8 +35,8 @@ if [ -f $TMPDIR/.config-ver ] && ! $init; then ###
trap - EXIT
vibrate() { :; }
{ dumpsys battery reset &
cp $config /dev/.${id}-config
config=/dev/.${id}-config
grep -Ev '^$|^#' $config > $TMPDIR/.config
config=$TMPDIR/.config
enable_charging &
apply_on_boot default &
apply_on_plug default &
Expand Down Expand Up @@ -340,8 +340,9 @@ else


# log
mkdir -p $TMPDIR /data/adb/${id}-data/logs
exec > /data/adb/${id}-data/logs/init.log 2>&1
data_dir=/sdcard/Download/$id
mkdir -p $TMPDIR $data_dir/logs
exec > $data_dir/logs/init.log 2>&1
set -x


Expand Down Expand Up @@ -432,7 +433,7 @@ else
while read file; do
chmod u+r $file 2>/dev/null || continue
defaultValue=$(cat $file)
ampFactor=$(sed -n 's/^ampFactor=//p' /data/adb/${id}-data/config.txt 2>/dev/null)
ampFactor=$(sed -n 's/^ampFactor=//p' $data_dir/config.txt 2>/dev/null)
[ -n "$ampFactor" -o $defaultValue -ne 0 ] && {
if [ "${ampFactor:-1}" -eq 1000 -o $defaultValue -lt 10000 ]; then
# milliamps
Expand Down
8 changes: 4 additions & 4 deletions acc/logf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ logf() {
batt_info > $TMPDIR/acc-i.txt)
dumpsys battery > dumpsys-battery.txt

userDir=/sdcard/Download/acc
mkdir -p $userDir
tar -c *.log *.txt | bzip2 -9 > $userDir/acc-logs-$device.tar.bz2
data_dir=/sdcard/Download/acc
mkdir -p $data_dir
tar -c *.log *.txt | bzip2 -9 > $data_dir/acc-logs-$device.tar.bz2

rm *.txt magisk.log in*.log power*.log m*accapp.log 2>/dev/null
echo "(i) $userDir/acc-logs-$device.tar.bz2"
echo "(i) $data_dir/acc-logs-$device.tar.bz2"

else
if [[ "${1:-x}" = -*a* ]]; then
Expand Down
11 changes: 3 additions & 8 deletions acc/misc-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ apply_on_boot() {

apply_on_plug() {
local entry="" file="" value="" default="" arg=${1:-value}
for entry in "${applyOnPlug[@]-}" "${maxChargingCurrent[@]-}"; do
for entry in "${applyOnPlug[@]-}" "${maxChargingCurrent[@]-}" "${maxChargingVoltage[@]-}"; do
set -- ${entry//::/ }
file=${1-}
value=${2-}
Expand Down Expand Up @@ -246,13 +246,9 @@ enable_charging() {

misc_stuff() {
set -eu
mkdir -p ${config%/*} $userDir || :
mkdir -p ${config%/*} 2>/dev/null || :
[ -f $config ] || cp $execDir/default-config.txt $config

# config backup
! test $config -nt $userDir/.acc-config-backup.txt \
|| cp -f $config $userDir/.acc-config-backup.txt

# custom config path
case "${1-}" in
*/*)
Expand Down Expand Up @@ -326,8 +322,7 @@ id=acc
umask 0077
execDir=/data/adb/acc
export TMPDIR=/dev/.acc
userDir=/sdcard/Download/$id
config=/data/adb/acc-data/config.txt
config=/sdcard/Download/$id/config.txt
config_=$config

[ -f $TMPDIR/.ghost-charging ] \
Expand Down
2 changes: 1 addition & 1 deletion acc/power-supply-logger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ gather_ps_data() {

export TMPDIR=/dev/.acc
execDir=/data/adb/acc
logsDir=/data/adb/acc-data/logs
logsDir=/sdcard/Download/acc/logs

print_wait 2>/dev/null || echo "(i) Alright, this may take a minute or so..."

Expand Down
4 changes: 2 additions & 2 deletions acc/release-lock.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/system/bin/sh
id=acc
(pid=
set +o sh 2>/dev/null || :
set +euo sh 2>/dev/null || :
flock -n 0 || {
read pid
kill $pid
timeout 15 flock 0 || kill -KILL $pid
}) <>$TMPDIR/${id}.lock
}) <>$TMPDIR/${id}.lock || :
1 change: 0 additions & 1 deletion acc/select.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# . $0
# select_ <var> <list>
#
# "#" is an argument for read -n (optional).
# ${PS3:-#?} is used.


Expand Down
Loading

0 comments on commit c1b9d30

Please sign in to comment.