summaryrefslogtreecommitdiff
path: root/libs/binder/ProcessState.cpp
diff options
context:
space:
mode:
author Jayant Chowdhary <jchowdhary@google.com> 2019-03-08 10:08:20 -0800
committer Jayant Chowdhary <jchowdhary@google.com> 2019-03-12 13:11:47 -0700
commit46f95536bec334f8472ea92a7697c37602337398 (patch)
tree00594a48238495be58d3e4ef10d360183fb6f22b /libs/binder/ProcessState.cpp
parenta5d85affa9d1c869a8d2178b9daa284240e1c904 (diff)
libbinder: Choose the binder driver at runtime based on system/vendor process.
This is needed since llndk libraries may cause the system variant of libbinder (and therefore compile time checks are not enough) to be loaded in a vendor process. In that case, it should not be initing the driver with /dev/binder. It should use /dev/vndbinder instead. Bug: 124128212 Test: Device boots Test: play YouTube videos, use camera to take pictures / record video (sanity) on devices supporting legacy vndk(sailfish) and also devices supporting current vndk. Change-Id: Ia5581efa04c8d4adc6af39668b0aa98e84324a27 Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
Diffstat (limited to 'libs/binder/ProcessState.cpp')
-rw-r--r--libs/binder/ProcessState.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp
index 3798b61ab9..86afffc079 100644
--- a/libs/binder/ProcessState.cpp
+++ b/libs/binder/ProcessState.cpp
@@ -26,6 +26,7 @@
#include <utils/String8.h>
#include <utils/String8.h>
#include <utils/threads.h>
+#include <vndksupport/linker.h>
#include <private/binder/binder_module.h>
#include <private/binder/Static.h>
@@ -43,16 +44,22 @@
#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* kDefaultVendorDriver = "/dev/vndbinder";
const char* kDefaultDriver = "/dev/binder";
-#endif
// -------------------------------------------------------------------------
namespace android {
+static const char *getDefaultBinderDriver() {
+ // Some libs might have their system variants loaded in a vendor process, so
+ // we cannot depend on a compile time check.
+ if (android_is_in_vendor_process()) {
+ return kDefaultVendorDriver;
+ }
+ return kDefaultDriver;
+}
+
class PoolThread : public Thread
{
public:
@@ -77,7 +84,7 @@ sp<ProcessState> ProcessState::self()
if (gProcess != nullptr) {
return gProcess;
}
- gProcess = new ProcessState(kDefaultDriver);
+ gProcess = new ProcessState(getDefaultBinderDriver());
return gProcess;
}