Skip to content

Commit 623ef03

Browse files
committed
**2020.2.23-dev (202002230)**
- Updated strings > Note: incompatible with AccA versions lower than 1.0.21 **2020.2.22-r1-dev (202002221)** - acc -D: show accd version and PID as well - acc -F: optimizations - acc -s s: fixed "print_known_cs: not found" - acc -v: new output format - `version (version_code)` > Note: incompatible with AccA versions lower than 1.0.21 **2020.2.22-dev (202002220)** - Ability to set/nullify multiple properties with a single command (e.g., `acc -s prop1=value "prop2=value1 value2 ..." prop3=`) - `acc --uninstall` (-U) and the flashable uninstaller remove AccA as well - Better localization support - capacity_sync and cooldown cycle improvements - Changes made by `apply_on_boot()` and `apply_on_plug()` are reverted automatically when appropriate - config.txt contains a comprehensive help text as well - Dedicated current control commmands - Custom configuration for specific devices (`acc/oem-custom.sh`) - Enhanced commmand list and examples (`acc -h`) - Extended device support (ASUS, MediaTek, Pixel 4/XL, Razer, 1+7 and more) - General wizard (`acc` command) - Greater charging control flexibility - More modular design - New config format and more flexible APIs - Optimized busybox setup - Prevent power events from waking the screen during the cooldown cycle - `runCmdOnPause` - Self-disable after a bootloop event - Symlink `installDir` to `/data/adb/acc` and `/data/adb/modules/acc` - The help text (acc -h), documentation (acc -r), logs (acc -l) and config (acc -c) open in vim/vi by default (scrollable) - Universal zip flasher (`acc -F "zip_file"`) - Updated documentation and framework > Notes: incompatible with AccA versions lower than 1.0.21; config will be reset
1 parent b577a38 commit 623ef03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+3144
-2211
lines changed

META-INF/com/google/android/update-binary

+97-71
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/system/bin/sh
22
# $id Installer/Upgrader
3-
# Copyright (c) 2019, VR25 (xda-developers.com)
3+
# Copyright (c) 2019-2020, VR25 (xda-developers)
44
# License: GPLv3+
55

6+
# override the official Magisk module installer
7+
SKIPUNZIP=1
8+
69
set +x
710
echo
811
id=acc
@@ -16,23 +19,25 @@ set -x
1619
trap 'e=$?; echo; exit $e' EXIT
1720

1821
# set up busybox
22+
#BB#
1923
if [ -d /sbin/.magisk/busybox ]; then
20-
[[ $PATH == /sbin/.magisk/busybox* ]] || PATH=/sbin/.magisk/busybox:$PATH
21-
elif [ -d /sbin/.core/busybox ]; then
22-
[[ $PATH == /sbin/.core/busybox* ]] || PATH=/sbin/.core/busybox:$PATH
24+
[[ $PATH == /sbin/.magisk/busybox:* ]] || PATH=/sbin/.magisk/busybox:$PATH
2325
else
24-
[[ $PATH == /dev/.busybox* ]] || PATH=/dev/.busybox:$PATH
25-
if ! mkdir -m 700 /dev/.busybox 2>/dev/null; then
26-
if [ -x /data/adb/magisk/busybox ]; then
27-
/data/adb/magisk/busybox --install -s /dev/.busybox
28-
elif which busybox > /dev/null; then
26+
mkdir -p -m 700 /dev/.busybox
27+
[[ $PATH == /dev/.busybox:* ]] || PATH=/dev/.busybox:$PATH
28+
if [ ! -x /dev/.busybox/busybox ]; then
29+
if which busybox > /dev/null; then
2930
busybox --install -s /dev/.busybox
31+
elif [ -f /data/adb/busybox ]; then
32+
chmod 700 /data/adb/busybox
33+
/data/adb/busybox --install -s /dev/.busybox
3034
else
3135
echo "(!) Install busybox binary first"
3236
exit 3
3337
fi
3438
fi
3539
fi
40+
#/BB#
3641

3742
# root check
3843
if [ $(id -u) -ne 0 ]; then
@@ -43,8 +48,8 @@ fi
4348
print() { sed -n "s|^$1=||p" ${2:-$srcDir/module.prop}; }
4449

4550
set_perms() {
46-
local owner=${2:-0} perms=0600 target=$(readlink -f $1)
47-
if echo $target | grep -q '.*\.sh$' || [ -d $target ]; then perms=0700; fi
51+
local owner=${2:-0} perms=600 target=$(readlink -f $1)
52+
if echo $target | grep -q '.*\.sh$' || [ -d $target ]; then perms=700; fi
4853
chmod $perms $target
4954
chown $owner:$owner $target
5055
restorecon $target > /dev/null 2>&1 || :
@@ -55,118 +60,135 @@ set_perms_recursive() {
5560
find $1 2>/dev/null | while read target; do set_perms $target $owner; done
5661
}
5762

58-
set -euo pipefail
63+
set -euo pipefail 2>/dev/null || :
5964

6065
# set source code directory
6166
[ -f $PWD/${0##*/} ] && srcDir=$PWD || srcDir=${0%/*}
67+
srcDir=${srcDir/#"${0##*/}"/"."}
6268

6369
# unzip flashable zip if source code is unavailable
6470
if [ ! -f $srcDir/module.prop ]; then
6571
srcDir=/dev/.tmp
6672
rm -rf $srcDir 2>/dev/null || :
6773
mkdir $srcDir
68-
unzip -o ${ZIP:-${3:-}} -d $srcDir/ >&2
74+
unzip ${ZIP:-${3-}} -d $srcDir/ >&2
6975
fi
7076

7177
name=$(print name)
7278
author=$(print author)
7379
version=$(print version)
7480
versionCode=$(print versionCode)
75-
installDir=${installDir0:-/data/data/mattecarra.accapp/files}
76-
config=/data/media/0/$id/${id}.conf
77-
78-
# migrate/restore config
79-
[ -f $config ] || mv ${config%/*}/config.txt $config 2>/dev/null || :
80-
if [ -d ${config%/*} ] && [ ! -d /data/adb/${id}-data ]; then
81-
mv $config ${config%/*}/config.txt 2>/dev/null || :
82-
(cd /data/media/0; mv ${config%/*} ${id}-data
83-
tar -cf - ${id}-data | tar -xf - -C /data/adb)
84-
rm -rf ${id}-data
85-
fi
81+
installDir=${installDir0:=/data/data/mattecarra.accapp/files}
8682
config=/data/adb/${id}-data/config.txt
83+
84+
# restore config backup
8785
[ -f $config ] || cp /data/media/0/.${id}-config-backup.txt $config 2>/dev/null || :
8886

89-
configVer=$(print versionCode $config 2>/dev/null || :)
87+
configVer=$(print configVerCode $config 2>/dev/null || :)
9088

9189
# check/set parent installation directory
9290
[ -d $installDir ] || installDir=/sbin/.magisk/modules
93-
[ -d $installDir ] || installDir=/sbin/.core/img
9491
[ -d $installDir ] || installDir=/data/adb
9592
[ -d $installDir ] || { echo "(!) /data/adb/ not found\n"; exit 1; }
9693

9794

95+
# install
96+
9897
cat << EOF
9998
$name $version
100-
Copyright (c) 2017-2019, $author
99+
Copyright (c) 2017-2020, $author
101100
License: GPLv3+
102101
103102
(i) Installing in $installDir/$id/...
104103
EOF
105104

105+
/sbin/.acc-en --daemon stop > /dev/null 2>&1 || :
106106

107-
(pkill -9 -f "/$id (-|--)|/${id}d.sh" ) || :
107+
rm -rf $(readlink -f /sbin/.$id/$id || :) $installDir/$id \
108+
/data/adb/$id /sbin/.magisk/modules/$id 2>/dev/null || :
108109

109-
# install
110-
rm -rf $(readlink -f /sbin/.$id/$id) $installDir/$id 2>/dev/null || :
111110
cp -R $srcDir/$id/ $installDir/
112-
installDir=$installDir/$id
113-
[ ${installDir0:-x} == x ] && installDir0=/data/data/mattecarra.accapp/files/$id || installDir0=$installDir0/$id
111+
installDir=$(readlink -f $installDir/$id)
112+
installDir0=$installDir0/$id
113+
[ ! -d $installDir0 ] || installDir0=$(readlink -f $installDir0)
114114
cp $srcDir/module.prop $installDir/
115115

116116
mkdir -p ${config%/*}/info
117117
cp -f $srcDir/*.md ${config%/*}/info
118+
[ $installDir == /data/adb/$id ] || ln -s $installDir /data/adb/
118119

119-
case $installDir in
120-
/data/adb/$id|$installDir0)
121-
mv $installDir/service.sh $installDir/${id}-init.sh;;
122-
*)
123-
ln $installDir/service.sh $installDir/post-fs-data.sh;;
124-
esac
125120

126-
# patch/upgrade config
121+
if [ $installDir != /sbin/.magisk/modules/$id ]; then
122+
mv $installDir/service.sh $installDir/${id}-init.sh
123+
124+
# enable upgrading through Magisk Manager
125+
ln -s $installDir /sbin/.magisk/modules/$id 2>/dev/null || :
126+
127+
# set up alternate initializer (Magisk service.d)
128+
cat << EOF > /data/adb/service.d/${id}-init.sh
129+
#!/system/bin/sh
130+
# alternate $id initializer
131+
(until [ -d /storage/emulated/0/?ndroid ]; do sleep 10; done
132+
if [ -f $installDir/${id}-init.sh ]; then
133+
$installDir/${id}-init.sh
134+
else
135+
rm \$0
136+
fi
137+
exit 0 &) &
138+
exit 0
139+
EOF
140+
chmod 700 /data/adb/service.d/${id}-init.sh
141+
142+
# set up cleanup script
143+
cat << EOF > /data/adb/service.d/${id}-cleanup.sh
144+
#!/system/bin/sh
145+
# $id post-uninstall cleanup
146+
(until [ -d /storage/emulated/0/?ndroid ]; do sleep 15; done
147+
if [ ! -f $installDir/module.prop ]; then
148+
rm /data/adb/$id /data/adb/${id}-data /data/adb/modules/$id \$0 2>/dev/null
149+
fi
150+
exit 0 &) &
151+
exit 0
152+
EOF
153+
chmod 700 /data/adb/service.d/${id}-cleanup.sh
154+
fi
155+
156+
157+
touch /sbin/.magisk/modules/$id/skip_mount 2>/dev/null || :
158+
159+
# patch/reset config
127160
if [ -f $config ]; then
128-
if [ ${configVer:-0} -lt 201910130 ] \
129-
|| [ ${configVer:-0} -gt $(print versionCode $installDir/default-config.txt) ]
130-
then
131-
rm $config
132-
# else
133-
# if [ $configVer -lt 201906290 ]; then
134-
# echo prioritizeBattIdleMode=false >> $config
135-
# sed -i '/^versionCode=/s/=.*/=201906290/' $config
136-
# fi
137-
# if [ $configVer -lt 201907080 ]; then
138-
# sed -i '/^loopDelay=/s/=.*/=10,30/' $config
139-
# sed -i '/^versionCode=/s/=.*/=201907080/' $config
140-
# fi
141-
# if [ $configVer -lt 201907090 ]; then
142-
# sed -i '/^rebootOnUnplug=/d' $config
143-
# sed -i '/^versionCode=/s/=.*/=201907090/' $config
144-
# fi
145-
# if [ $configVer -lt 201909260 ]; then
146-
# sed -i '/^loopDelay=/s/,30/,15/' $config
147-
# sed -i '/^versionCode=/s/=.*/=201909260/' $config
148-
# fi
161+
dConfVer=$(print configVerCode $installDir/default-config.txt)
162+
if [[ ${configVer:-0} -gt $dConfVer || ${configVer:-0} -lt 202002220 ]]; then
163+
rm $config /sdcard/acc-logs-*.tar.bz2 2>/dev/null || :
164+
# else
165+
# if [ $configVer -lt 201906290 ]; then
166+
# echo prioritizeBattIdleMode=false >> $config
167+
# sed -i '/^configVerCode=/s/=.*/=201906290/' $config
168+
# fi
149169
fi
170+
unset dConfVer
150171
fi
151172

173+
# flashable uninstaller
152174
cp -f $srcDir/bin/${id}-uninstaller.zip /data/media/0/
153175

154176
# set perms
155177
set_perms_recursive ${config%/*}
156-
chmod 0666 /data/media/0/${id}-uninstaller.zip
178+
chmod 666 /data/media/0/${id}-uninstaller.zip
157179
case $installDir in
158180
/data/*/files/$id)
159181
pkg=${installDir%/files/$id}
160182
pkg=${pkg##/data*/}
161-
owner=$(grep $pkg /data/system/packages.list | awk '{print $2}')
183+
owner=$(grep $pkg /data/system/packages.list | cut -d ' ' -f 2)
162184
set_perms_recursive ${installDir%/*} $owner
163185
;;
164186
*)
165187
set_perms_recursive $installDir
166188
;;
167189
esac
168190

169-
set +euo pipefail
191+
set +euo pipefail 2>/dev/null || :
170192

171193

172194
cat << EOF
@@ -178,25 +200,26 @@ EOF
178200

179201

180202
# print changelog
181-
tail -n +$(grep -n \($versionCode\) ${config%/*}/info/README.md | cut -d: -f1) \
182-
${config%/*}/info/README.md | sed 's/^/ /'
203+
sed -n "\|\($versionCode\)|,\$s|^| |p" ${config%/*}/info/README.md
183204

184205

185206
cat << EOF
186207
187208
LINKS
188-
- ACC app: github.com/MatteCarra/AccA/
209+
- ACC app: GitHub.com/MatteCarra/AccA/
189210
- Battery University: batteryuniversity.com/learn/article/how_to_prolong_lithium_based_batteries/
190-
- Donate: paypal.me/vr25xda/
191-
- Daily Job Scheduler: github.com/VR-25/djs/
192-
- Facebook page: facebook.com/VR25-at-xda-developers-258150974794782/
193-
- Git repository: github.com/VR-25/$id/
211+
- Daily Job Scheduler: GitHub.com/VR-25/djs/
212+
- Facebook page: fb.me/vr25xda/
213+
- Git repository: GitHub.com/VR-25/$id/
214+
- Liberapay: liberapay.com/VR25/
215+
- Patreon: patreon.com/vr25/
216+
- PayPal: paypal.me/vr25xda/
194217
- Telegram channel: t.me/vr25_xda/
195218
- Telegram group: t.me/${id}_group/
196219
- Telegram profile: t.me/vr25xda/
197220
- XDA thread: forum.xda-developers.com/apps/magisk/module-magic-charging-switch-cs-v2017-9-t3668427/
198221
199-
(i) Important info: https://bit.ly/2TRqRz0
222+
(i) Power supply logs (help needed): https://bit.ly/2TRqRz0
200223
201224
(i) Rebooting is unnecessary.
202225
- $id can be used right now.
@@ -209,6 +232,9 @@ EOF
209232
echo
210233
trap - EXIT
211234

235+
# remove bootloop lock file
236+
rm /data/adb/${id}-data/logs/.bootlooped 2>/dev/null
237+
212238
# initialize $id
213239
if grep -q /storage/emulated /proc/mounts; then
214240
if [ -f $installDir/service.sh ]; then

0 commit comments

Comments
 (0)