80,471
社区成员




mSock = new DatagramSocket();
network.bindSocket(mSock);
ParcelFileDescriptor ps = ParcelFileDescriptor.fromDatagramSocket(mSock);
m_cellsock = ps.getFd();//再通过localsocket把m_cellsock 传递给so进程
public static void bindSocketToNetwork(int socketfd) {
L.d("start bindSocketToNetwork");
if (network != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
FileDescriptor fileDescriptor = new FileDescriptor();
try {
Field field = FileDescriptor.class.getDeclaredField("descriptor");
field.setAccessible(true);
field.setInt(fileDescriptor, socketfd);
// fileDescriptor.sync();
network.bindSocket(fileDescriptor);
// bindSocket(socketfd, netId);
L.d("bindSocketToNetwork success: network" + network + "+socketfd" + socketfd);
} catch (Exception e) {
e.printStackTrace();
}
}
}