for i in $(seq 1 10); do
	echo i=$i
	# 回到主界面
	adb shell input keyevent 3
	adb shell input keyevent 3

	# 唤醒菜单
	adb shell input keyevent 312

	# dump当前ui
	adb shell uiautomator dump
	adb pull /sdcard/window_dump.xml
	sleep 2

	# 判断是否有后台
	cnt=$(cat window_dump.xml | grep -c "近期没有")
	if [ $cnt -eq 1 ]; then
		adb shell input keyevent 3
		rm window_dump.xml
		break
	fi

	echo debug $cnt

	cnt=$(cat window_dump.xml | grep -c "全部")
	if [ $cnt -ne 1 ]; then
		continue
	fi

	#找到清后台按钮的位置
	tmp=$(sed 's/\<node/\n/g' window_dump.xml | grep 全部 | awk -F 'bounds=' '{print $2}' | awk '{print $1}' | awk -F '"' '{print $2}' | sed 's/,/ /g' | sed 's/\[/ /g' | sed 's/\]/ /g' | awk '{print $1,$2}')
	echo $tmp
	adb shell input tap $tmp
	adb shell input keyevent 3
	rm window_dump.xml
done

