Using Android phone as GSM Gateway for VoIP

Using Android phones as a SIP client is not a big deal nowadays. It requires only to be connected either through 3G or WiFi as an extension to an Asterisk server. Your Asterisk server will act as a VoIP gateway for any outgoing calls. For inbound calls, you may require a DID, a VoIP phone line which usually costs very little.

Android phones these days have become very powerful with Quadcore and Octacore processors. So why not utilize their power? Why not remove the middle man, Asterisk, as VoIP gateway and put it on the smartphone? It would be an interesting thing if Asterisk or FreeSWITCH is installed on an Android box. It would make the Android phone a portable Call center or PBX. Other phones can join in as sip clients utilizing the Asterisk installed Android phone. This would allow the outbound calls to go through the android device without needing any middle application gateway to be used. The android device itself will act as a VoIP gateway.

However, porting Asterisk to an Android device will only allow it to serve as VoIP and/or SMS gateway. What if we want to use an android device as a GSM gateway? For example, using your cellular network to send automated calls and messages to your phone contacts. The current Android phone is unable to do that. They are unable to provide call and media control that is required to make them work as a gateway.

Let's dig out what can we do to make this thing possible and what are the hurdles:

Hurdle 1

First thing, we if look at a high-level of abstraction, in the Android software, it doesn't provide any high-level APIs to call and media control. One example of media control is playing recording files on a voice call. This is mentioned in the Android official documentation. As quoted in the documentation that "You can playback the audio data only to the standard output device. Currently, that is the mobile device speaker or a Bluetooth headset. You cannot play sound files in the conversation audio during a call".

Even if we are able to remove this hurdle, we may still not be able to use Android as GSM Gateway. Because there is a second hurdle.

Hurdle 2

The second hurdle is in the design of the Android RIL (Radio Interface Layer). RIL is an abstraction layer between Android telephony services (android. telephony package) and radio hardware. It is clearly visible from the diagram below that RIL passes on complete control of the call to Radio Daemon (rild) of the Linux library which then further passes the control to the vendor RIL. So we are unable to control our call at the android application. We need access to Radio Daemon and vendor RIL source code to manipulate our call.

Even if we are able to remove this hurdle, we may still not be able to use Android as GSM Gateway. Because there is another hurdle.

Hurdle 3

The third hurdle to make Android work as a GSM Gateway is that vendor RIL is not open source. Every vendor has its own library of RIL that communicates with Radio Daemon (rild). Radio Daemon is continuously running on a specific port and dispatches any calls to the vendor RIL. Vendor RIL library (system/libs/ then captures any incoming call and puts it on the radio hardware.

It's not possible to use Android as a GSM Gateway in its current form. Even after flashing custom ROM because they also depend on proprietary RIL firmware. Hurdles 1 and 2 can be removed because the source code is available for the open-source community to make it possible. However, hurdle 3 is dependent on the hardware vendors. Hardware vendors do not usually make their device drivers' code available.

If someone is ready to make vendor RIL source code available to the community, then it is possible. There are some projects out there, which are aiming to totally replace all proprietary firmware (currently with a very limited device supported) such as

ICT Innovations is an open-source, telephony consultant.
Contact Us for deployment and development of open source telephony projects