#!/system/bin/sh

read input

case "$input" in
    1) opt="国际服" ;;
    2) opt="日韩服" ;;
    3) opt="台湾服" ;;
    4) opt="越南服" ;;
    5) opt="体验服" ;;
    *) echo "无效输入（请输入 1~5）" ; exit 1 ;;
esac

kill_by_pkgname() {
    pkgname=$1
    pid=$(pidof $pkgname)
    if [ -n "$pid" ]; then
        kill $pid
        sleep 1
    fi
}

reset_guest_data() {
    pkgname=$1
    kill_by_pkgname $pkgname
    rm -rf /data/data/$pkgname/shared_prefs
    mkdir /data/data/$pkgname/shared_prefs
    chmod 777 /data/data/$pkgname/shared_prefs
    rm -rf /data/data/$pkgname/files
    GUEST="/data/data/$pkgname/shared_prefs/device_id.xml"
    echo "<?xml version='1.0' encoding='utf-8' standalone='yes' ?><map><string name=\"uuid\">$RANDOM$RANDOM-$RANDOM-$RANDOM-$RANDOM-$RANDOM$RANDOM$RANDOM</string></map>" > "$GUEST"
    echo "$opt 重置完成！"
}

case "$opt" in
    "国际服") reset_guest_data "com.tencent.ig" ;;
    "日韩服") reset_guest_data "com.pubg.krmobile" ;;
    "台湾服") reset_guest_data "com.rekoo.pubgm" ;;
    "越南服") reset_guest_data "com.vng.pubgmobile" ;;
    "体验服") reset_guest_data "com.tencent.igce" ;;
esac
