从 Android phone 拨打语音电话连接到 Linux
Making voice calls from Android phone connected to Linux
我有一个 Andorid phone 连接到 Linux 服务器。我需要一个 bash 脚本来使用 phone 拨号并在接听电话时读出一个字符串。
我在 Linux 服务器上安装了 ADB,下面的代码可以正常拨号:
adb shell am start -a android.intent.action.CALL -d tel:$phone_number
Starting: Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxx }
但是我不确定如何让它读取一个字符串然后断开通话。是否有 ADB/Android 的文本转语音可以帮助我?
adb shell input keyevent 6
这个adb命令会挂断电话。尝试命令。
我发现由于 Android.
的安全限制,通话期间几乎无法播放语音
我的一个 adb 工具中有这样的功能,也许这会给你一个提示:
#!/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
我有一个 Andorid phone 连接到 Linux 服务器。我需要一个 bash 脚本来使用 phone 拨号并在接听电话时读出一个字符串。
我在 Linux 服务器上安装了 ADB,下面的代码可以正常拨号:
adb shell am start -a android.intent.action.CALL -d tel:$phone_number
Starting: Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxx }
但是我不确定如何让它读取一个字符串然后断开通话。是否有 ADB/Android 的文本转语音可以帮助我?
adb shell input keyevent 6
这个adb命令会挂断电话。尝试命令。
我发现由于 Android.
的安全限制,通话期间几乎无法播放语音我的一个 adb 工具中有这样的功能,也许这会给你一个提示:
#!/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