Home » Android » How to capture Modem Radio Log in Android

How to capture Modem Radio Log in Android

Posted by: admin May 14, 2020 Leave a comment

Questions:

I need to capture some information from Modem Radio Log in android but I don’t know how to capture it. I searched a lot but nothing found. As I need some information about baseband in android, I found out that must to capture modem log.

Thanks in advance.

Edit

I found Read logcat programmatically within application for capturing logcat logs in application

But because it is adb log adb logcat -b radio I don’t know how to capture ADB log in application. As I see in one comment I’m in doubt if it is possible or not.

Thanks

How to&Answers:

Use below command on terminal or console after adb device connection.

adb logcat -b radio

Answer:

Try something like this:

try {
    Runtime rt = Runtime.getRuntime();
    //here you can add your params
    String[] commands = {"logcat"};
    Process proc = rt.exec(commands);

    BufferedReader stdInput = new BufferedReader(new
            InputStreamReader(proc.getInputStream()));

    BufferedReader stdError = new BufferedReader(new
            InputStreamReader(proc.getErrorStream()));

    String s;
    while ((s = stdInput.readLine()) != null) {
        //here is your logcat
        Log.i("logcat", s);
    }

    while ((s = stdError.readLine()) != null) {
        Log.e("logcat", s);
    }
 } catch (IOException e) {
    e.printStackTrace();
}

Keep in mind that you might need root to read logcat.

UPD: Working example – https://github.com/sssemil/SampleLogcatApp