2012年3月14日 星期三

DDMS with radio logcat

DDMS is a very powerful tool in Android. You can use it to monitor the process and log. But if you try to look the log in DDMS, you find that there is no RIL log. It’s not convenient for developing the RIL related program. As we know the DDMS is open source code in google’s Android project. So we can get the source code from google, modify this function to fit our requirement.

1.      DDMS script
First we have to understand the DDMS. After you finish building the android source code, you will find the ddms command under the out/host/linux-x86/bin directory.
After open this file, you will find it will run the “$jarpath” variable in this script.
   And


So this script will run ddms.jar file. We have to looking for the ddms.jar.

2.      ddms.jar
How to find out the ddms.jar in the huge android source code repository? As we know android make file will use the “Android.mk” file to build the source code.
You can find the Android.mk file of ddms.jar under the sdk/ddms/app directory.

Open it and verify the “LOCAL_MODULE” variable and “include $(BUILD_HOST_JAVA_LIBRARY)”. Then you can make sure there is the ddms.jar source code directory.

3.      logcat
We have already find out the DDMS source code. But before we start to modify it we have to understand the logcat command parameter. You can issue the logcat command to look at that. 

By the document you can use the “logcat –b radio” to log from the radio buffer. But you will miss the main(default) log message when you issue that command. Fortunately you can issue the “logcat –b main –b radio” command get the main and radio log at the same time.

4.      modify the source code
Everything you need has already in your hand. The last thing you need to do is find out where the “logcat” is in ddms source code. In GB version it’s in the “LogPanel.java”. In ICS version it’s in the “LogCatReceiver.java”.
The “LogCatReceiver.java” file under the sdk/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat directory.
Open it. You will find out the LOGCAT_COMMAND variable.


The only thing you need to do is change it to “logcat –b main –b radio –v long”.
Is it easy, right?

5.      Rebuild DDMS and enjoy it. ^__^