Loading libs/binder/Binder.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -407,8 +407,10 @@ status_t BBinder::transact( AutoMutex lock(e->mLock); if (mRecordingOn) { Parcel emptyReply; timespec ts; timespec_get(&ts, TIME_UTC); auto transaction = android::binder::debug::RecordedTransaction::fromDetails(code, flags, data, android::binder::debug::RecordedTransaction::fromDetails(code, flags, ts, data, reply ? *reply : emptyReply, err); Loading libs/binder/BinderRecordReplay.cpp +16 −3 Original line number Diff line number Diff line Loading @@ -101,18 +101,24 @@ static_assert(PADDING8(8) == 0); // End Chunk may therefore produce a empty, meaningless RecordedTransaction. RecordedTransaction::RecordedTransaction(RecordedTransaction&& t) noexcept { mHeader = {t.getCode(), t.getFlags(), t.getReturnedStatus(), t.getVersion()}; mHeader = t.mHeader; mSent.setData(t.getDataParcel().data(), t.getDataParcel().dataSize()); mReply.setData(t.getReplyParcel().data(), t.getReplyParcel().dataSize()); } std::optional<RecordedTransaction> RecordedTransaction::fromDetails(uint32_t code, uint32_t flags, timespec timestamp, const Parcel& dataParcel, const Parcel& replyParcel, status_t err) { RecordedTransaction t; t.mHeader = {code, flags, static_cast<int32_t>(err), dataParcel.isForRpc() ? static_cast<uint32_t>(1) : static_cast<uint32_t>(0)}; t.mHeader = {code, flags, static_cast<int32_t>(err), dataParcel.isForRpc() ? static_cast<uint32_t>(1) : static_cast<uint32_t>(0), static_cast<int64_t>(timestamp.tv_sec), static_cast<int32_t>(timestamp.tv_nsec), 0}; if (t.mSent.setData(dataParcel.data(), dataParcel.dataSize()) != android::NO_ERROR) { LOG(INFO) << "Failed to set sent parcel data."; Loading Loading @@ -175,6 +181,7 @@ std::optional<RecordedTransaction> RecordedTransaction::fromFile(const unique_fd LOG(INFO) << "Failed to read transactionHeader from fd " << fd.get(); return std::nullopt; } lseek(fd.get(), chunk.padding, SEEK_CUR); break; } case DATA_PARCEL_CHUNK: { Loading Loading @@ -292,6 +299,12 @@ int32_t RecordedTransaction::getReturnedStatus() const { return mHeader.statusReturned; } timespec RecordedTransaction::getTimestamp() const { time_t sec = mHeader.timestampSeconds; int32_t nsec = mHeader.timestampNanoseconds; return (timespec){.tv_sec = sec, .tv_nsec = nsec}; } uint32_t RecordedTransaction::getVersion() const { return mHeader.version; } Loading libs/binder/include/binder/BinderRecordReplay.h +7 −3 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ public: static std::optional<RecordedTransaction> fromFile(const android::base::unique_fd& fd); // Filled with the arguments. static std::optional<RecordedTransaction> fromDetails(uint32_t code, uint32_t flags, const Parcel& data, const Parcel& reply, status_t err); timespec timestamp, const Parcel& data, const Parcel& reply, status_t err); RecordedTransaction(RecordedTransaction&& t) noexcept; [[nodiscard]] status_t dumpToFile(const android::base::unique_fd& fd) const; Loading @@ -43,6 +43,7 @@ public: uint32_t getCode() const; uint32_t getFlags() const; int32_t getReturnedStatus() const; timespec getTimestamp() const; uint32_t getVersion() const; const Parcel& getDataParcel() const; const Parcel& getReplyParcel() const; Loading @@ -60,9 +61,12 @@ private: uint32_t flags = 0; int32_t statusReturned = 0; uint32_t version = 0; // !0 iff Rpc int64_t timestampSeconds = 0; int32_t timestampNanoseconds = 0; int32_t reserved = 0; }; #pragma clang diagnostic pop static_assert(sizeof(TransactionHeader) == 16); static_assert(sizeof(TransactionHeader) == 32); static_assert(sizeof(TransactionHeader) % 8 == 0); TransactionHeader mHeader; Loading libs/binder/include/binder/IServiceManager.h +3 −0 Original line number Diff line number Diff line Loading @@ -198,7 +198,10 @@ status_t getService(const String16& name, sp<INTERFACE>* outService) { const sp<IServiceManager> sm = defaultServiceManager(); if (sm != nullptr) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" *outService = interface_cast<INTERFACE>(sm->getService(name)); #pragma clang diagnostic pop // getService deprecation if ((*outService) != nullptr) return NO_ERROR; } return NAME_NOT_FOUND; Loading libs/binder/ndk/include_cpp/android/binder_to_string.h +36 −11 Original line number Diff line number Diff line Loading @@ -49,12 +49,19 @@ #include <android/binder_interface_utils.h> #include <android/binder_parcelable_utils.h> #define HAS_NDK_INTERFACE #else #endif // TODO: some things include libbinder without having access to libbase. This is // due to frameworks/native/include, which symlinks to libbinder headers, so even // though we don't use it here, we detect a different header, so that we are more // confident libbase will be included #if __has_include(<binder/RpcSession.h>) #include <binder/IBinder.h> #include <binder/IInterface.h> #include <binder/ParcelFileDescriptor.h> #include <binder/ParcelableHolder.h> #endif //_has_include #define HAS_CPP_INTERFACE #endif namespace android { namespace internal { Loading Loading @@ -134,14 +141,16 @@ class IsIterable { template <typename _T> class ToEmptyString { template <typename _U> static std::enable_if_t< static std::enable_if_t<false #ifdef HAS_NDK_INTERFACE std::is_base_of_v<::ndk::ICInterface, _U> || std::is_base_of_v<::ndk::ICInterface, _U> #if __ANDROID_API__ >= 31 || std::is_same_v<::ndk::AParcelableHolder, _U> #endif #else std::is_base_of_v<IInterface, _U> || std::is_same_v<IBinder, _U> || #endif // HAS_NDK_INTERFACE #ifdef HAS_CPP_INTERFACE || std::is_base_of_v<IInterface, _U> || std::is_same_v<IBinder, _U> || std::is_same_v<os::ParcelFileDescriptor, _U> || std::is_same_v<os::ParcelableHolder, _U> #endif Loading Loading @@ -221,4 +230,20 @@ std::string ToString(const _T& t) { } // namespace internal } // namespace android #ifdef HAS_STRONG_POINTER #undef HAS_STRONG_POINTER #endif #ifdef HAS_STRING16 #undef HAS_STRING16 #endif #ifdef HAS_NDK_INTERFACE #undef HAS_NDK_INTERFACE #endif #ifdef HAS_CPP_INTERFACE #undef HAS_CPP_INTERFACE #endif /** @} */ Loading
libs/binder/Binder.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -407,8 +407,10 @@ status_t BBinder::transact( AutoMutex lock(e->mLock); if (mRecordingOn) { Parcel emptyReply; timespec ts; timespec_get(&ts, TIME_UTC); auto transaction = android::binder::debug::RecordedTransaction::fromDetails(code, flags, data, android::binder::debug::RecordedTransaction::fromDetails(code, flags, ts, data, reply ? *reply : emptyReply, err); Loading
libs/binder/BinderRecordReplay.cpp +16 −3 Original line number Diff line number Diff line Loading @@ -101,18 +101,24 @@ static_assert(PADDING8(8) == 0); // End Chunk may therefore produce a empty, meaningless RecordedTransaction. RecordedTransaction::RecordedTransaction(RecordedTransaction&& t) noexcept { mHeader = {t.getCode(), t.getFlags(), t.getReturnedStatus(), t.getVersion()}; mHeader = t.mHeader; mSent.setData(t.getDataParcel().data(), t.getDataParcel().dataSize()); mReply.setData(t.getReplyParcel().data(), t.getReplyParcel().dataSize()); } std::optional<RecordedTransaction> RecordedTransaction::fromDetails(uint32_t code, uint32_t flags, timespec timestamp, const Parcel& dataParcel, const Parcel& replyParcel, status_t err) { RecordedTransaction t; t.mHeader = {code, flags, static_cast<int32_t>(err), dataParcel.isForRpc() ? static_cast<uint32_t>(1) : static_cast<uint32_t>(0)}; t.mHeader = {code, flags, static_cast<int32_t>(err), dataParcel.isForRpc() ? static_cast<uint32_t>(1) : static_cast<uint32_t>(0), static_cast<int64_t>(timestamp.tv_sec), static_cast<int32_t>(timestamp.tv_nsec), 0}; if (t.mSent.setData(dataParcel.data(), dataParcel.dataSize()) != android::NO_ERROR) { LOG(INFO) << "Failed to set sent parcel data."; Loading Loading @@ -175,6 +181,7 @@ std::optional<RecordedTransaction> RecordedTransaction::fromFile(const unique_fd LOG(INFO) << "Failed to read transactionHeader from fd " << fd.get(); return std::nullopt; } lseek(fd.get(), chunk.padding, SEEK_CUR); break; } case DATA_PARCEL_CHUNK: { Loading Loading @@ -292,6 +299,12 @@ int32_t RecordedTransaction::getReturnedStatus() const { return mHeader.statusReturned; } timespec RecordedTransaction::getTimestamp() const { time_t sec = mHeader.timestampSeconds; int32_t nsec = mHeader.timestampNanoseconds; return (timespec){.tv_sec = sec, .tv_nsec = nsec}; } uint32_t RecordedTransaction::getVersion() const { return mHeader.version; } Loading
libs/binder/include/binder/BinderRecordReplay.h +7 −3 Original line number Diff line number Diff line Loading @@ -34,8 +34,8 @@ public: static std::optional<RecordedTransaction> fromFile(const android::base::unique_fd& fd); // Filled with the arguments. static std::optional<RecordedTransaction> fromDetails(uint32_t code, uint32_t flags, const Parcel& data, const Parcel& reply, status_t err); timespec timestamp, const Parcel& data, const Parcel& reply, status_t err); RecordedTransaction(RecordedTransaction&& t) noexcept; [[nodiscard]] status_t dumpToFile(const android::base::unique_fd& fd) const; Loading @@ -43,6 +43,7 @@ public: uint32_t getCode() const; uint32_t getFlags() const; int32_t getReturnedStatus() const; timespec getTimestamp() const; uint32_t getVersion() const; const Parcel& getDataParcel() const; const Parcel& getReplyParcel() const; Loading @@ -60,9 +61,12 @@ private: uint32_t flags = 0; int32_t statusReturned = 0; uint32_t version = 0; // !0 iff Rpc int64_t timestampSeconds = 0; int32_t timestampNanoseconds = 0; int32_t reserved = 0; }; #pragma clang diagnostic pop static_assert(sizeof(TransactionHeader) == 16); static_assert(sizeof(TransactionHeader) == 32); static_assert(sizeof(TransactionHeader) % 8 == 0); TransactionHeader mHeader; Loading
libs/binder/include/binder/IServiceManager.h +3 −0 Original line number Diff line number Diff line Loading @@ -198,7 +198,10 @@ status_t getService(const String16& name, sp<INTERFACE>* outService) { const sp<IServiceManager> sm = defaultServiceManager(); if (sm != nullptr) { #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" *outService = interface_cast<INTERFACE>(sm->getService(name)); #pragma clang diagnostic pop // getService deprecation if ((*outService) != nullptr) return NO_ERROR; } return NAME_NOT_FOUND; Loading
libs/binder/ndk/include_cpp/android/binder_to_string.h +36 −11 Original line number Diff line number Diff line Loading @@ -49,12 +49,19 @@ #include <android/binder_interface_utils.h> #include <android/binder_parcelable_utils.h> #define HAS_NDK_INTERFACE #else #endif // TODO: some things include libbinder without having access to libbase. This is // due to frameworks/native/include, which symlinks to libbinder headers, so even // though we don't use it here, we detect a different header, so that we are more // confident libbase will be included #if __has_include(<binder/RpcSession.h>) #include <binder/IBinder.h> #include <binder/IInterface.h> #include <binder/ParcelFileDescriptor.h> #include <binder/ParcelableHolder.h> #endif //_has_include #define HAS_CPP_INTERFACE #endif namespace android { namespace internal { Loading Loading @@ -134,14 +141,16 @@ class IsIterable { template <typename _T> class ToEmptyString { template <typename _U> static std::enable_if_t< static std::enable_if_t<false #ifdef HAS_NDK_INTERFACE std::is_base_of_v<::ndk::ICInterface, _U> || std::is_base_of_v<::ndk::ICInterface, _U> #if __ANDROID_API__ >= 31 || std::is_same_v<::ndk::AParcelableHolder, _U> #endif #else std::is_base_of_v<IInterface, _U> || std::is_same_v<IBinder, _U> || #endif // HAS_NDK_INTERFACE #ifdef HAS_CPP_INTERFACE || std::is_base_of_v<IInterface, _U> || std::is_same_v<IBinder, _U> || std::is_same_v<os::ParcelFileDescriptor, _U> || std::is_same_v<os::ParcelableHolder, _U> #endif Loading Loading @@ -221,4 +230,20 @@ std::string ToString(const _T& t) { } // namespace internal } // namespace android #ifdef HAS_STRONG_POINTER #undef HAS_STRONG_POINTER #endif #ifdef HAS_STRING16 #undef HAS_STRING16 #endif #ifdef HAS_NDK_INTERFACE #undef HAS_NDK_INTERFACE #endif #ifdef HAS_CPP_INTERFACE #undef HAS_CPP_INTERFACE #endif /** @} */