To make it compatible with user (not userdebug) builds, use adb shell su instead of adb root whenever possible (#102)

This commit is contained in:
Chang Qian (Fred)
2025-09-12 23:11:41 -07:00
committed by GitHub
parent 643bdd8984
commit 928b92ade1
+28 -22
View File
@@ -7,18 +7,12 @@ cd "$PROG_DIR"
# Please check that your path is the same, since this might be different among devices # Please check that your path is the same, since this might be different among devices
# RES_DIR="/mnt/sdcard/tencent/MicroMsg" # old version of wechat use this path. # RES_DIR="/mnt/sdcard/tencent/MicroMsg" # old version of wechat use this path.
RES_DIR="/data/data/com.tencent.mm" RES_DIR="/data/data/com.tencent.mm/MicroMsg"
MM_DIR="/data/data/com.tencent.mm"
echo "Starting rooted adb server..."
adb root
if [[ $1 == "db" || $1 == "res" ]]; then if [[ $1 == "db" || $1 == "res" ]]; then
echo "Looking for user dir name..." echo "Looking for user dir name..."
sleep 1 # sometimes adb complains: device not found
# look for dirname which looks like md5 (32 alpha-numeric chars) # look for dirname which looks like md5 (32 alpha-numeric chars)
userList=$(adb ls $RES_DIR | cut -f 4 -d ' ' | sed 's/[^0-9a-z]//g' \ userList=$(adb shell su -c "ls $RES_DIR" | awk '{if (length() == 32) print}')
| awk '{if (length() == 32) print}')
numUser=$(echo "$userList" | wc -l) numUser=$(echo "$userList" | wc -l)
# choose the first user. # choose the first user.
chooseUser=$(echo "$userList" | head -n1) chooseUser=$(echo "$userList" | head -n1)
@@ -35,20 +29,21 @@ if [[ $1 == "db" || $1 == "res" ]]; then
echo "Pulling resources... " echo "Pulling resources... "
for d in avatar image2 voice2 emoji video sfs; do for d in avatar image2 voice2 emoji video sfs; do
echo "Trying to download $RES_DIR/$chooseUser/$d with busybox ..." echo "Trying to download $RES_DIR/$chooseUser/$d with busybox ..."
adb shell "cd $RES_DIR/$chooseUser && adb shell su -c "busybox tar czf - $RES_DIR/$chooseUser/$d 2>/dev/null |
busybox tar czf - $d 2>/dev/null | busybox base64" | busybox base64" | base64 -di | tar xzf - --strip-components 5
base64 -di | tar xzf -
[[ -d $d ]] && continue [[ -d $d ]] && continue
echo "Trying to download $RES_DIR/$chooseUser/$d with tar & base64 ..." echo "Trying to download $RES_DIR/$chooseUser/$d with tar & base64 ..."
adb shell "cd $RES_DIR/$chooseUser && adb shell su -c "tar czf - $RES_DIR/$chooseUser/$d 2>/dev/null | base64" |
tar czf - $d 2>/dev/null | base64" | base64 -di | tar xzf - base64 -di | tar xzf - --strip-components 5
[[ -d $d ]] && continue [[ -d $d ]] && continue
echo "Trying to download $RES_DIR/$chooseUser/$d with adb pull (slow) ..." echo "Trying to download $RES_DIR/$chooseUser/$d with adb pull (slow) ..."
mkdir -p $d mkdir -p $d
( (
cd $d || exit cd $d || exit
adb root
sleep 1 # sometimes adb complains: device not found
adb pull "$RES_DIR/$chooseUser/$d" adb pull "$RES_DIR/$chooseUser/$d"
) )
@@ -60,18 +55,29 @@ if [[ $1 == "db" || $1 == "res" ]]; then
echo "Total size: $(du -sh | cut -f1)" echo "Total size: $(du -sh | cut -f1)"
) )
else else
echo "Pulling database and avatar index file..." for f in EnMicroMsg.db sfs/avatar.index; do
adb pull $MM_DIR/MicroMsg/$chooseUser/EnMicroMsg.db echo "Trying to download $RES_DIR/$chooseUser/$f with busybox ..."
[[ -f EnMicroMsg.db ]] && \ adb shell su -c "busybox tar czf - $RES_DIR/$chooseUser/$f 2>/dev/null |
echo "Database successfully downloaded to EnMicroMsg.db" || { busybox base64" | base64 -di | tar xzf - --strip-components 5
>&2 echo "Failed to pull database by adb!" [[ -f $f ]] && continue
exit 1
echo "Trying to download $RES_DIR/$chooseUser/$f with tar & base64 ..."
adb shell su -c "tar czf - $RES_DIR/$chooseUser/$f 2>/dev/null | base64" |
base64 -di | tar xzf - --strip-components 5
[[ -f $f ]] && continue
echo "Trying to download $RES_DIR/$chooseUser/$f with adb pull..."
adb root
sleep 1
adb pull $RES_DIR/$chooseUser/$f
[[ -f $f ]] || {
echo "Failed to download $RES_DIR/$chooseUser/$f"
} }
adb pull $MM_DIR/MicroMsg/$chooseUser/sfs/avatar.index done
[[ -f avatar.index ]] && echo "Avatar index successfully downloaded to avatar.index" echo "Database and avatar index file successfully downloaded"
fi fi
else else
echo "Usage: $0 <res|db>" echo "Usage: $0 <res|db>"
exit 1 exit 1
fi fi