diff options
| author | 2020-09-22 22:00:45 +0000 | |
|---|---|---|
| committer | 2020-09-22 22:00:45 +0000 | |
| commit | d4c28086bcbaffde7dd5a662ab9d5ab068097a84 (patch) | |
| tree | 48d1ffd0659f16fe016f452fbf0601f1ff5b7517 | |
| parent | b3f953a7bfb7299954e95f64b3edecf5eb04be8a (diff) | |
| parent | 9514b203cf79a988f45908d63ca6c9223fca4a12 (diff) | |
Merge "Reland "libbinder: ignore CallRestriction for magic 0 cmd""
| -rw-r--r-- | libs/binder/IPCThreadState.cpp | 8 | ||||
| -rw-r--r-- | libs/binder/ProcessState.cpp | 10 | ||||
| -rw-r--r-- | libs/binder/include/binder/IPCThreadState.h | 9 |
3 files changed, 23 insertions, 4 deletions
diff --git a/libs/binder/IPCThreadState.cpp b/libs/binder/IPCThreadState.cpp index 16afecdbb0..05fcc2b878 100644 --- a/libs/binder/IPCThreadState.cpp +++ b/libs/binder/IPCThreadState.cpp @@ -448,6 +448,14 @@ int32_t IPCThreadState::getLastTransactionBinderFlags() const return mLastTransactionBinderFlags; } +void IPCThreadState::setCallRestriction(ProcessState::CallRestriction restriction) { + mCallRestriction = restriction; +} + +ProcessState::CallRestriction IPCThreadState::getCallRestriction() const { + return mCallRestriction; +} + void IPCThreadState::restoreCallingIdentity(int64_t token) { mCallingUid = (int)(token>>32); diff --git a/libs/binder/ProcessState.cpp b/libs/binder/ProcessState.cpp index a53056560e..83ca687519 100644 --- a/libs/binder/ProcessState.cpp +++ b/libs/binder/ProcessState.cpp @@ -282,9 +282,17 @@ sp<IBinder> ProcessState::getStrongProxyForHandle(int32_t handle) // a driver API to get a handle to the context manager with // proper reference counting. + IPCThreadState* ipc = IPCThreadState::self(); + + CallRestriction originalCallRestriction = ipc->getCallRestriction(); + ipc->setCallRestriction(CallRestriction::NONE); + Parcel data; - status_t status = IPCThreadState::self()->transact( + status_t status = ipc->transact( 0, IBinder::PING_TRANSACTION, data, nullptr, 0); + + ipc->setCallRestriction(originalCallRestriction); + if (status == DEAD_OBJECT) return nullptr; } diff --git a/libs/binder/include/binder/IPCThreadState.h b/libs/binder/include/binder/IPCThreadState.h index aa256d4a6b..49ef253083 100644 --- a/libs/binder/include/binder/IPCThreadState.h +++ b/libs/binder/include/binder/IPCThreadState.h @@ -32,6 +32,8 @@ namespace android { class IPCThreadState { public: + using CallRestriction = ProcessState::CallRestriction; + static IPCThreadState* self(); static IPCThreadState* selfOrNull(); // self(), but won't instantiate @@ -99,6 +101,9 @@ public: void setLastTransactionBinderFlags(int32_t flags); int32_t getLastTransactionBinderFlags() const; + void setCallRestriction(CallRestriction restriction); + CallRestriction getCallRestriction() const; + int64_t clearCallingIdentity(); // Restores PID/UID (not SID) void restoreCallingIdentity(int64_t token); @@ -157,7 +162,6 @@ public: // This constant needs to be kept in sync with Binder.UNSET_WORKSOURCE from the Java // side. static const int32_t kUnsetWorkSource = -1; - private: IPCThreadState(); ~IPCThreadState(); @@ -204,8 +208,7 @@ private: bool mPropagateWorkSource; int32_t mStrictModePolicy; int32_t mLastTransactionBinderFlags; - - ProcessState::CallRestriction mCallRestriction; + CallRestriction mCallRestriction; }; } // namespace android |