-
Notifications
You must be signed in to change notification settings - Fork 2
/
50-7SIM.sh
63 lines (59 loc) · 1.98 KB
/
50-7SIM.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/sbin/sh
#
# ADDOND_VERSION=3
#
# /system/addon.d/50-7SIM.sh
# During an OTA update, this script backs up the app and all relative files;
# /system is formatted and reinstalled, then files are restored.
#
. /tmp/backuptool.functions
# update-binary|updater <RECOVERY_API_VERSION> <OUTFD> <ZIPFILE>
OUTFD=$(ps | grep -v 'grep' | grep -oE 'update(.*) 3 [0-9]+' | cut -d" " -f3)
[ -z $OUTFD ] && OUTFD=$(ps -Af | grep -v 'grep' | grep -oE 'update(.*) 3 [0-9]+' | cut -d" " -f3)
# update_engine_sideload --payload=file://<ZIPFILE> --offset=<OFFSET> --headers=<HEADERS> --status_fd=<OUTFD>
[ -z $OUTFD ] && OUTFD=$(ps | grep -v 'grep' | grep -oE 'status_fd=[0-9]+' | cut -d= -f2)
[ -z $OUTFD ] && OUTFD=$(ps -Af | grep -v 'grep' | grep -oE 'status_fd=[0-9]+' | cut -d= -f2)
if [ -z $OUTFD ]; then
ui_print() { echo "$1"; }
else
ui_print() { echo -e "ui_print $1\nui_print" >> /proc/self/fd/$OUTFD; }
fi
list_files() {
# NOTE: avoid using 'cat <<HERE-DOC' here, as it attempts to create a temporary file
# in $TMPDIR that on some recoveries is set to /data/local/tmp, but the /data
# can be missing if the recovery doesn't support decryption, so this func will
# output nothing but a "can't create temporary file : No such file or directory"
# error to stderr. Therefore, we echo everything instead.
echo 'system_ext/priv-app/7SIM/7SIM.apk'
echo 'system_ext/etc/permissions/privapp_whitelist_com.github.iusmac.sevensim.xml'
echo 'priv-app/7SIM/7SIM.apk'
echo 'etc/permissions/privapp_whitelist_com.github.iusmac.sevensim.xml'
}
case "$1" in
backup)
ui_print "- Backing up 7SIM"
list_files | while read FILE DUMMY; do
backup_file $S/"$FILE"
done
;;
restore)
ui_print "- Restoring 7SIM"
list_files | while read FILE REPLACEMENT; do
R=""
[ -n "$REPLACEMENT" ] && R="$S/$REPLACEMENT"
[ -f "$C/$S/$FILE" ] && restore_file $S/"$FILE" "$R"
done
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
# Stub
;;
esac