diff options
Diffstat (limited to 'libs/binder/include/binder/IPCThreadState.h')
-rw-r--r-- | libs/binder/include/binder/IPCThreadState.h | 71 |
1 files changed, 53 insertions, 18 deletions
diff --git a/libs/binder/include/binder/IPCThreadState.h b/libs/binder/include/binder/IPCThreadState.h index 4818889436..196a41ba55 100644 --- a/libs/binder/include/binder/IPCThreadState.h +++ b/libs/binder/include/binder/IPCThreadState.h @@ -14,8 +14,7 @@ * limitations under the License. */ -#ifndef ANDROID_IPC_THREAD_STATE_H -#define ANDROID_IPC_THREAD_STATE_H +#pragma once #include <utils/Errors.h> #include <binder/Parcel.h> @@ -32,19 +31,54 @@ namespace android { class IPCThreadState { public: + using CallRestriction = ProcessState::CallRestriction; + static IPCThreadState* self(); static IPCThreadState* selfOrNull(); // self(), but won't instantiate - + + // Freeze or unfreeze the binder interface to a specific process. When freezing, this method + // will block up to timeout_ms to process pending transactions directed to pid. Unfreeze + // is immediate. Transactions to processes frozen via this method won't be delivered and the + // driver will return BR_FROZEN_REPLY to the client sending them. After unfreeze, + // transactions will be delivered normally. + // + // pid: id for the process for which the binder interface is to be frozen + // enable: freeze (true) or unfreeze (false) + // timeout_ms: maximum time this function is allowed to block the caller waiting for pending + // binder transactions to be processed. + // + // returns: 0 in case of success, a value < 0 in case of error + static status_t freeze(pid_t pid, bool enabled, uint32_t timeout_ms); + + // Provide information about the state of a frozen process + static status_t getProcessFreezeInfo(pid_t pid, bool *sync_received, + bool *async_received); sp<ProcessState> process(); status_t clearLastError(); + /** + * Returns the PID of the process which has made the current binder + * call. If not in a binder call, this will return getpid. If the + * call is oneway, this will return 0. + */ pid_t getCallingPid() const; - // nullptr if unavailable - // - // this can't be restored once it's cleared, and it does not return the - // context of the current process when not in a binder call. + + /** + * Returns the SELinux security identifier of the process which has + * made the current binder call. If not in a binder call this will + * return nullptr. If this isn't requested with + * Binder::setRequestingSid, it will also return nullptr. + * + * This can't be restored once it's cleared, and it does not return the + * context of the current process when not in a binder call. + */ const char* getCallingSid() const; + + /** + * Returns the UID of the process which has made the current binder + * call. If not in a binder call, this will return 0. + */ uid_t getCallingUid() const; void setStrictModePolicy(int32_t policy); @@ -66,13 +100,17 @@ 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); - - int setupPolling(int* fd); + + status_t setupPolling(int* fd); status_t handlePolledCommands(); void flushCommands(); + bool flushIfNeeded(); void joinThreadPool(bool isMain = true); @@ -109,7 +147,7 @@ public: void blockUntilThreadAvailable(); // Service manager registration - void setTheContextObject(sp<BBinder> obj); + void setTheContextObject(const sp<BBinder>& obj); // WARNING: DO NOT USE THIS API // @@ -124,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(); @@ -149,9 +186,8 @@ private: static void threadDestructor(void *st); static void freeBuffer(Parcel* parcel, const uint8_t* data, size_t dataSize, - const binder_size_t* objects, size_t objectsSize, - void* cookie); - + const binder_size_t* objects, size_t objectsSize); + const sp<ProcessState> mProcess; Vector<BBinder*> mPendingStrongDerefs; Vector<RefBase::weakref_type*> mPendingWeakDerefs; @@ -169,14 +205,13 @@ private: int32_t mWorkSource; // Whether the work source should be propagated. bool mPropagateWorkSource; + bool mIsLooper; + bool mIsFlushing; int32_t mStrictModePolicy; int32_t mLastTransactionBinderFlags; - - ProcessState::CallRestriction mCallRestriction; + CallRestriction mCallRestriction; }; } // namespace android // --------------------------------------------------------------------------- - -#endif // ANDROID_IPC_THREAD_STATE_H |