summaryrefslogtreecommitdiff
path: root/libs/binder/ProcessState.cpp
diff options
context:
space:
mode:
author Martijn Coenen <maco@google.com> 2017-03-21 15:56:40 -0700
committer Martijn Coenen <maco@google.com> 2017-03-21 16:04:09 -0700
commit55d871cc09b7493e2b7e5705ea9774fd5f4c626c (patch)
treeaf239691f979e94c169a8101c1f578695c1ef230 /libs/binder/ProcessState.cpp
parent4856e00f0e001185b107480fe27ef3360923eb87 (diff)
Allow ProcessState to use another binder dev node.
Since we have different binder domains at different /dev nodes now, processes using libbinder must be able to select which /dev node they want to use. This is achieved with a new ProcessState::initWithDriver() API, which takes the /dev node to talk to as an argument. Bug: 36052864 Test: system boots without issues Change-Id: I5b3b13decf254ca0957665c91abac4b287e448c4
Diffstat (limited to 'libs/binder/ProcessState.cpp')
-rw-r--r--libs/binder/ProcessState.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index 98107c578d..5c4cfe2156 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -71,7 +71,17 @@ sp<ProcessState> ProcessState::self()
if (gProcess != NULL) {
return gProcess;
}
- gProcess = new ProcessState;
+ gProcess = new ProcessState("/dev/binder");
+ return gProcess;
+}
+
+sp<ProcessState> ProcessState::initWithDriver(const char* driver)
+{
+ Mutex::Autolock _l(gProcessMutex);
+ if (gProcess != NULL) {
+ LOG_ALWAYS_FATAL("ProcessState was already initialized.");
+ }
+ gProcess = new ProcessState(driver);
return gProcess;
}
@@ -307,9 +317,9 @@ void ProcessState::giveThreadPoolName() {
androidSetThreadName( makeBinderThreadName().string() );
}
-static int open_driver()
+static int open_driver(const char *driver)
{
- int fd = open("/dev/binder", O_RDWR | O_CLOEXEC);
+ int fd = open(driver, O_RDWR | O_CLOEXEC);
if (fd >= 0) {
int vers = 0;
status_t result = ioctl(fd, BINDER_VERSION, &vers);
@@ -330,13 +340,13 @@ static int open_driver()
ALOGE("Binder ioctl to set max threads failed: %s", strerror(errno));
}
} else {
- ALOGW("Opening '/dev/binder' failed: %s\n", strerror(errno));
+ ALOGW("Opening '%s' failed: %s\n", driver, strerror(errno));
}
return fd;
}
-ProcessState::ProcessState()
- : mDriverFD(open_driver())
+ProcessState::ProcessState(const char *driver)
+ : mDriverFD(open_driver(driver))
, mVMStart(MAP_FAILED)
, mThreadCountLock(PTHREAD_MUTEX_INITIALIZER)
, mThreadCountDecrement(PTHREAD_COND_INITIALIZER)