binder RPC add IP address argument when setting up Inet socket
This allows connections on any IP address that the device has.
127.0.0.1 only allows local connections.
Test: test remote connection across two different devices with static ip
of 10.10.10.2
Test: m servicedispatcher
Test: atest binderRpcTest binderLibTest
Change-Id: Idaa61875dadb5196006faddb13e55fdd8a379d52
diff --git a/libs/binder/servicedispatcher.cpp b/libs/binder/servicedispatcher.cpp
index 62df9b7..a6e3f7d 100644
--- a/libs/binder/servicedispatcher.cpp
+++ b/libs/binder/servicedispatcher.cpp
@@ -47,6 +47,7 @@
namespace {
+const char* kLocalInetAddress = "127.0.0.1";
using ServiceRetriever = decltype(&android::IServiceManager::checkService);
int Usage(const char* program) {
@@ -86,7 +87,7 @@
}
rpcServer->iUnderstandThisCodeIsExperimentalAndIWillNotUseItInProduction();
unsigned int port;
- if (!rpcServer->setupInetServer(0, &port)) {
+ if (!rpcServer->setupInetServer(kLocalInetAddress, 0, &port)) {
LOG(ERROR) << "setupInetServer failed";
return EX_SOFTWARE;
}
@@ -199,7 +200,7 @@
rpcServer->iUnderstandThisCodeIsExperimentalAndIWillNotUseItInProduction();
rpcServer->setRootObject(service);
unsigned int port;
- if (!rpcServer->setupInetServer(0, &port)) {
+ if (!rpcServer->setupInetServer(kLocalInetAddress, 0, &port)) {
LOG(ERROR) << "Unable to set up inet server";
return EX_SOFTWARE;
}