diff options
author | 2023-02-14 01:33:39 +0000 | |
---|---|---|
committer | 2023-02-14 19:20:27 +0000 | |
commit | 9a4278ece240f0c4a511f77a62d86aa15b755a05 (patch) | |
tree | b05be4e2915e9800952177aa5402a4cd47d611fd | |
parent | b1fe177da30fc3771f3e3ba1188476a7856ce000 (diff) |
libbinder: warn when vndbinder use is wasted
We can't return null, because there may be other calls
in the process to ProcessState, but if vndservicemanager
is not installed, we can save a few threads.
Note: due to logs being broken (b/210919187) early in boot,
you may not be able to see logs for this.
Bug: 264617136
Test: check logs, e.g.
02-14 01:31:57.034 3273 3273 E ProcessState: vndservicemanager is not started on this device, you can save resources/threads by not initializing ProcessState with /dev/vndbinder.
Change-Id: Ie91dc4ee302e7a36184e533fb755ce0870e2f546
-rw-r--r-- | libs/binder/ProcessState.cpp | 9 | ||||
-rw-r--r-- | libs/binder/include/binder/ProcessState.h | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp index 254dda81a6..5f1f50672a 100644 --- a/libs/binder/ProcessState.cpp +++ b/libs/binder/ProcessState.cpp @@ -100,6 +100,10 @@ static void verifyNotForked(bool forked) { LOG_ALWAYS_FATAL_IF(forked, "libbinder ProcessState can not be used after fork"); } +bool ProcessState::isVndservicemanagerEnabled() { + return access("/vendor/bin/vndservicemanager", R_OK) == 0; +} + sp<ProcessState> ProcessState::init(const char *driver, bool requireDefault) { #ifdef BINDER_IPC_32BIT @@ -123,6 +127,11 @@ sp<ProcessState> ProcessState::init(const char *driver, bool requireDefault) driver = "/dev/binder"; } + if (0 == strcmp(driver, "/dev/vndbinder") && !isVndservicemanagerEnabled()) { + ALOGE("vndservicemanager is not started on this device, you can save resources/threads " + "by not initializing ProcessState with /dev/vndbinder."); + } + // we must install these before instantiating the gProcess object, // otherwise this would race with creating it, and there could be the // possibility of an invalid gProcess object forked by another thread diff --git a/libs/binder/include/binder/ProcessState.h b/libs/binder/include/binder/ProcessState.h index 471c9949aa..ce578e3f5c 100644 --- a/libs/binder/include/binder/ProcessState.h +++ b/libs/binder/include/binder/ProcessState.h @@ -38,6 +38,8 @@ public: static sp<ProcessState> self(); static sp<ProcessState> selfOrNull(); + static bool isVndservicemanagerEnabled(); + /* initWithDriver() can be used to configure libbinder to use * a different binder driver dev node. It must be called *before* * any call to ProcessState::self(). The default is /dev/vndbinder |