forked from Magisk-Modules-Repo/Detach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compatibility.txt
90 lines (70 loc) · 3.46 KB
/
compatibility.txt
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#MODDIR=${0%/*}
#MAGMOD=$MODDIR
instant_run=$MAGMOD/instant_run.sh
instant_run_two=$MAGMOD/instant_run_two.sh
#SQLITE=$MAGMOD
# Multiple Play Store accounts compatibility
ps_accounts=$("$MODDIR/sqlite" $PS_DATA_PATH "SELECT account FROM ownership" | sort -u | wc -l)
ps_accounts_final=$((ps_accounts+1))
test -e "$MAGMOD/first_detach_result.txt" || touch "$MAGMOD/first_detach_result.txt"
chmod 0777 "$MAGMOD/first_detach_result.txt"
#prevent recursive run
#sh "$MAGMOD/main.sh" > "$MAGMOD/first_detach_result.txt" 2>&1
if [ "$ps_accounts" -gt "1" ]; then
test -e "$instant_run_two" || touch "$instant_run_two"
chmod 0777 "$instant_run_two"
echo -e "PLAY_DB_DIR=/data/data/com.android.vending/databases\nSQLITE=${MAGMOD}\n\n\nam force-stop com.android.vending\n\ncd \$SQLITE\nsleep 1\n" >> "$instant_run_two"
am force-stop com.android.vending
for i in {1..${ps_accounts_final}}; do sed -n '/^[[:space:]]*$SQLITE\/sqlite.*/p' "$instant_run" >> "$instant_run_two"; done
#sed -i -e "s/.$(echo a | tr 'a' '\t')\/sqlite/\$SQLITE\/sqlite/" "$instant_run_two"
#sed -i -e 's/..\/sqlite/$SQLITE\/sqlite/' "$instant_run_two"
#sed -i -e 's/.\/sqlite/$SQLITE\/sqlite/' "$instant_run_two"
echo -e '\n' >> "$instant_run_two"
su -c sh "$instant_run_two" > "$MAGMOD/second_detach_result.txt" 2>&1
fi
wrong_result=$(echo "Error: UNIQUE constraint failed: ownership.account,")
if grep -q "$wrong_result" "$MAGMOD/first_detach_result.txt"; then
[ -e "$MODDIR/silent" ] || echo -e "\nDatabase file corrupted\nDatabase file need to be fixed, so please wait some little seconds...\n"; sleep 2;
ACTAPPS=$MAGMOD/actapps.txt
ACTAPPSBCK=$MAGMOD/actapps.bak
FINAL=$MAGMOD/final.sh
for o in "$ACTAPPS" "$ACTAPPSBCK" "$FINAL"; do touch "$o" && cat /dev/null > "$o" && chmod 0644 "$o"; done
PLAY_DB_DIR=/data/data/com.android.vending/databases
sed -n '/^[[:space:]]*$SQLITE\/sqlite.*/p' "$SERVICESH" > "$ACTAPPS"
sed -i -e "s/\$SQLITE\/sqlite \$PLAY_DB_DIR\/library.db \"UPDATE ownership SET library_id = 'u-wl' where doc_id = '//" -i -e "s/'\";//" "$ACTAPPS"
sed -i -e 's/[ \t]*//' "$ACTAPPS"
sed -i -e 's/[[:blank:]]*//' "$ACTAPPS"
cp -f "$ACTAPPS" "$ACTAPPSBCK"
var_ACTAPPS=$(awk '{ print }' "$ACTAPPSBCK")
am force-stop com.android.vending
FIRST_PCK_NAME=$(head -n 1 "$ACTAPPS")
PRESENT_DIR=$(pwd)
SQL_ENTRY_TEST=$(cd $MODDIR && $SQLITE/sqlite $PS_DATA_PATH "SELECT * FROM ownership WHERE doc_id = '${FIRST_PCK_NAME}' AND library_id='3'" | wc -l)
cd "$PRESENT_DIR"
ZERO=0
chmod +x "$FINAL"
if [ "$SQL_ENTRY_TEST" -eq 1 ]; then
echo -e "\ncd $MAGMOD\n\n" >> "$FINAL"
printf '%s\n' "$var_ACTAPPS" | while IFS= read -r line
do echo -e "$SQLITE/sqlite $PLAY_DB_DIR/library.db \"DELETE FROM ownership WHERE doc_id = '$line' AND library_id = '3'\";\n" >> "$FINAL"
done
chmod +x "$FINAL"
su -c sh "$FINAL"
else
echo -e "\ncd $MAGMOD\n\n" >> "$FINAL"
while [ "$ZERO" -le "$SQL_ENTRY_TEST" ]; do
printf '%s\n' "$var_ACTAPPS" | while IFS= read -r line
do echo -e "$SQLITE/sqlite $PLAY_DB_DIR/library.db \"DELETE FROM ownership WHERE doc_id = '$line' AND library_id = '3'\";\n" >> "$FINAL"
done
SQL_ENTRY_TEST=$(($SQL_ENTRY_TEST - 1))
done
su -c sh "$FINAL"
fi
for f in "$ACTAPPS" "$ACTAPPSBCK" "$MAGMOD/first_detach_result.txt"; do rm -f "$f"; done
echo -e "\nDatabase file fixed.\n\nDone\n"; sleep 2;
else
echo -e "\nDone\n"
[ -e "$MODDIR/silent" ] || echo -e "Instant file ready to be executed, path of the file:\n $instant_run\n"
fi
#For while loop closing in main.sh
done &)