How to Connect to rild Socket

核能气质少年 提交于 2019-12-18 11:54:13

问题


I'm trying to write an app to talk to the rild. And Yes, I know this is not politically correct, but it's an embedded industrial telemetry app so I'm not concerned about user experience, portability and all that stuff.

The problem is that when I try to connect, I get a java.io "Permission denied" exception. Can anybody help me?

The phone (Nexus One) is rooted with Cyanogenmod 7 and the app is running as superuser using the "SuperUser" app from Market.

My Code (abbreviated):

try {
  mSocket = new LocalSocket();
  mSockAddr = new LocalSocketAddress( "rild", LocalSocketAddress.Namespace.RESERVED );
  mSocket.connect( mSockAddr );
}
catch( Exception e ) {
  dbg.p( "connect failed: "+e );
}

I see the rild (and rild-debug) sockets in /dev/socket.

srw-rw----    1 root     radio            0 Feb 13 19:14 rild
srw-rw----    1 radio    system           0 Feb 13 19:14 rild-debug

Could it be that the Dialer app is already connected and hogging the socket?

BTW I initially tried to use the frameworks but got a humongus boatload of errors mostly about java and and third party classes unknown, so I gave up after days of hair-pulling. I've also STFW and this site - lot's of dancing around the issue but no concrete advice.

Any help greatly appreciated. -John


回答1:


On the java end of the rild socket is an instance of com.android.internal.telephony.RIL.java, which is owned by com.android.phone.PhoneApp.java. PhoneApp is a persistent app which, not surprisingly, provides the phone functionality. Disabling PhoneApp should kill any java-side use of the rild socket.

You also might want to try connecting to "rild-debug", which is unused (but may be ignored by the ril-daemon).

BTW - You can see the comms between the RIL layers by doing logcat -b radio.

Please post back if you come up with a workaround.




回答2:


In recent versions of Android (and, likely, in the earlier versions), rild-debug is not meant to accept a full range of commands; only predefined commands are accepted.

Check out ril.cpp here;

static void debugCallback (int fd, short flags, void *param)
...

    case 0:
        LOGI ("Connection on debug port: issuing reset.");
        issueLocalRequest(RIL_REQUEST_RESET_RADIO, NULL, 0);
        break;
    case 1:
        LOGI ("Connection on debug port: issuing radio power off.");
        data = 0;
        issueLocalRequest(RIL_REQUEST_RADIO_POWER, &data, sizeof(int));
        // Close the socket
        close(s_fdCommand);
        s_fdCommand = -1;
        break;

UPD: also, RIL requests are incrementally numbered and it's very easy to effectively break the ril/phoneapp pairing by issuing an out-of-the-series event.



来源:https://stackoverflow.com/questions/9298750/how-to-connect-to-rild-socket

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!