关于 android RIL 调试

首先,要了解RIL是如何启动的,拿G1做个例子

init.rc:

service ril-daemon /system/bin/rild
    socket rild stream 660 root radio
    socket rild-debug stream 660 radio system
    user root
    group radio cache inet misc audio

/system/build.prop:

ro.ril.hsxpa=1
ro.ril.gprsclass=10
rild.libpath=/system/lib/libhtc_ril.so

阅读 /hardware/ril/rild/rild.c。

如果/system/bin/rild 启动有带参数,则解析参数,否则找系统变量 rild.libpath

也可以不按照G1的,一口气写完:
init.rc:
/system/bin/rild -l /system/lib/libreference-ril.so — -d /dev/ttyS0

/hardware/ril/rild/rild.c 里有一段注释: “special override when in the emulator”, 紧接着是 #if 1 … #endif 代码块。
它读取 /proc/cmdline,

# cat /proc/cmdline ,模拟器上的值
qemu=1 console=ttyS0 android.checkjni=1 android.qemud=ttyS1 android.ndns=2

找到与字符串“android.qemud“匹配的,则表示运行在模拟器上,会覆盖ril系统设置,连接为模拟器准备的 /dev/socket/qemud

所以,在开发生产版本,要把 #if 1 修改为 #if 0, 或者在编译kernel里把生成的 /proc/cmdline 配置去掉android.qemud。

要调试 RIL,最好的方法就是打开 radio的log:

$ adb logcat -b radio

最好加上 log语法亮度工具 coloredlogcat.py,一些常见的LOG TAG要明白,他们是:

RIL: /hardware/ril/reference-ril/refereince-ril.c
AT: /hardware/ril/reference-ril/atchannel.c
RILD: /hardware/ril/rild/rild.c
RILC: /hardware/ril/libril/ril.cpp
RILB frameworks/base/telephony/java/com/android/internal/telephony/BaseCommands.java
RILJ: /frameworks/base/telephony/java/com/android/internal/telephony/gsm/RIL.java
GSM: /frameworks/base/telephony/java/com/android/internal/telephony/gsm/GSMPhone.java

如何在模拟器上外接 gsm modem?

请参考 http://i-miss-erin.blogspot.com/2009/09/android-emulator-external-gsm-modem.html

If you enjoyed this post, make sure you subscribe to my RSS feed!

One thought on “关于 android RIL 调试

Leave a Reply

Your email address will not be published. Required fields are marked *