176 lines
3.7 KiB
Bash
176 lines
3.7 KiB
Bash
|
:
|
|||
|
|
|||
|
initialization() {
|
|||
|
GOODS_NUMBER=10
|
|||
|
SHELL_DIR=$(pwd)
|
|||
|
|
|||
|
ADB="$(which adb)"
|
|||
|
if [ "${ADB}" = "" ]; then
|
|||
|
ADB="";
|
|||
|
else
|
|||
|
ADB="$ADB shell"
|
|||
|
fi
|
|||
|
|
|||
|
#显示 true false
|
|||
|
showing=$(${ADB} dumpsys window policy | grep 'showing=' | cut -d = -f 2)
|
|||
|
#睡眠 true false
|
|||
|
dreaming=$(${ADB} dumpsys window policy | grep 'dreaming=' | cut -d = -f 2)
|
|||
|
#屏幕状态 SCREEN_STATE_OFF SCREEN_STATE_ON
|
|||
|
screenState=$(${ADB} dumpsys window policy | grep 'screenState=' | cut -d = -f 2)
|
|||
|
#交互状态 INTERACTIVE_STATE_SLEEP INTERACTIVE_STATE_AWAKE
|
|||
|
interactiveState=$(${ADB} dumpsys window policy | grep 'interactiveState=' | cut -d = -f 2)
|
|||
|
|
|||
|
mTrusted=$(${ADB} dumpsys window policy | grep 'mTrusted=' | cut -d = -f 2)
|
|||
|
}
|
|||
|
|
|||
|
sleep_() {
|
|||
|
sleep 1
|
|||
|
sleep $1
|
|||
|
}
|
|||
|
|
|||
|
Lock_screen() {
|
|||
|
|
|||
|
if test "${showing}" = "true" -a "${dreaming}" = "true" -a "${screenState}" = "SCREEN_STATE_OFF" -a ${interactiveState} = "INTERACTIVE_STATE_SLEEP"; then
|
|||
|
#点亮屏幕
|
|||
|
${ADB} input keyevent 26
|
|||
|
${ADB} input swipe 540 1810 540 1500 200;
|
|||
|
|
|||
|
if test ${mTrusted} = "false"; then
|
|||
|
${ADB} input tap 242 1130 #1
|
|||
|
${ADB} input tap 832 1593 #9
|
|||
|
${ADB} input tap 520 1577 #8
|
|||
|
${ADB} input tap 832 1593 #9
|
|||
|
${ADB} input tap 242 1130 #1
|
|||
|
${ADB} input tap 536 1790 #0
|
|||
|
${ADB} input tap 536 1790 #0
|
|||
|
${ADB} input tap 832 1593 #9
|
|||
|
${ADB} input tap 824 1807 #enter
|
|||
|
sleep_ 1
|
|||
|
fi
|
|||
|
else
|
|||
|
:
|
|||
|
fi
|
|||
|
}
|
|||
|
|
|||
|
Weipaitang() {
|
|||
|
#打开微拍堂
|
|||
|
${ADB} am start -n com.weipaitang.wpt/com.weipaitang.wpt.wptnative.module.launch.MainActivity
|
|||
|
sleep_ 5
|
|||
|
#我的
|
|||
|
${ADB} input tap 950 1982
|
|||
|
sleep_ 3
|
|||
|
${ADB} input tap 960 246
|
|||
|
sleep_ 3
|
|||
|
${ADB} input tap 483 772
|
|||
|
sleep_ 2
|
|||
|
|
|||
|
${ADB} input keyevent 4
|
|||
|
}
|
|||
|
|
|||
|
Salted_fish() {
|
|||
|
#打开APP
|
|||
|
${ADB} am start -n com.taobao.idlefish/com.taobao.fleamarket.home.activity.InitActivity
|
|||
|
sleep_ 5
|
|||
|
|
|||
|
#我的
|
|||
|
${ADB} input tap 964 1960
|
|||
|
sleep_ 1
|
|||
|
|
|||
|
#下拉
|
|||
|
${ADB} input swipe 500 480 500 1100 200;
|
|||
|
sleep_ 2
|
|||
|
|
|||
|
#我发布的
|
|||
|
${ADB} input tap 134 1753
|
|||
|
sleep_ 1
|
|||
|
|
|||
|
#擦亮
|
|||
|
${ADB} input tap 600 730
|
|||
|
sleep_ 1
|
|||
|
|
|||
|
#第一件商品, 重新发布
|
|||
|
${ADB} input tap 959 1810
|
|||
|
sleep_ 1
|
|||
|
${ADB} input tap 925 129
|
|||
|
sleep_ 1
|
|||
|
${ADB} input keyevent 4
|
|||
|
|
|||
|
sleep_ 2
|
|||
|
while [ $GOODS_NUMBER -gt 0 ]; do
|
|||
|
GOODS_NUMBER=$((GOODS_NUMBER-1))
|
|||
|
|
|||
|
${ADB} input swipe 540 1810 540 1500 200;
|
|||
|
sleep_ 1
|
|||
|
${ADB} input tap 579 1530
|
|||
|
sleep_ 2
|
|||
|
${ADB} input tap 935 1971
|
|||
|
sleep_ 2
|
|||
|
${ADB} input tap 300 1088
|
|||
|
sleep_ 2
|
|||
|
${ADB} input tap 925 129
|
|||
|
sleep_ 2
|
|||
|
${ADB} input keyevent 4
|
|||
|
sleep_ 2
|
|||
|
${ADB} input keyevent 4
|
|||
|
sleep_ 2
|
|||
|
|
|||
|
done
|
|||
|
|
|||
|
${ADB} input keyevent 4
|
|||
|
}
|
|||
|
|
|||
|
function HELP_() {
|
|||
|
#帮助
|
|||
|
echo -e "\033[31mXiaoMi MIX 2S Automated script\033[0m"
|
|||
|
cat << EOF
|
|||
|
Usage:
|
|||
|
${0} [XY] [WPT]
|
|||
|
${0} [-xnh]
|
|||
|
options:
|
|||
|
-x : Print Debug.
|
|||
|
-n : loop Number.
|
|||
|
-h : Print Help.
|
|||
|
|
|||
|
by AIXIAO@AIXIAO.ME
|
|||
|
EOF
|
|||
|
|
|||
|
echo -e "\033[31m仅适用于MI MIX 2s设备!\033[0m"
|
|||
|
exit 0;
|
|||
|
}
|
|||
|
|
|||
|
initialization
|
|||
|
|
|||
|
while getopts :xn:h? l; do
|
|||
|
case ${l} in
|
|||
|
x)
|
|||
|
debug=x;
|
|||
|
shift $((OPTIND-1));
|
|||
|
;;
|
|||
|
n)
|
|||
|
GOODS_NUMBER=${OPTARG};
|
|||
|
shift $((OPTIND-1));
|
|||
|
;;
|
|||
|
h|?)
|
|||
|
HELP_;
|
|||
|
;;
|
|||
|
*)
|
|||
|
HELP_;
|
|||
|
;;
|
|||
|
esac
|
|||
|
done
|
|||
|
test "${debug}" = "x" && set -x;
|
|||
|
|
|||
|
Lock_screen
|
|||
|
case $@ in
|
|||
|
"XY")
|
|||
|
Salted_fish
|
|||
|
;;
|
|||
|
"WPT")
|
|||
|
Weipaitang
|
|||
|
;;
|
|||
|
*)
|
|||
|
HELP_
|
|||
|
;;
|
|||
|
esac
|
|||
|
|