The Java API to Android's Telephony Stack
GSM AT Commands
AT commands are the most common interface between cellular application and baseband processors, used by the majority of the cellular software stacks, including Android. They are defined in the 3GPP standard 27.007. They can be divided roughly into the following groups:
Call control commands, such as ATD to dial a number.
Network service commands, such as AT+CREG for network registration.
Mobile control, such as AT+CPBR to read a phone book.
SMS commands, such as AT+CMGS to send an SMS.
GPRS commands, such as AT+CGDCONT to define PDP context.
Many other commands exist, including some nonstandard vendor-specific commands. For a more detailed description, refer to the latest standards document.
Going back to the internal telephony API of the com.android.internal.telephony package that platform applications such as Phone use, you will find that the most important methods are in the Phone and SimCard interfaces as well as the Call and Connection abstract classes. The source code below shows some of the most important methods.
The Phone interface has methods that are used to place, accept or reject a call:
public interface Phone {
Connection dial(String dialString) throws CallStateException;
void acceptCall() throws CallStateException;
void rejectCall() throws CallStateException;
void setMute(boolean muted);
void startDtmf(char c);
void sendDtmf(char c);
void stopDtmf();
...
}
A Call object is created when you answer a call, and the Call class methods implement call-related functionality allowing you to, among other things, hang up:
public abstract class Call {
public abstract void hangup() throws CallStateException;
public boolean isRinging()
public abstract boolean isIncoming();
...
}
The Connection class is related to the Call class shown above. A Call can have a number of associated Connection classes accessible via the getConnections() method, while the Connection class has a reference to the corresponding Call, returned by the getCall() method). To be honest, I didn't manage to understand from the Android source code when and why there would be multiple connections in one call. Some telephony routines work with the Call class—for instance, those used to answer the call. Others work with the Connection class—for instance, it is returned by the dial() method of the Phone class. As you can see from the list of important Connection methods, their functionality is similar:
public abstract class Connection {
public abstract void hangup() throws CallStateException;
public boolean isRinging()
public abstract boolean isIncoming();
...
}
Finally, the SimCard interface provides an access to a SIM card via methods that allow users to supply a PIN (Personal Identification Number) and a PUK (Personal Unblocking Key), which is used to unblock the PIN:
public interface SimCard {
void supplyPin(String pin, Message onComplete);
void supplyPuk(String puk, String newPin, Message onComplete);
void supplyPin2(String pin2, Message onComplete);
void supplyPuk2(String puk2, String newPin2, Message onComplete);
State getState();
...
}
The SIM state, returned by the getState() method, can be either ready, PIN/PUK required or network locked.
If you are interested in the Phone interface implementation, you should check the PhoneBase class that implements some of its methods. The rest, which are RAT-dependent, can be found in GSMPhone, which extends the PhoneBase class and is part of the com.android.internal.telephony.gsm package. The SimCard interface and the GsmSimCard class, as well as Call and GSMCall, follow the same approach. GSM currently is the only RAT supported by the Android platform, but Qualcomm has announced that it is working on CDMA2000 support. More technologies, such as LTE (Long Term Evolution), may be supported in the future.
Another important class is TelephonyIntents, which defines intents—that is, events (in Android parlance) that the telephony framework can produce:
ACTION_SERVICE_STATE_CHANGED: the phone service state has changed.
ACTION_SIGNAL_STRENGTH_CHANGED: the phone's signal strength has changed.
ACTION_ANY_DATA_CONNECTION_STATE_CHANGED: the data connection state has changed for any one of the phone's mobile data connections.
ACTION_DATA_CONNECTION_FAILED: an attempt to establish a data connection has failed.
ACTION_SIM_STATE_CHANGED: the SIM card state has changed.
The Phone application (in the PhoneUtils class of the com.android.phone package) uses these methods to place or answer a call in the following way:
public class PhoneUtils {
...
static boolean answerCall(Phone phone) {
...
Call call = phone.getRingingCall();
phone.acceptCall();
...
}
...
}
static int placeCall(Phone phone, String number, Uri contactRef) {
...
Connection cn = phone.dial(number);
...
}
The above code sample demonstrates only the most basic telephony functionality; however, along with the API outlined above, it should give you a good starting point for writing Android telephony applications. If you decide to do so, you probably won't be able to avoid having to dig in to the Android sources for more details. I hope having a bit more of an in-depth understanding of how cellular telephony works under the hood of the high-level Java API will help you in this endeavour.
Note that this article is based on the Android 1.1 SDK r1 and the Android main git branch snapshot taken on March 24, 2009. Because Android is being developed constantly, some of the APIs mentioned in this article may have changed since that date.
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Designing Electronics with Linux | May 22, 2013 |
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
- New Products
- Linux Systems Administrator
- Senior Perl Developer
- Technical Support Rep
- UX Designer
- Web & UI Developer (JavaScript & j Query)
- Designing Electronics with Linux
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- Nice article, thanks for the
9 hours 13 min ago - I once had a better way I
14 hours 59 min ago - Not only you I too assumed
15 hours 17 min ago - another very interesting
17 hours 10 min ago - Reply to comment | Linux Journal
19 hours 3 min ago - Reply to comment | Linux Journal
1 day 1 hour ago - Reply to comment | Linux Journal
1 day 2 hours ago - Favorite (and easily brute-forced) pw's
1 day 4 hours ago - Have you tried Boxen? It's a
1 day 9 hours ago - seo services in india
1 day 14 hours ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?




Comments
I want to call from PC using
I want to call from PC using my GSM mobile phone blutooth between them,i want to use AT Commands for call control through PC to Mobile via blutooth, pls give some smple code or guidance