我将Andorid手机连接到Linux服务器。我需要一个bash脚本来使用电话拨号并在接听电话时读出一个字符串。
我在Linux服务器上安装了ADB,以下代码可以正常拨号:
manifest.json
但是我不知道如何让它读取字符串然后断开呼叫。 ADB / Android是否有文字转语可以帮助我?
答案 0 :(得分:0)
adb shell input keyevent 6
这个adb命令会挂断电话。尝试命令。
答案 1 :(得分:0)
我发现由于Android的安全限制,在通话过程中几乎不可能播放语音。
答案 2 :(得分:0)
#!/bin/bash
LANDSCODE="+<landscode here>"
trap ctrl_c INT
function ctrl_c() {
echo "Aborted call.."
adb shell input keyevent KEYCODE_ENDCALL
exit
}
read -p "Enter Number: $LANDSCODE" number
if [[ -z $number ]]; then
echo "You must enter a phone number, aborted.."
exit
elif [[ $(echo $number | wc -c) -lt 7 ]]; then
echo "This is not a real number, enter a real number.."
exit
else
read -p "Do you want speaker on (y/n): " speaker
case $speaker in
"y")
adb shell am start -a android.intent.action.CALL -d tel:$LANDSCODE$number &> /dev/null;
sleep 2.0;
adb shell service call audio 20 i32 1 # does this really works on android oreo 8.0?
echo "Dialing +$LANDSCODE$number"
read -p "Press any key to end call"
adb shell input keyevent KEYCODE_ENDCALL
echo -e "Call ended"
adb shell input keyevent 6
exit 1 ;;
"n")
adb shell am start -a android.intent.action.CALL -d tel:$LANDSCODE$number &> /dev/null
echo -e "Dialing $LANDSCODE$number"
read -p "Press any key to end call"
adb shell input keyevent KEYCODE_ENDCALL
echo "Call ended"
adb shell input keyevent 6
exit 1 ;;
esac
fi