Loading include/input/Input.h +55 −30 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include <android/os/MotionEventFlag.h> #endif #include <android/os/PointerIconType.h> #include <ftl/flags.h> #include <math.h> #include <stdint.h> #include <ui/LogicalDisplayId.h> Loading Loading @@ -57,6 +58,7 @@ enum { AKEY_EVENT_FLAG_TAINTED = android::os::IInputConstants::INPUT_EVENT_FLAG_TAINTED, }; // TODO(b/245989146): Remove these definitions and use MotionFlag enum directly. enum { // AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED is defined in include/android/input.h /** Loading Loading @@ -128,20 +130,6 @@ enum { AMOTION_EVENT_PRIVATE_FLAG_SUPPORTS_DIRECTIONAL_ORIENTATION, }; /** * Allowed VerifiedKeyEvent flags. All other flags from KeyEvent do not get verified. * These values must be kept in sync with VerifiedKeyEvent.java */ constexpr int32_t VERIFIED_KEY_EVENT_FLAGS = AKEY_EVENT_FLAG_CANCELED | AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT; /** * Allowed VerifiedMotionEventFlags. All other flags from MotionEvent do not get verified. * These values must be kept in sync with VerifiedMotionEvent.java */ constexpr int32_t VERIFIED_MOTION_EVENT_FLAGS = AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED | AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED | AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT; /** * This flag indicates that the point up event has been canceled. * Typically this is used for palm event when the user has accidental touches. Loading Loading @@ -232,6 +220,39 @@ struct AInputDevice { namespace android { enum class MotionFlag : uint32_t { // clang-format off CANCELED = android::os::IInputConstants::INPUT_EVENT_FLAG_CANCELED, WINDOW_IS_OBSCURED = static_cast<uint32_t>(android::os::MotionEventFlag::WINDOW_IS_OBSCURED), WINDOW_IS_PARTIALLY_OBSCURED = static_cast<uint32_t>(android::os::MotionEventFlag::WINDOW_IS_PARTIALLY_OBSCURED), HOVER_EXIT_PENDING = static_cast<uint32_t>(android::os::MotionEventFlag::HOVER_EXIT_PENDING), IS_GENERATED_GESTURE = static_cast<uint32_t>(android::os::MotionEventFlag::IS_GENERATED_GESTURE), NO_FOCUS_CHANGE = static_cast<uint32_t>(android::os::MotionEventFlag::NO_FOCUS_CHANGE), IS_ACCESSIBILITY_EVENT = static_cast<uint32_t>(android::os::MotionEventFlag::IS_ACCESSIBILITY_EVENT), INJECTED_FROM_ACCESSIBILITY_TOOL = static_cast<uint32_t>(android::os::MotionEventFlag::INJECTED_FROM_ACCESSIBILITY_TOOL), TARGET_ACCESSIBILITY_FOCUS = static_cast<uint32_t>(android::os::MotionEventFlag::TARGET_ACCESSIBILITY_FOCUS), TAINTED = static_cast<uint32_t>(android::os::MotionEventFlag::TAINTED), SUPPORTS_ORIENTATION = static_cast<uint32_t>(android::os::MotionEventFlag::PRIVATE_FLAG_SUPPORTS_ORIENTATION), SUPPORTS_DIRECTIONAL_ORIENTATION = static_cast<uint32_t>(android::os::MotionEventFlag::PRIVATE_FLAG_SUPPORTS_DIRECTIONAL_ORIENTATION), // clang-format on }; /** * Allowed VerifiedKeyEvent flags. All other flags from KeyEvent do not get verified. * These values must be kept in sync with VerifiedKeyEvent.java */ constexpr int32_t VERIFIED_KEY_EVENT_FLAGS = AKEY_EVENT_FLAG_CANCELED | AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT; /** * Allowed VerifiedMotionEventFlags. All other flags from MotionEvent do not get verified. * These values must be kept in sync with VerifiedMotionEvent.java */ constexpr ftl::Flags<MotionFlag> VERIFIED_MOTION_EVENT_FLAGS{MotionFlag::WINDOW_IS_OBSCURED, MotionFlag::WINDOW_IS_PARTIALLY_OBSCURED, MotionFlag::IS_ACCESSIBILITY_EVENT}; class Parcel; /* Loading Loading @@ -702,9 +723,9 @@ public: inline void setAction(int32_t action) { mAction = action; } inline int32_t getFlags() const { return mFlags; } inline ftl::Flags<MotionFlag> getFlags() const { return mFlags; } inline void setFlags(int32_t flags) { mFlags = flags; } inline void setFlags(ftl::Flags<MotionFlag> flags) { mFlags = flags; } inline int32_t getEdgeFlags() const { return mEdgeFlags; } Loading Loading @@ -919,12 +940,13 @@ public: void initialize(int32_t id, DeviceId deviceId, uint32_t source, ui::LogicalDisplayId displayId, std::array<uint8_t, 32> hmac, int32_t action, int32_t actionButton, int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, MotionClassification classification, const ui::Transform& transform, float xPrecision, float yPrecision, float rawXCursorPosition, float rawYCursorPosition, const ui::Transform& rawTransform, nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords); ftl::Flags<MotionFlag> flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, MotionClassification classification, const ui::Transform& transform, float xPrecision, float yPrecision, float rawXCursorPosition, float rawYCursorPosition, const ui::Transform& rawTransform, nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords); void copyFrom(const MotionEvent* other, bool keepHistory); Loading Loading @@ -986,19 +1008,22 @@ public: static std::tuple<int32_t /*action*/, std::vector<PointerProperties>, std::vector<PointerCoords>> split(int32_t action, int32_t flags, int32_t historySize, const std::vector<PointerProperties>&, const std::vector<PointerCoords>&, std::bitset<MAX_POINTER_ID + 1> splitPointerIds); split(int32_t action, ftl::Flags<MotionFlag> flags, int32_t historySize, const std::vector<PointerProperties>&, const std::vector<PointerCoords>&, std::bitset<MAX_POINTER_ID + 1> splitPointerIds); // MotionEvent will transform various axes in different ways, based on the source. For // example, the x and y axes will not have any offsets/translations applied if it comes from a // relative mouse device (since SOURCE_RELATIVE_MOUSE is a non-pointer source). These methods // are used to apply these transformations for different axes. static vec2 calculateTransformedXY(uint32_t source, const ui::Transform&, const vec2& xy); static float calculateTransformedAxisValue(int32_t axis, uint32_t source, int32_t flags, const ui::Transform&, const PointerCoords&); static float calculateTransformedAxisValue(int32_t axis, uint32_t source, ftl::Flags<MotionFlag> flags, const ui::Transform&, const PointerCoords&); static void calculateTransformedCoordsInPlace(PointerCoords& coords, uint32_t source, int32_t flags, const ui::Transform&); static PointerCoords calculateTransformedCoords(uint32_t source, int32_t flags, ftl::Flags<MotionFlag> flags, const ui::Transform&); static PointerCoords calculateTransformedCoords(uint32_t source, ftl::Flags<MotionFlag> flags, const ui::Transform&, const PointerCoords&); // The rounding precision for transformed motion events. static constexpr float ROUNDING_PRECISION = 0.001f; Loading @@ -1009,7 +1034,7 @@ public: protected: int32_t mAction; int32_t mActionButton; int32_t mFlags; ftl::Flags<MotionFlag> mFlags; int32_t mEdgeFlags; int32_t mMetaState; int32_t mButtonState; Loading Loading @@ -1158,7 +1183,7 @@ struct __attribute__((__packed__)) VerifiedMotionEvent : public VerifiedInputEve float rawX; float rawY; int32_t actionMasked; int32_t flags; ftl::Flags<MotionFlag> flags; nsecs_t downTimeNanos; int32_t metaState; int32_t buttonState; Loading include/input/InputEventBuilders.h +4 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <android/input.h> #include <attestation/HmacKeyManager.h> #include <ftl/flags.h> #include <input/Input.h> #include <input/InputTransport.h> #include <ui/LogicalDisplayId.h> Loading Loading @@ -251,7 +252,7 @@ public: MotionEventBuilder(int32_t action, int32_t source) { mAction = action; if (mAction == AMOTION_EVENT_ACTION_CANCEL) { mFlags |= AMOTION_EVENT_FLAG_CANCELED; mFlags |= MotionFlag::CANCELED; } mSource = source; mEventTime = systemTime(SYSTEM_TIME_MONOTONIC); Loading Loading @@ -303,7 +304,7 @@ public: return *this; } MotionEventBuilder& addFlag(uint32_t flags) { MotionEventBuilder& addFlag(ftl::Flags<MotionFlag> flags) { mFlags |= flags; return *this; } Loading Loading @@ -354,7 +355,7 @@ private: ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::DEFAULT}; int32_t mActionButton{0}; int32_t mButtonState{0}; int32_t mFlags{0}; ftl::Flags<MotionFlag> mFlags{}; float mRawXCursorPosition{AMOTION_EVENT_INVALID_CURSOR_POSITION}; float mRawYCursorPosition{AMOTION_EVENT_INVALID_CURSOR_POSITION}; ui::Transform mTransform; Loading libs/binder/RpcSession.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -429,8 +429,9 @@ void RpcSession::join(sp<RpcSession>&& session, PreJoinSetupResult&& setupResult } } } else { ALOGE("Connection failed to init, closing with status %s", ALOGE("Connection failed to init, closing with status %s. Terminating!", statusToString(setupResult.status).c_str()); (void)session->shutdownAndWait(false); } sp<RpcSession::EventListener> listener; Loading @@ -450,6 +451,12 @@ void RpcSession::join(sp<RpcSession>&& session, PreJoinSetupResult&& setupResult "bad state: connection object guaranteed to be in list"); } // If you are hitting this, it's likely because whatever caused the thread to exit // in getAndExecuteCommand did not terminate the thread. We abort here, to make // this discoverable instead of potentially causing a deadlock. LOG_ALWAYS_FATAL_IF(!session->mShutdownTrigger->isTriggered(), "If a thread exits, we only support shutting down the entire RpcSession."); session = nullptr; if (listener != nullptr) { Loading libs/binder/RpcState.cpp +54 −21 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include "Constants.h" #include "Debug.h" #include "FdTrigger.h" #include "RpcWireFormat.h" #include "Utils.h" Loading Loading @@ -389,8 +390,13 @@ status_t RpcState::rpcSend(const sp<RpcSession::RpcConnection>& connection, iovs, niovs, altPoll, ancillaryFds); status != OK) { LOG_RPC_DETAIL("Failed to write %s (%d iovs) on RpcTransport %p, error: %s", what, niovs, if (status == DEAD_OBJECT || status == -ECONNRESET) { LOG_RPC_DETAIL("Failed to write %s (%d iovs) on RpcTransport %p, error: %s", what, niovs, connection->rpcTransport.get(), statusToString(status).c_str()); } else { ALOGE("Failed to write %s (%d iovs) on RpcTransport %p, error: %s", what, niovs, connection->rpcTransport.get(), statusToString(status).c_str()); } (void)session->shutdownAndWait(false); return status; } Loading @@ -407,8 +413,13 @@ status_t RpcState::rpcRec(const sp<RpcSession::RpcConnection>& connection, iovs, niovs, std::nullopt, ancillaryFds); status != OK) { if (status == DEAD_OBJECT || status == -ECONNRESET) { LOG_RPC_DETAIL("Failed to read %s (%d iovs) on RpcTransport %p, error: %s", what, niovs, connection->rpcTransport.get(), statusToString(status).c_str()); } else { ALOGE("Failed to read %s (%d iovs) on RpcTransport %p, error: %s", what, niovs, connection->rpcTransport.get(), statusToString(status).c_str()); } (void)session->shutdownAndWait(false); return status; } Loading Loading @@ -866,26 +877,38 @@ status_t RpcState::processCommand( }); #endif // BINDER_WITH_KERNEL_IPC status_t result = NO_INIT; switch (command.command) { case RPC_COMMAND_TRANSACT: if (type != CommandType::ANY) return BAD_TYPE; return processTransact(connection, session, command, std::move(ancillaryFds)); result = processTransact(connection, session, command, std::move(ancillaryFds)); break; case RPC_COMMAND_DEC_STRONG: return processDecStrong(connection, session, command); } result = processDecStrong(connection, session, command); break; default: // We should always know the version of the opposing side, and since the // RPC-binder-level wire protocol is not self synchronizing, we have no way // to understand where the current command ends and the next one begins. We // also can't consider it a fatal error because this would allow any client // to kill us, so ending the session for misbehaving client. ALOGE("Unknown RPC command %d - terminating session. Header: %s. CommandType: %d. numFds: %zu", command.command, HexString(&command, sizeof(command)).c_str(), static_cast<int>(type), ancillaryFds.size()); ALOGE("Unknown RPC command %d - terminating session. Header: %s. CommandType: %d. " "numFds: %zu", command.command, HexString(&command, sizeof(command)).c_str(), static_cast<int>(type), ancillaryFds.size()); (void)session->shutdownAndWait(false); return DEAD_OBJECT; } if (result != OK) { LOG_ALWAYS_FATAL_IF(!session->mShutdownTrigger->isTriggered(), "Error during processing command must trigger shutdown! %s", statusToString(result).c_str()); } return result; } // THIS FUNCTION MUST SHUTDOWN IF IT ERRORS, ACCORDING TO processCommand. // THIS FUNCTION MUST ALWAYS READ THE FULL COMMAND, ACCORDING TO processCommand. status_t RpcState::processTransact( Loading Loading @@ -1162,7 +1185,7 @@ processTransactInternalTailCall: // done processing all the async commands on this binder that we can, so // write decstrongs on the binder if (addr != 0 && replyStatus == OK) { if (addr != 0) { return flushExcessBinderRefs(session, addr, target); } Loading @@ -1171,8 +1194,12 @@ processTransactInternalTailCall: // Binder refs are flushed for oneway calls only after all calls which are // built up are executed. Otherwise, they fill up the binder buffer. if (addr != 0 && replyStatus == OK) { replyStatus = flushExcessBinderRefs(session, addr, target); if (addr != 0) { // if this fails, we are broken out of the protocol, so just shutdown. There // is no chance we could write the status to the other side. if (status_t status = flushExcessBinderRefs(session, addr, target); status != OK) { return status; } } std::string errorMsg; Loading @@ -1181,6 +1208,12 @@ processTransactInternalTailCall: // Forward the error to the client of the transaction. reply.freeData(); reply.markForRpc(session); if (replyStatus != OK) { ALOGE("Dropping error from transaction (%s) due to more serious error in " "validateParcel (%s)", statusToString(replyStatus).c_str(), statusToString(status).c_str()); } replyStatus = status; } Loading libs/binder/include/binder/RpcThreads.h +0 −2 Original line number Diff line number Diff line Loading @@ -15,8 +15,6 @@ */ #pragma once #include <pthread.h> #include <functional> #include <memory> #include <tuple> Loading Loading
include/input/Input.h +55 −30 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ #include <android/os/MotionEventFlag.h> #endif #include <android/os/PointerIconType.h> #include <ftl/flags.h> #include <math.h> #include <stdint.h> #include <ui/LogicalDisplayId.h> Loading Loading @@ -57,6 +58,7 @@ enum { AKEY_EVENT_FLAG_TAINTED = android::os::IInputConstants::INPUT_EVENT_FLAG_TAINTED, }; // TODO(b/245989146): Remove these definitions and use MotionFlag enum directly. enum { // AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED is defined in include/android/input.h /** Loading Loading @@ -128,20 +130,6 @@ enum { AMOTION_EVENT_PRIVATE_FLAG_SUPPORTS_DIRECTIONAL_ORIENTATION, }; /** * Allowed VerifiedKeyEvent flags. All other flags from KeyEvent do not get verified. * These values must be kept in sync with VerifiedKeyEvent.java */ constexpr int32_t VERIFIED_KEY_EVENT_FLAGS = AKEY_EVENT_FLAG_CANCELED | AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT; /** * Allowed VerifiedMotionEventFlags. All other flags from MotionEvent do not get verified. * These values must be kept in sync with VerifiedMotionEvent.java */ constexpr int32_t VERIFIED_MOTION_EVENT_FLAGS = AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED | AMOTION_EVENT_FLAG_WINDOW_IS_PARTIALLY_OBSCURED | AMOTION_EVENT_FLAG_IS_ACCESSIBILITY_EVENT; /** * This flag indicates that the point up event has been canceled. * Typically this is used for palm event when the user has accidental touches. Loading Loading @@ -232,6 +220,39 @@ struct AInputDevice { namespace android { enum class MotionFlag : uint32_t { // clang-format off CANCELED = android::os::IInputConstants::INPUT_EVENT_FLAG_CANCELED, WINDOW_IS_OBSCURED = static_cast<uint32_t>(android::os::MotionEventFlag::WINDOW_IS_OBSCURED), WINDOW_IS_PARTIALLY_OBSCURED = static_cast<uint32_t>(android::os::MotionEventFlag::WINDOW_IS_PARTIALLY_OBSCURED), HOVER_EXIT_PENDING = static_cast<uint32_t>(android::os::MotionEventFlag::HOVER_EXIT_PENDING), IS_GENERATED_GESTURE = static_cast<uint32_t>(android::os::MotionEventFlag::IS_GENERATED_GESTURE), NO_FOCUS_CHANGE = static_cast<uint32_t>(android::os::MotionEventFlag::NO_FOCUS_CHANGE), IS_ACCESSIBILITY_EVENT = static_cast<uint32_t>(android::os::MotionEventFlag::IS_ACCESSIBILITY_EVENT), INJECTED_FROM_ACCESSIBILITY_TOOL = static_cast<uint32_t>(android::os::MotionEventFlag::INJECTED_FROM_ACCESSIBILITY_TOOL), TARGET_ACCESSIBILITY_FOCUS = static_cast<uint32_t>(android::os::MotionEventFlag::TARGET_ACCESSIBILITY_FOCUS), TAINTED = static_cast<uint32_t>(android::os::MotionEventFlag::TAINTED), SUPPORTS_ORIENTATION = static_cast<uint32_t>(android::os::MotionEventFlag::PRIVATE_FLAG_SUPPORTS_ORIENTATION), SUPPORTS_DIRECTIONAL_ORIENTATION = static_cast<uint32_t>(android::os::MotionEventFlag::PRIVATE_FLAG_SUPPORTS_DIRECTIONAL_ORIENTATION), // clang-format on }; /** * Allowed VerifiedKeyEvent flags. All other flags from KeyEvent do not get verified. * These values must be kept in sync with VerifiedKeyEvent.java */ constexpr int32_t VERIFIED_KEY_EVENT_FLAGS = AKEY_EVENT_FLAG_CANCELED | AKEY_EVENT_FLAG_IS_ACCESSIBILITY_EVENT; /** * Allowed VerifiedMotionEventFlags. All other flags from MotionEvent do not get verified. * These values must be kept in sync with VerifiedMotionEvent.java */ constexpr ftl::Flags<MotionFlag> VERIFIED_MOTION_EVENT_FLAGS{MotionFlag::WINDOW_IS_OBSCURED, MotionFlag::WINDOW_IS_PARTIALLY_OBSCURED, MotionFlag::IS_ACCESSIBILITY_EVENT}; class Parcel; /* Loading Loading @@ -702,9 +723,9 @@ public: inline void setAction(int32_t action) { mAction = action; } inline int32_t getFlags() const { return mFlags; } inline ftl::Flags<MotionFlag> getFlags() const { return mFlags; } inline void setFlags(int32_t flags) { mFlags = flags; } inline void setFlags(ftl::Flags<MotionFlag> flags) { mFlags = flags; } inline int32_t getEdgeFlags() const { return mEdgeFlags; } Loading Loading @@ -919,12 +940,13 @@ public: void initialize(int32_t id, DeviceId deviceId, uint32_t source, ui::LogicalDisplayId displayId, std::array<uint8_t, 32> hmac, int32_t action, int32_t actionButton, int32_t flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, MotionClassification classification, const ui::Transform& transform, float xPrecision, float yPrecision, float rawXCursorPosition, float rawYCursorPosition, const ui::Transform& rawTransform, nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords); ftl::Flags<MotionFlag> flags, int32_t edgeFlags, int32_t metaState, int32_t buttonState, MotionClassification classification, const ui::Transform& transform, float xPrecision, float yPrecision, float rawXCursorPosition, float rawYCursorPosition, const ui::Transform& rawTransform, nsecs_t downTime, nsecs_t eventTime, size_t pointerCount, const PointerProperties* pointerProperties, const PointerCoords* pointerCoords); void copyFrom(const MotionEvent* other, bool keepHistory); Loading Loading @@ -986,19 +1008,22 @@ public: static std::tuple<int32_t /*action*/, std::vector<PointerProperties>, std::vector<PointerCoords>> split(int32_t action, int32_t flags, int32_t historySize, const std::vector<PointerProperties>&, const std::vector<PointerCoords>&, std::bitset<MAX_POINTER_ID + 1> splitPointerIds); split(int32_t action, ftl::Flags<MotionFlag> flags, int32_t historySize, const std::vector<PointerProperties>&, const std::vector<PointerCoords>&, std::bitset<MAX_POINTER_ID + 1> splitPointerIds); // MotionEvent will transform various axes in different ways, based on the source. For // example, the x and y axes will not have any offsets/translations applied if it comes from a // relative mouse device (since SOURCE_RELATIVE_MOUSE is a non-pointer source). These methods // are used to apply these transformations for different axes. static vec2 calculateTransformedXY(uint32_t source, const ui::Transform&, const vec2& xy); static float calculateTransformedAxisValue(int32_t axis, uint32_t source, int32_t flags, const ui::Transform&, const PointerCoords&); static float calculateTransformedAxisValue(int32_t axis, uint32_t source, ftl::Flags<MotionFlag> flags, const ui::Transform&, const PointerCoords&); static void calculateTransformedCoordsInPlace(PointerCoords& coords, uint32_t source, int32_t flags, const ui::Transform&); static PointerCoords calculateTransformedCoords(uint32_t source, int32_t flags, ftl::Flags<MotionFlag> flags, const ui::Transform&); static PointerCoords calculateTransformedCoords(uint32_t source, ftl::Flags<MotionFlag> flags, const ui::Transform&, const PointerCoords&); // The rounding precision for transformed motion events. static constexpr float ROUNDING_PRECISION = 0.001f; Loading @@ -1009,7 +1034,7 @@ public: protected: int32_t mAction; int32_t mActionButton; int32_t mFlags; ftl::Flags<MotionFlag> mFlags; int32_t mEdgeFlags; int32_t mMetaState; int32_t mButtonState; Loading Loading @@ -1158,7 +1183,7 @@ struct __attribute__((__packed__)) VerifiedMotionEvent : public VerifiedInputEve float rawX; float rawY; int32_t actionMasked; int32_t flags; ftl::Flags<MotionFlag> flags; nsecs_t downTimeNanos; int32_t metaState; int32_t buttonState; Loading
include/input/InputEventBuilders.h +4 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include <android/input.h> #include <attestation/HmacKeyManager.h> #include <ftl/flags.h> #include <input/Input.h> #include <input/InputTransport.h> #include <ui/LogicalDisplayId.h> Loading Loading @@ -251,7 +252,7 @@ public: MotionEventBuilder(int32_t action, int32_t source) { mAction = action; if (mAction == AMOTION_EVENT_ACTION_CANCEL) { mFlags |= AMOTION_EVENT_FLAG_CANCELED; mFlags |= MotionFlag::CANCELED; } mSource = source; mEventTime = systemTime(SYSTEM_TIME_MONOTONIC); Loading Loading @@ -303,7 +304,7 @@ public: return *this; } MotionEventBuilder& addFlag(uint32_t flags) { MotionEventBuilder& addFlag(ftl::Flags<MotionFlag> flags) { mFlags |= flags; return *this; } Loading Loading @@ -354,7 +355,7 @@ private: ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::DEFAULT}; int32_t mActionButton{0}; int32_t mButtonState{0}; int32_t mFlags{0}; ftl::Flags<MotionFlag> mFlags{}; float mRawXCursorPosition{AMOTION_EVENT_INVALID_CURSOR_POSITION}; float mRawYCursorPosition{AMOTION_EVENT_INVALID_CURSOR_POSITION}; ui::Transform mTransform; Loading
libs/binder/RpcSession.cpp +8 −1 Original line number Diff line number Diff line Loading @@ -429,8 +429,9 @@ void RpcSession::join(sp<RpcSession>&& session, PreJoinSetupResult&& setupResult } } } else { ALOGE("Connection failed to init, closing with status %s", ALOGE("Connection failed to init, closing with status %s. Terminating!", statusToString(setupResult.status).c_str()); (void)session->shutdownAndWait(false); } sp<RpcSession::EventListener> listener; Loading @@ -450,6 +451,12 @@ void RpcSession::join(sp<RpcSession>&& session, PreJoinSetupResult&& setupResult "bad state: connection object guaranteed to be in list"); } // If you are hitting this, it's likely because whatever caused the thread to exit // in getAndExecuteCommand did not terminate the thread. We abort here, to make // this discoverable instead of potentially causing a deadlock. LOG_ALWAYS_FATAL_IF(!session->mShutdownTrigger->isTriggered(), "If a thread exits, we only support shutting down the entire RpcSession."); session = nullptr; if (listener != nullptr) { Loading
libs/binder/RpcState.cpp +54 −21 Original line number Diff line number Diff line Loading @@ -25,6 +25,7 @@ #include "Constants.h" #include "Debug.h" #include "FdTrigger.h" #include "RpcWireFormat.h" #include "Utils.h" Loading Loading @@ -389,8 +390,13 @@ status_t RpcState::rpcSend(const sp<RpcSession::RpcConnection>& connection, iovs, niovs, altPoll, ancillaryFds); status != OK) { LOG_RPC_DETAIL("Failed to write %s (%d iovs) on RpcTransport %p, error: %s", what, niovs, if (status == DEAD_OBJECT || status == -ECONNRESET) { LOG_RPC_DETAIL("Failed to write %s (%d iovs) on RpcTransport %p, error: %s", what, niovs, connection->rpcTransport.get(), statusToString(status).c_str()); } else { ALOGE("Failed to write %s (%d iovs) on RpcTransport %p, error: %s", what, niovs, connection->rpcTransport.get(), statusToString(status).c_str()); } (void)session->shutdownAndWait(false); return status; } Loading @@ -407,8 +413,13 @@ status_t RpcState::rpcRec(const sp<RpcSession::RpcConnection>& connection, iovs, niovs, std::nullopt, ancillaryFds); status != OK) { if (status == DEAD_OBJECT || status == -ECONNRESET) { LOG_RPC_DETAIL("Failed to read %s (%d iovs) on RpcTransport %p, error: %s", what, niovs, connection->rpcTransport.get(), statusToString(status).c_str()); } else { ALOGE("Failed to read %s (%d iovs) on RpcTransport %p, error: %s", what, niovs, connection->rpcTransport.get(), statusToString(status).c_str()); } (void)session->shutdownAndWait(false); return status; } Loading Loading @@ -866,26 +877,38 @@ status_t RpcState::processCommand( }); #endif // BINDER_WITH_KERNEL_IPC status_t result = NO_INIT; switch (command.command) { case RPC_COMMAND_TRANSACT: if (type != CommandType::ANY) return BAD_TYPE; return processTransact(connection, session, command, std::move(ancillaryFds)); result = processTransact(connection, session, command, std::move(ancillaryFds)); break; case RPC_COMMAND_DEC_STRONG: return processDecStrong(connection, session, command); } result = processDecStrong(connection, session, command); break; default: // We should always know the version of the opposing side, and since the // RPC-binder-level wire protocol is not self synchronizing, we have no way // to understand where the current command ends and the next one begins. We // also can't consider it a fatal error because this would allow any client // to kill us, so ending the session for misbehaving client. ALOGE("Unknown RPC command %d - terminating session. Header: %s. CommandType: %d. numFds: %zu", command.command, HexString(&command, sizeof(command)).c_str(), static_cast<int>(type), ancillaryFds.size()); ALOGE("Unknown RPC command %d - terminating session. Header: %s. CommandType: %d. " "numFds: %zu", command.command, HexString(&command, sizeof(command)).c_str(), static_cast<int>(type), ancillaryFds.size()); (void)session->shutdownAndWait(false); return DEAD_OBJECT; } if (result != OK) { LOG_ALWAYS_FATAL_IF(!session->mShutdownTrigger->isTriggered(), "Error during processing command must trigger shutdown! %s", statusToString(result).c_str()); } return result; } // THIS FUNCTION MUST SHUTDOWN IF IT ERRORS, ACCORDING TO processCommand. // THIS FUNCTION MUST ALWAYS READ THE FULL COMMAND, ACCORDING TO processCommand. status_t RpcState::processTransact( Loading Loading @@ -1162,7 +1185,7 @@ processTransactInternalTailCall: // done processing all the async commands on this binder that we can, so // write decstrongs on the binder if (addr != 0 && replyStatus == OK) { if (addr != 0) { return flushExcessBinderRefs(session, addr, target); } Loading @@ -1171,8 +1194,12 @@ processTransactInternalTailCall: // Binder refs are flushed for oneway calls only after all calls which are // built up are executed. Otherwise, they fill up the binder buffer. if (addr != 0 && replyStatus == OK) { replyStatus = flushExcessBinderRefs(session, addr, target); if (addr != 0) { // if this fails, we are broken out of the protocol, so just shutdown. There // is no chance we could write the status to the other side. if (status_t status = flushExcessBinderRefs(session, addr, target); status != OK) { return status; } } std::string errorMsg; Loading @@ -1181,6 +1208,12 @@ processTransactInternalTailCall: // Forward the error to the client of the transaction. reply.freeData(); reply.markForRpc(session); if (replyStatus != OK) { ALOGE("Dropping error from transaction (%s) due to more serious error in " "validateParcel (%s)", statusToString(replyStatus).c_str(), statusToString(status).c_str()); } replyStatus = status; } Loading
libs/binder/include/binder/RpcThreads.h +0 −2 Original line number Diff line number Diff line Loading @@ -15,8 +15,6 @@ */ #pragma once #include <pthread.h> #include <functional> #include <memory> #include <tuple> Loading