dial流程
Activity.java (frameworks\base\core\java\android\app):
public boolean onKeyDown(int keyCode, KeyEvent event)
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + str));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
RecentCallsListActivity.java (packages\apps\contacts\src\com\android\contacts):
setDefaultKeyMode(DEFAULT_KEYS_DIALER);
PhoneUtils.java (packages\apps\phone\src\com\android\phone)
static int placeCall(Phone phone, String number, Uri contactRef)
Connection cn = phone.dial(number);
GSMPhone()
dial (String dialString)
mCT.dial(mmi.dialingNumber, mmi.getCLIRMode());
CallTracker mCT;
CallTracker类 dial (String dialString)
dial (String dialString, int clirMode)
cm.dial(pendingMO.address, clirMode, obtainCompleteMessage());
//因为 RIL.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm):
//public final class RIL extends BaseCommands implements CommandsInterface所以 cm.dial
//实际上调用的是 RIL.java 中的dial
dial (String address, int clirMode, Message result)
RILRequest rr = RILRequest.obtain(RIL_REQUEST_DIAL, result);
send()
msg.sendToTarget();
target.sendMessage(this);
//Handler.java (frameworks\base\core\java\android\os)
boolean sendMessage(Message msg)
//Handler.java (frameworks\base\core\java\android\os)
return sendMessageDelayed(msg, 0);
return sendMessageAtTime(msg, SystemClock.uptimeMillis() + delayMillis);
sent = queue.enqueueMessage(msg, uptimeMillis);
//把消息放入到消息队列
public void handleMessage(Message msg)
s.getOutputStream().write(dataLength);
s.getOutputStream().write(data);
因为在 RIL.java 文件中有 static final String SOCKET_NAME_RIL = "rild";
run()函数中有:
s = new LocalSocket();
l = new LocalSocketAddress(SOCKET_NAME_RIL,
LocalSocketAddress.Namespace.RESERVED);
s.connect(l);
...
mSocket = s;
所以我们可以确定s.getOutputStream().write(data) 是往 rild 的socket写数据。
下面为 rild 收到数据后的处理流程。
static void processCommandsCallback(int fd, short flags, void *param)
processCommandBuffer(p_record, recordlen);
status = p.readInt32(&request);
pRI->pCI = &(s_commands[request]);
pRI->pCI->dispatchFunction(p, pRI);
因为 RIL.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm):
中dail函数中有:
RILRequest rr = RILRequest.obtain(RIL_REQUEST_DIAL, result);
而 Ril_commands.h (hardware\ril\libril):中有:
{RIL_REQUEST_DIAL, dispatchDial, responseVoid},
所以此时执行的是 Ril.cpp (hardware\ril\libril)文件中的:
static void dispatchDial (Parcel& p, RequestInfo *pRI)
s_callbacks.onRequest(pRI->pCI->requestNumber, NULL, 0, pRI);
case RIL_REQUEST_DIAL:
requestDial(data, datalen, t);
asprintf(&cmd, "ATD%s%s;", p_dial->address, clir);
ret = at_send_command(cmd, NULL);
err = at_send_command_full (command, NO_RESULT, NULL,NULL, 0, pp_outResponse);
at_send_command_full_nolock()
err = writeline (command);
补充:
BaseCommands.java (frameworks\base\telephony\java\com\android\internal\telephony\gsm):
public abstract class BaseCommands implements CommandsInterface
[android] trace radio interface layer (RIL) by two emulators
http://i-miss-erin.blogspot.com/2009/04/android-trace-radio-interface-layer-ril.html
How to dial out a call in Android? I traced the radio log and make sure the whole procedure and the source code.
==============================================================================
阅读(1432) | 评论(0) | 转发(0) |