Skip to content

Commit db1d0ff

Browse files
committed
**2020.3.30-dev (202003300)**
- `-C|--calibrate`: charge until battery_status == "Full" - `acc -i`: fixed current_now conversion (Redmi 6 Pro and other msm8953 based devices) - `acc -u, install-latest.sh`: optional -k|--insecure flag - accd manages capacity_sync loop_delay_charging, loop_delay_discharging and switch_delay parameters dynamically - Charging switch tests take significantly longer (switch_delay=18); this leads to more consistent results - Enable Android battery saver on capacity <= shutdown_capacity + 5 - Enriched help text (acc -h|--help) - Major optimizations - More modular design - Portability enhancements - Vibrate 3 times when an error occurs - Vibrate 5 times on capacity <= shutdown_capacity + 5, and again on each subsequent capacity drop - Vibrate 5 times when `acc --calibrate` reaches 100% - Updated documentation
1 parent 8160467 commit db1d0ff

Some content is hidden

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

41 files changed

+1218
-1031
lines changed

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ _builds
22
_misc
33
.directory
44
*.kate-swp
5-
*:wip:*

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

+28-45
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66
# devs: triple hashtags (###) mark custom code
77

88

9+
set +x
10+
911
# override the official Magisk module installer
1012
SKIPUNZIP=1
1113

12-
set +x
1314
echo
1415
id=acc
1516
umask 077
@@ -29,33 +30,34 @@ if [ -d /sbin/.magisk/busybox ]; then
2930
*) PATH=/sbin/.magisk/busybox:$PATH;;
3031
esac
3132
else
32-
mkdir -p -m 700 /dev/.busybox
33+
mkdir -p /dev/.busybox
34+
chmod 700 /dev/.busybox
3335
case $PATH in
3436
/dev/.busybox:*) :;;
3537
*) PATH=/dev/busybox:$PATH;;
3638
esac
37-
if [ ! -x /dev/.busybox/busybox ]; then
39+
[ -x /dev/.busybox/busybox ] || {
3840
if [ -f /data/adb/magisk/busybox ]; then
39-
chmod 700 /data/adb/magisk/busybox
41+
[ -x /data/adb/magisk/busybox ] || chmod 700 /data/adb/magisk/busybox
4042
/data/adb/magisk/busybox --install -s /dev/.busybox
4143
elif which busybox > /dev/null; then
4244
busybox --install -s /dev/.busybox
4345
elif [ -f /data/adb/busybox ]; then
44-
chmod 700 /data/adb/busybox
46+
[ -x /data/adb/busybox ] || chmod 700 /data/adb/busybox
4547
/data/adb/busybox --install -s /dev/.busybox
4648
else
47-
echo "(!) Install busybox binary first"
49+
echo "(!) Install busybox or simply place it in /data/adb/"
4850
exit 3
4951
fi
50-
fi
52+
}
5153
fi
5254
#/BB#
5355

5456
# root check
55-
if [ $(id -u) -ne 0 ]; then
57+
[ $(id -u) -ne 0 ] && {
5658
echo "(!) $0 must run as root (su)"
5759
exit 4
58-
fi
60+
}
5961

6062
get_prop() { sed -n "s|^$1=||p" ${2:-$srcDir/module.prop}; }
6163

@@ -79,12 +81,12 @@ set -euo pipefail 2>/dev/null || :
7981
srcDir=${srcDir/#"${0##*/}"/"."}
8082

8183
# unzip flashable zip if source code is unavailable
82-
if [ ! -f $srcDir/module.prop ]; then
84+
[ -f $srcDir/module.prop ] || {
8385
srcDir=/dev/.tmp
8486
rm -rf $srcDir 2>/dev/null || :
8587
mkdir $srcDir
8688
unzip ${ZIP:-${3-}} -d $srcDir/ >&2
87-
fi
89+
}
8890

8991
name=$(get_prop name)
9092
author=$(get_prop author)
@@ -108,7 +110,7 @@ License: GPLv3+
108110

109111

110112
# install
111-
mv -f $config /data/.${id}-config-bkp 2>/dev/null || :
113+
cp $config /data/.${id}-config-bkp 2>/dev/null || :
112114
/system/bin/sh $srcDir/$id/uninstall.sh
113115
mv /data/.${id}-config-bkp $config 2>/dev/null || :
114116
cp -R $srcDir/$id/ $installDir/
@@ -127,7 +129,7 @@ if [ $installDir != /sbin/.magisk/modules/$id ]; then
127129
# enable upgrading through Magisk Manager
128130
ln -s $installDir /sbin/.magisk/modules/$id 2>/dev/null || :
129131

130-
if [ -d /data/adb/service.d ]; then
132+
[ ! -d /data/adb/service.d ] || {
131133

132134
# alternate initialization script
133135
echo "#!/system/bin/sh
@@ -152,7 +154,7 @@ exit 0 &) &
152154
exit 0" > /data/adb/service.d/${id}-cleanup.sh
153155

154156
chmod 700 /data/adb/service.d/${id}-*.sh
155-
fi
157+
}
156158

157159
else
158160
# workaround for Magisk "forgetting service.sh" issue
@@ -167,21 +169,16 @@ touch /sbin/.magisk/modules/$id/skip_mount 2>/dev/null || :
167169
[ -f $config ] || cp /data/media/0/.${id}-config-backup.txt $config 2>/dev/null || :
168170

169171
# patch/reset config ###
170-
if [ -f $config ]; then
172+
[ ! -f $config ] || {
171173
! grep -q '=20200260$' $config \
172174
|| sed -i 's/=20200260$/=202002260/' $config # bugfix
173175
configVer=$(get_prop configVerCode $config 2>/dev/null || :)
174176
dConfVer=$(get_prop configVerCode $installDir/default-config.txt)
175177
if [ ${configVer:-0} -gt $dConfVer ] || [ ${configVer:-0} -lt 202002220 ]; then
176178
rm $config /sdcard/${id}-logs-*.tar.bz2 2>/dev/null || :
177-
# else
178-
# if [ $configVer -lt 201906290 ]; then
179-
# echo prioritizeBattIdleMode=false >> $config
180-
# sed -i '/^configVerCode=/s/=.*/=201906290/' $config
181-
# fi
182179
fi
183180
unset dConfVer
184-
fi
181+
}
185182

186183
# flashable uninstaller
187184
cp -f $srcDir/bin/${id}-uninstaller.zip /data/media/0/
@@ -206,32 +203,18 @@ set +euo pipefail 2>/dev/null || :
206203

207204
echo "- Done
208205
209-
LATEST CHANGES
210206
211207
"
212208

213209

214-
# print changelog
215-
sed -n "\|\($versionCode\)|,\$s|^| |p" ${config%/*}/info/README.md
210+
# print links and changelog
211+
sed -En "\|## LINKS|,\$p" ${config%/*}/info/README.md \
212+
| grep -v '^---' | sed 's/^## //'
216213

217214

218215
###
219216
echo "
220-
LINKS
221-
- ACC app: GitHub.com/MatteCarra/AccA/
222-
- Battery University: batteryuniversity.com/learn/article/how_to_prolong_lithium_based_batteries/
223-
- Daily Job Scheduler: GitHub.com/VR-25/djs/
224-
- Facebook page: fb.me/vr25xda/
225-
- Git repository: GitHub.com/VR-25/$id/
226-
- Liberapay: liberapay.com/VR25/
227-
- Patreon: patreon.com/vr25/
228-
- PayPal: paypal.me/vr25xda/
229-
- Telegram channel: t.me/vr25_xda/
230-
- Telegram group: t.me/${id}_group/
231-
- Telegram profile: t.me/vr25xda/
232-
- XDA thread: forum.xda-developers.com/apps/magisk/module-magic-charging-switch-cs-v2017-9-t3668427/
233-
234-
(i) Power supply logs (help needed): https://bit.ly/2TRqRz0
217+
235218
236219
(i) Rebooting is unnecessary.
237220
- $id can be used right now.
@@ -244,14 +227,14 @@ echo
244227
trap - EXIT
245228

246229
# initialize $id
247-
if grep -q /storage/emulated /proc/mounts; then
248-
if [ -f $installDir/service.sh ]; then
249-
$installDir/service.sh --override
250-
else
251-
$installDir/${id}-init.sh --override
252-
fi
230+
if [ -f $installDir/service.sh ]; then
231+
$installDir/service.sh --override
232+
else
233+
$installDir/${id}-init.sh --override
253234
fi
254235

255236
e=$?
256237
[ $e -eq 0 ] || { echo; exit $e; }
238+
rm /sbin/.$id/.ghost-charging 2>/dev/null ###
239+
/sbin/acca --daemon > /dev/null || /sbin/accd ### workaround, Magisk 20.4+
257240
exit 0

0 commit comments

Comments
 (0)