diff options
| author | 2021-05-14 17:51:03 +0000 | |
|---|---|---|
| committer | 2021-05-14 17:51:03 +0000 | |
| commit | da55afdbd41f66d33af20c31630f18cfec4616ea (patch) | |
| tree | c4509cb97211ec161f5f67c38c9541e9585912b1 /libs/binder/RpcState.cpp | |
| parent | 982e8b7d3be0eef5f47c715526e11206008f64b7 (diff) | |
| parent | 08cb54f49df91e1a4240eaa916dc0dc65689352e (diff) | |
Merge changes Id8fc889f,I2145ad0e am: 5426122b9b am: 08cb54f49d
Original change: https://android-review.googlesource.com/c/platform/frameworks/native/+/1707789
Change-Id: I44d1b684d2a177b71c2a0aa64bd19d5fd1ba7b14
Diffstat (limited to 'libs/binder/RpcState.cpp')
| -rw-r--r-- | libs/binder/RpcState.cpp | 16 | 
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/binder/RpcState.cpp b/libs/binder/RpcState.cpp index 2ba9fa2bd5..e5a6026f3b 100644 --- a/libs/binder/RpcState.cpp +++ b/libs/binder/RpcState.cpp @@ -18,7 +18,9 @@  #include "RpcState.h" +#include <android-base/scopeguard.h>  #include <binder/BpBinder.h> +#include <binder/IPCThreadState.h>  #include <binder/RpcServer.h>  #include "Debug.h" @@ -28,6 +30,8 @@  namespace android { +using base::ScopeGuard; +  RpcState::RpcState() {}  RpcState::~RpcState() {} @@ -470,6 +474,18 @@ status_t RpcState::getAndExecuteCommand(const base::unique_fd& fd, const sp<RpcS  status_t RpcState::processServerCommand(const base::unique_fd& fd, const sp<RpcSession>& session,                                          const RpcWireHeader& command) { +    IPCThreadState* kernelBinderState = IPCThreadState::selfOrNull(); +    IPCThreadState::SpGuard spGuard{"processing binder RPC command"}; +    IPCThreadState::SpGuard* origGuard; +    if (kernelBinderState != nullptr) { +        origGuard = kernelBinderState->pushGetCallingSpGuard(&spGuard); +    } +    ScopeGuard guardUnguard = [&]() { +        if (kernelBinderState != nullptr) { +            kernelBinderState->restoreGetCallingSpGuard(origGuard); +        } +    }; +      switch (command.command) {          case RPC_COMMAND_TRANSACT:              return processTransact(fd, session, command);  |