Permalink
Browse files

Merge "Enable QEMUD pipe connection"

  • Loading branch information...
2 parents 8dbc643 + 385a739 commit 988d3d7181473e36df8679368b06d0fb766c52e4 Vladimir Chtchetkine committed with Android Code Review Aug 8, 2011
Showing with 33 additions and 22 deletions.
  1. +25 −17 reference-ril/reference-ril.c
  2. +8 −5 rild/rild.c
@@ -33,6 +33,7 @@
#include <sys/socket.h>
#include <cutils/sockets.h>
#include <termios.h>
+#include "hardware/qemu_pipe.h"
#define LOG_TAG "RIL"
#include <utils/Log.h>
@@ -63,7 +64,7 @@ typedef enum {
SIM_PIN = 3,
SIM_PUK = 4,
SIM_NETWORK_PERSONALIZATION = 5
-} SIM_Status;
+} SIM_Status;
static void onRequest (int request, void *data, size_t datalen, RIL_Token t);
static RIL_RadioState currentState();
@@ -1573,7 +1574,7 @@ setRadioState(RIL_RadioState newState)
}
/** Returns SIM_NOT_READY on error */
-static SIM_Status
+static SIM_Status
getSIMStatus()
{
ATResponse *p_response = NULL;
@@ -2011,21 +2012,28 @@ mainLoop(void *param)
fd = socket_loopback_client(s_port, SOCK_STREAM);
} else if (s_device_socket) {
if (!strcmp(s_device_path, "/dev/socket/qemud")) {
- /* Qemu-specific control socket */
- fd = socket_local_client( "qemud",
- ANDROID_SOCKET_NAMESPACE_RESERVED,
- SOCK_STREAM );
- if (fd >= 0 ) {
- char answer[2];
-
- if ( write(fd, "gsm", 3) != 3 ||
- read(fd, answer, 2) != 2 ||
- memcmp(answer, "OK", 2) != 0)
- {
- close(fd);
- fd = -1;
- }
- }
+ /* Before trying to connect to /dev/socket/qemud (which is
+ * now another "legacy" way of communicating with the
+ * emulator), we will try to connecto to gsm service via
+ * qemu pipe. */
+ fd = qemu_pipe_open("qemud:gsm");
+ if (fd < 0) {
+ /* Qemu-specific control socket */
+ fd = socket_local_client( "qemud",
+ ANDROID_SOCKET_NAMESPACE_RESERVED,
+ SOCK_STREAM );
+ if (fd >= 0 ) {
+ char answer[2];
+
+ if ( write(fd, "gsm", 3) != 3 ||
+ read(fd, answer, 2) != 2 ||
+ memcmp(answer, "OK", 2) != 0)
+ {
+ close(fd);
+ fd = -1;
+ }
+ }
+ }
}
else
fd = socket_local_client( s_device_path,
View
@@ -33,6 +33,7 @@
#include <linux/prctl.h>
#include <private/android_filesystem_config.h>
+#include "hardware/qemu_pipe.h"
#define LIB_PATH_PROPERTY "rild.libpath"
#define LIB_ARGS_PROPERTY "rild.libargs"
@@ -175,11 +176,13 @@ int main(int argc, char **argv)
sleep(1);
- fd = socket_local_client(
- QEMUD_SOCKET_NAME,
- ANDROID_SOCKET_NAMESPACE_RESERVED,
- SOCK_STREAM );
-
+ fd = qemu_pipe_open("qemud:gsm");
+ if (fd < 0) {
+ fd = socket_local_client(
+ QEMUD_SOCKET_NAME,
+ ANDROID_SOCKET_NAMESPACE_RESERVED,
+ SOCK_STREAM );
+ }
if (fd >= 0) {
close(fd);
snprintf( arg_device, sizeof(arg_device), "%s/%s",

0 comments on commit 988d3d7

Please sign in to comment.