Making Voice Calls from Android Phone Connected to Linux

Making voice calls from Android phone connected to Linux

I have found out that it is almost impossible to play a voice during the call due to security restrictions on Android.

How to Initiate Call from Raspberry Pi on Android Device

you can use ssh to get a shell on the android ( https://android.stackexchange.com/questions/118738/how-to-ssh-into-an-unrooted-android-device-using-sshdroid-from-a-linux-computer )

calls are managed on android by the phone service that is an android system service ( https://anatomyofandroid.com/2013/10/03/system-services/, https://developer.android.com/guide/components/services.html )

if you have the shell ( and if you have root ) you can invoke calls like

# service call phone 2 s16 "+1234567890"
service call phone 2 s16 "+1234567890"
Result: Parcel(NULL)

source : https://davanum.wordpress.com/2007/12/12/android-calldial-from-the-adb-shell-command-line/
i

for mirroring the android screen you can use a VNC server on the android and a VNC client on the Rpi

VoIP service to make a bridge between Android phone and Ubuntu server

If I have well understood, the use case is:

  • A wants to call B through an application running in a mobile device
  • B has a phone land or mobile line, but not a VoIP one to receive the call.
  • Bridge between internet and phone lines is to be done at home (A's home) without specific subscription costs, that is to say, without the services of a VoIP provider (I should like here to suggest rethinking the use of a well stablished solution as costs to call phone lines from IP can be really cheap).

Well, there is a lot of solutions for this scenario. I am going to speak about one of them that I consider interesting because it opens the way to a lot of additional communication services.

First, the softphone. To make and receive calls, A will need an application in his or her device. Consider a softphone as Zoiper or Jitsi Meet.

Then, the gateway between VoIp and phone lines. Asterisk can do the work as a SIP server. It is a lightweight linux software with a lot of features. It can switch VoIP lines with land phone lines via FXS - FXO cards (if the phone lines are analogue ones), ISDN cards, VoIP interfaces, bluetooth using mobile devices, etc.

Last, but not least, the connection. Ok, you do not want to expose your gateway to the dangers of all those wicked people of internet, eager to stole your phone line minutes. Connection between mobile and server could be done using a VPN (e.g. OpenVPN), or through a web app (SIP on top of WebRTC).

Once you have the asterisk working at home, you could use it as an answering machine sending email messages with the received audio, as (if your local regulations allow it) a recorder, as an IVR or as a part of a security system, calling sequencially phone numbers in case of emergency.

Make and receive phone calls to from android phone connected to Raspberry pi

One option would be Bluetooth: Put a Bluetooth stick into your RPi, pair it with the Android device, and possibly emulate a hands-free device, e.g. using HFP for Linux.

Otherwise, you could use TCP/IP if your Raspberry Pi and your Android device are connected to the same network (e.g. your home network with your Android phone being connected via WiFi and your RPi connected via Ethernet, or if your RPi acts as a WiFi AP and your Android is connected to it). For this, you would need to write a custom Android app (or check if someone else already did) that reacts to incoming calls and sends information to the RPi, and receives requests to dial a number and makes the call (requires the CALL_PHONE permission and cannot dial emergency numbers like 911).

If you want a wired connection, ADB via USB would likely be the easiest way to do it. You can use it to send intents (to make the phone dial a number) and read debug output from the phone (to give the RPi the incoming call numbers).

android : can we call from Android to another platform and vice versa using VOIP

SIP is a protocol independent of the platform. So yes you can call from Android to iPhone to Windows to Linux to whatever you want provided you have correctly implemented the sip stack.

Yes all of them need to be registered to the same SIP domain or their servers should have configurations to talk to each other.

how to perform voice call from one GSM modem to another

Yes, this is possible assuming you just want to initiate and receive the voice call. You will not be able to process the audio with software.


The simplest way to do this is to use AT commands. Assuming the terminating modem has phone number 1234 then on the originating side run ATD1234; (notice that the semicolon on the end is required in order to make a voice call. Without it the modem will make a circuit switched data call instead).

Then on the terminating side there are a few ways. The simplest is to set the S0 register to something different than zero, e.g. ATS0=2 which will automatically answer an incoming call after two rings (for more details see chapter 6.3.8 Automatic answer in V.250).

Notice however that S0 applies to all types of calls, so it would potentially try to answer data calls as well. If you want to be a little bit more sophisticated you could enable the +CRING unsolicited result code with AT+CRC=1 (see 27.007 for details) and then write a program that monitors UR codes and when receiving +CRING: VOICE manually answer the call with ATA.


Except for the monitoring of UR codes, all the AT command can very easily be sent using the atinout program. Taking the simplest approach would be on the terminating side to run

$ echo ATS0=1 | atinout - /dev/your_modem_device -
ATS0=1

OK
$

and on the originating side run

$ echo 'AT1234;' | atinout - /dev/your_modem_device -
ATD123;

OK
$


Related Topics



Leave a reply



Submit