libbinder: auto-choose between binder/vndbinder.
Right now, a huge amount of client code has to manually
specify initWithDriver("/dev/vndbinder"). This is kind
of silly because every vendor process is not allowed to
talk to /dev/binder, and system processes are not allowed
to talk to /dev/vndbinder. On legacy devices,
__ANDROID_VNDK__ will not be set, so they will continue
to talk to /dev/binder.
Bug: 62956284
Test: boot Pixel 2, check for errors
Change-Id: Ic0d9da6d9b451aa8b1e62f24487d19478bff3d97
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index 6e7c427..c8cdb77 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -43,6 +43,12 @@
#define BINDER_VM_SIZE ((1 * 1024 * 1024) - sysconf(_SC_PAGE_SIZE) * 2)
#define DEFAULT_MAX_BINDER_THREADS 15
+#ifdef __ANDROID_VNDK__
+const char* kDefaultDriver = "/dev/vndbinder";
+#else
+const char* kDefaultDriver = "/dev/binder";
+#endif
+
// -------------------------------------------------------------------------
namespace android {
@@ -71,7 +77,7 @@
if (gProcess != nullptr) {
return gProcess;
}
- gProcess = new ProcessState("/dev/binder");
+ gProcess = new ProcessState(kDefaultDriver);
return gProcess;
}