i'm trying to create a "custom" rild process but i having problem with the creation of rild socket.
I'm able to create a unix socket in /dev/socket/rild but the application com.android.phone return the follow error:
Couldn't find 'rild' socket; retrying after timeout
The socket has permission of rw for root and rw for radio group (with ll I obtain the same result on the custom rild socket and real socket)
I use the following code:
unsigned int s, s2;
struct sockaddr_un local, remote1;
s = socket(PF_UNIX, SOCK_STREAM, 0);
int n = 1;
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &n, sizeof(n));
local.sun_family = AF_LOCAL;
snprintf(local.sun_path, sizeof(local.sun_path), "/dev/socket/rild");
unlink(local.sun_path);
size_t len = strlen(local.sun_path) + sizeof(local.sun_family);
int ret = bind(s, (struct sockaddr *) &local, sizeof (local));
int savederrno = errno;
if (ret) {
errno = savederrno;
__android_log_print(ANDROID_LOG_VERBOSE, TAGCB, "Error in binding: %d", errno);
return -1;
}
if (lchown(local.sun_path, 0, 1001)) {
__android_log_print(ANDROID_LOG_VERBOSE, TAGCB, "Failed to lchown socket %s",local.sun_path);
return -1;
}
if(chmod(local.sun_path,0660)){
__android_log_print(ANDROID_LOG_VERBOSE, TAGCB, "Failed to chmod socket %s",local.sun_path);
return -1;
}
__android_log_print(ANDROID_LOG_VERBOSE, TAGCB, "Created SOCKET %s",local.sun_path);
fcntl(s, F_SETFD, FD_CLOEXEC);
fcntl(s, F_SETFL, O_NONBLOCK);
switchUser();
listen(s, 8);
Thanks for the advices :D