Skip to content

Commit

Permalink
**v2020.10.1 (202010010)**
Browse files Browse the repository at this point in the history
- Fixed automatic charging switch management issues.
- Fixed ghost charging problem related to cooldown and capacity_sync/capacity_freeze2.
- General optimizations
- Persistent data is now saved in /sdcard/vr25/acc/.
- Workaround for EdXposed's service.sh bug

Release Notes

- Confirmed: the MIUI bootloop issue is gone.
- If you face any other issue, run `rm /sdcard/vr25/acc/config.txt; accd` to reset the config and restart accd.
  • Loading branch information
VR-25 committed Oct 1, 2020
1 parent b94c0b9 commit a85fe6c
Show file tree
Hide file tree
Showing 21 changed files with 143 additions and 108 deletions.
33 changes: 19 additions & 14 deletions META-INF/com/google/android/update-binary
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SKIPUNZIP=1
echo
id=acc
umask 0077
data_dir=/sdcard/Download/$id
data_dir=/sdcard/vr25/$id


# log
Expand Down Expand Up @@ -121,14 +121,11 @@ fi


# check/change parent installation directory

! $magisk || installDir=$magiskModDir

[ -d $installDir ] || installDir=/data/adb

[ $installDir != /data/adb/vr25 ] || mkdir -p $installDir
[ -d $installDir ] || {
printf "(!) $installDir/ not found\n"
exit 1
installDir=/data/adb/vr25
mkdir -p $installDir
}


Expand All @@ -141,9 +138,14 @@ GPLv3+


# 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 || :
if [ -d /data/adb/${id}-data ]; then
mv -f /data/adb/${id}-data/* /data/adb/${id}-data/.* \
$data_dir/ 2>/dev/null || :
else
mv -f /sdcard/Download/$id/* /sdcard/Download/$id/.* \
$data_dir/ 2>/dev/null || :
fi
rm -rf $data_dir/info 2>/dev/null || :


/system/bin/sh $srcDir/$id/uninstall.sh install
Expand Down Expand Up @@ -188,15 +190,18 @@ if $acca; then
sleep 60
[ -e /data/data/mattecarra.${id}app/files/$id ] || rm \$0 /data/adb/$id /data/adb/modules/$id 2>/dev/null
[ -e /data/data/mattecarra.${id}app/files/$id ] || rm -rf \$0 /data/adb/vr25/$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
}
fi


[ $installDir = /data/adb/$id ] || ln -s $installDir /data/adb/
[ $installDir = /data/adb/vr25/$id ] || {
mkdir -p /data/adb/vr25
ln -s $installDir /data/adb/vr25/
}


# install binaries
Expand Down Expand Up @@ -258,10 +263,10 @@ echo "


[ $installDir = /data/adb ] && echo "
(i) Non-Magisk users can enable $id auto-start by running /data/adb/$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/vr25/$id/service.sh, a copy of, or a link to it - with init.d or an app that emulates it."


# initialize $id
/data/adb/$id/service.sh --init
/data/adb/vr25/$id/service.sh --init

exit 0
49 changes: 32 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Always read/reread this reference prior to installing/upgrading this software.

While no cats have been harmed, the author assumes no responsibility for anything that might break due to the use/misuse of it.

To prevent fraud, do NOT mirror any link associated with this project; do NOT share builds (zips/tarballs)! Share official links instead.
To prevent fraud, do NOT mirror any link associated with this project; do NOT share builds (tarballs/zips)! Share official links instead.


---
Expand All @@ -52,10 +52,10 @@ By choosing to use/misuse it, you agree to do so at your own risk!

- [Must read - how to prolong lithium ion batteries lifespan](https://batteryuniversity.com/index.php/learn/article/how_to_prolong_lithium_based_batteries/)
- Android or Android based OS
- Any root method (e.g., [Magisk](https://github.com/topjohnwu/Magisk/))
- Any root solution (e.g., [Magisk](https://github.com/topjohnwu/Magisk/))
- [Busybox\*](https://github.com/search?o=desc&q=busybox+android&s=updated&type=Repositories/) (only if not rooted with Magisk)
- [curl](https://github.com/search?o=desc&q=curl+android&s=updated&type=Repositories/) (for fbind --upgrade, optional)
- Non-Magisk users can enable acc auto-start by running /data/adb/$id/service.sh, a copy of, or a link to it - with init.d or an app that emulates it
- [curl](https://github.com/search?o=desc&q=curl+android&s=updated&type=Repositories/) (for acc --upgrade, optional)
- Non-Magisk users can enable acc auto-start by running /data/adb/vr25/acc/service.sh, a copy of, or a link to it - with init.d or an app that emulates it.
- Terminal emulator
- Text editor (optional)

Expand Down Expand Up @@ -95,11 +95,11 @@ Settings can be overwhelming. Start with what you understand.
The default configuration has you covered.
Don't ever feel like you have to configure everything. You probably shouldn't anyway - unless you really know what you're doing.

Uninstall: run `acc --uninstall` or flash\* `/sdcard/Download/acc/acc-uninstaller.zip`.
Uninstall: run `acc --uninstall` or flash\* `/sdcard/vr25/acc/acc-uninstaller.zip`.

ACC runs in some recovery environments as well.
Unless the zip is flashed again, manual initialization is required.
The initialization command is `/data/adb/acc/service.sh`.
The initialization command is `/data/adb/vr25/acc/service.sh`.


---
Expand Down Expand Up @@ -424,7 +424,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 `/sdcard/Download/acc/config.txt`.
Alternatively, you can use a `text editor` to modify `/sdcard/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.
Expand Down Expand Up @@ -495,7 +495,7 @@ Options
e.g.,
acc -F (lauches a zip flashing wizard)
acc -F "file1" "file2" "fileN" ... (install multiple zips)
acc -F "/sdcard/Download/Magisk-v20.0(20000).zip"
acc -F "/sdcard/vr25/Magisk-v20.0(20000).zip"
-i|--info [case insentive egrep regex (default: ".")] Show battery info
e.g.,
Expand All @@ -512,7 +512,7 @@ Options
-la Same as -l -a
-l|--log -e|--export Export all logs to /sdcard/Download/acc/logs/acc-logs-$deviceName.tar.bz2
-l|--log -e|--export Export all logs to /sdcard/vr25/acc/logs/acc-logs-$deviceName.tar.bz2
e.g., acc -l -e
-le Same as -l -e
Expand Down Expand Up @@ -562,7 +562,7 @@ Options
-s|--set r|--reset Restore default config
e.g.,
acc -s r
rm /sdcard/Download/acc/config.txt (failsafe)
rm /sdcard/vr25/acc/config.txt (failsafe)
-sr Same as above
Expand Down Expand Up @@ -590,7 +590,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: /data/data/com.termux/files/usr/tmp/ch-switches)
-t|--test [file] Test charging switches from a file (default: /dev/.acc/ch-switches)
This will also report whether "battery idle" mode is supported
e.g.,
acc -t (test known switches)
Expand Down Expand Up @@ -681,7 +681,7 @@ Note: after updating charging_switch or shutdown_capacity, accd has to be restar

```
1) Check whether ACC is installed (exit code 0)
"which acc"
"/dev/acca --version"
2) Download the installer (https://raw.githubusercontent.com/VR-25/acc/master/install-online.sh)
- e.g.,
Expand Down Expand Up @@ -733,7 +733,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, one can flash `/sdcard/Download/acc/acc-uninstaller.zip` or run `mount /system; /data/adb/acc/uninstall.sh`.
From recovery, one can flash `/sdcard/vr25/acc/acc-uninstaller.zip` or run `mount /system; /data/adb/vr25/acc/uninstall.sh`.


### Charging Switch
Expand Down Expand Up @@ -780,7 +780,7 @@ The phone will only draw the max it can take.

### Diagnostics/Logs

Volatile logs (gone on reboot) are stored in `/dev/.acc/`, persistent logs - `/sdcard/Download/acc/logs/`.
Volatile logs (gone on reboot) are stored in `/dev/.acc/`, persistent logs - `/sdcard/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.
Expand All @@ -791,7 +791,7 @@ Automatic exporting (local) happens under specific conditions (refer back to `SE

This can save you a lot of time and grief.

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


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

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).
Please run `acc -le` and upload `/sdcard/vr25/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 @@ -876,7 +876,7 @@ There are no negative consequences when it doesn't.
Open issues on GitHub or contact the developer on Facebook, Telegram (preferred) or XDA (links below).
Always provide as much information as possible.
Attach `/sdcard/Download/acc/logs/acc-logs-*tar.bz2` - generated by `acc -le` _right after_ the problem occurs.
Attach `/sdcard/vr25/acc/logs/acc-logs-*tar.bz2` - generated by `acc -le` _right after_ the problem occurs.
Refer back to `TROUBLESHOOTING > Diagnostics/Logs` for additional details.


Expand Down Expand Up @@ -997,6 +997,21 @@ A common workaround is having `resume_capacity = pause_capacity - 1`. e.g., resu
---
## LATEST CHANGES


**v2020.10.1 (202010010)**

- Fixed automatic charging switch management issues.
- Fixed ghost charging problem related to cooldown and capacity_sync/capacity_freeze2.
- General optimizations
- Persistent data is now saved in /sdcard/vr25/acc/.
- Workaround for EdXposed's service.sh bug

Release Notes

- Confirmed: the MIUI bootloop issue is gone.
- If you face any other issue, run `rm /sdcard/vr25/acc/config.txt; accd` to reset the config and restart accd.


**v2020.9.24 (202009240)**

- Cooldown no longer interferes with capacity_sync.
Expand Down
5 changes: 0 additions & 5 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
remove #legacy

check #wip
run_xtimes()

change data_dir and execDir?
2 changes: 1 addition & 1 deletion acc/acc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ set_prop_() {

! ${verbose:-true} || echo
isAccd=false
execDir=/data/adb/acc
execDir=/data/adb/vr25/acc
defaultConfig=$execDir/default-config.txt

# load generic functions
Expand Down
6 changes: 3 additions & 3 deletions acc/acca.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ daemon_ctrl() {


set -eu
cd /data/adb/acc/
cd /data/adb/vr25/acc/
export TMPDIR=/dev/.acc verbose=false
. ./setup-busybox.sh

config=/sdcard/Download/acc/config.txt
config=/sdcard/vr25/acc/config.txt
defaultConfig=$PWD/default-config.txt

mkdir -p ${config%/*} 2>/dev/null || :
Expand Down Expand Up @@ -57,7 +57,7 @@ case "$@" in
&& grep -q '^POWER_SUPPLY_STATUS=' $batt \
&& batt=${batt%/*} && break
done 2>/dev/null || :
. /data/adb/acc/batt-info.sh
. /data/adb/vr25/acc/batt-info.sh
batt_info "${2-}"
exit 0
;;
Expand Down
14 changes: 8 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 300 # to prevent conflicts with fbind
sleep 30
done
}

Expand Down Expand Up @@ -128,7 +128,7 @@ if [ -f $TMPDIR/.config-ver ] && ! $init; then ###
if is_charging; then

# disable charging under <conditions>
test $(cat $batt/temp 2>/dev/null || cat $batt/batt_temp) -ge $(( ${temperature[1]} * 10 )) \
test $(cat $batt/temp $batt/batt_temp 2>/dev/null) -ge $(( ${temperature[1]} * 10 )) \
&& maxTempPause=true || maxTempPause=false
if $maxTempPause || test $(cat $batt/capacity) -ge ${capacity[3]}; then
disable_charging
Expand All @@ -141,11 +141,11 @@ if [ -f $TMPDIR/.config-ver ] && ! $init; then ###
fi

# cooldown cycle
while [[ -n "${cooldownRatio[0]-}" || -n "${cooldownCustom[0]-}" ]] \
while [ -n "${cooldownRatio[0]-}${cooldownCustom[0]-}" ] \
&& [ $(cat $batt/capacity) -lt ${capacity[3]} ] \
&& is_charging
do
if [ $(cat $batt/temp 2>/dev/null || cat $batt/batt_temp) -ge $(( ${temperature[0]} * 10 )) ] \
if [ $(cat $batt/temp $batt/batt_temp 2>/dev/null) -ge $(( ${temperature[0]} * 10 )) ] \
|| [ $(cat $batt/capacity) -ge ${capacity[1]} ] \
|| [ $(sed s/-// ${cooldownCustom[0]:-cooldownCustom} 2>/dev/null || echo 0) -ge ${cooldownCustom[1]:-1} ]
then
Expand Down Expand Up @@ -178,7 +178,7 @@ if [ -f $TMPDIR/.config-ver ] && ! $init; then ###

# enable charging under <conditions>
[ ! $(cat $batt/capacity) -le ${capacity[2]} ] || {
[ ! $(cat $batt/temp 2>/dev/null || cat $batt/batt_temp) -lt $(( ${temperature[1]} * 10 )) ] \
[ ! $(cat $batt/temp $batt/batt_temp 2>/dev/null) -lt $(( ${temperature[1]} * 10 )) ] \
|| enable_charging
}

Expand All @@ -202,6 +202,7 @@ if [ -f $TMPDIR/.config-ver ] && ! $init; then ###


sync_capacity() {
local isCharging_=$isCharging
! $capacitySync || {
! $cooldown || isCharging=true
if $isCharging; then
Expand All @@ -211,6 +212,7 @@ if [ -f $TMPDIR/.config-ver ] && ! $init; then ###
dumpsys battery unplug \
&& dumpsys battery set status $dischgStatusCode || :
fi
isCharging=$isCharging_
if ${capacity[4]} && [ $(cat $batt/capacity) -ge 2 ]; then
dumpsys battery set level $(cat $batt/capacity) || :
fi
Expand Down Expand Up @@ -256,7 +258,7 @@ else


# log
data_dir=/sdcard/Download/$id
data_dir=/sdcard/vr25/$id
mkdir -p $TMPDIR $data_dir/logs
exec > $data_dir/logs/init.log 2>&1
set -x
Expand Down
2 changes: 1 addition & 1 deletion acc/logf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ logf() {
[ -f $file ] && cp $file ./ && break
done

data_dir=/sdcard/Download/acc
data_dir=/sdcard/vr25/acc
mkdir -p $data_dir

cp $data_dir/logs/* ./ 2>/dev/null
Expand Down
17 changes: 8 additions & 9 deletions acc/misc-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@ cycle_switches() {
&& run_xtimes "echo \$$1 > ${chargingSwitch[3]}" || :
}

[ "$1" != off ] || {
if [ "$1" = on ]; then
not_charging || break
else
if sleep_sd not_charging ${2-}; then
# enforce working charging switch(es)
# set working charging switch(es)
. $execDir/write-config.sh
break
else
# reset switch/group that fails to disable charging
run_xtimes "echo ${chargingSwitch[1]//::/ } > ${chargingSwitch[0]} || :;
echo ${chargingSwitch[4]//::/ } > ${chargingSwitch[3]:-/dev/null} || :" 2>/dev/null
break
fi
}
fi
}
done < $TMPDIR/ch-switches
}
Expand Down Expand Up @@ -247,9 +249,6 @@ print_wait_plug() {


run_xtimes() {
eval "$@"
return $?
#wip
local count=0
for count in $(seq ${ctrlFileWrites[0]}); do
eval "$@"
Expand Down Expand Up @@ -293,10 +292,10 @@ id=acc
umask 0077
switchDelay=7
loopDelay=(5 10)
execDir=/data/adb/acc
execDir=/data/adb/vr25/acc
ctrlFileWrites=(3 0.3)
export TMPDIR=/dev/.acc
config=/sdcard/Download/$id/config.txt
config=/sdcard/vr25/$id/config.txt
config_=$config

[ -f $TMPDIR/.ghost-charging ] \
Expand Down
Loading

0 comments on commit a85fe6c

Please sign in to comment.