Loading include/input/Input.h +1 −4 Original line number Diff line number Diff line Loading @@ -840,15 +840,12 @@ public: inline bool getHasFocus() const { return mHasFocus; } inline bool getInTouchMode() const { return mInTouchMode; } void initialize(int32_t id, bool hasFocus, bool inTouchMode); void initialize(int32_t id, bool hasFocus); void initialize(const FocusEvent& from); protected: bool mHasFocus; bool mInTouchMode; }; /* Loading include/input/InputTransport.h +3 −4 Original line number Diff line number Diff line Loading @@ -178,10 +178,9 @@ struct InputMessage { struct Focus { int32_t eventId; // The following 3 fields take up 4 bytes total // The following 2 fields take up 4 bytes total bool hasFocus; bool inTouchMode; uint8_t empty[2]; uint8_t empty[3]; inline size_t size() const { return sizeof(Focus); } } focus; Loading Loading @@ -381,7 +380,7 @@ public: * Returns DEAD_OBJECT if the channel's peer has been closed. * Other errors probably indicate that the channel is broken. */ status_t publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus, bool inTouchMode); status_t publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus); /* Publishes a capture event to the input channel. * Loading libs/input/Input.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -820,17 +820,15 @@ float MotionEvent::calculateTransformedAxisValue(int32_t axis, uint32_t source, // --- FocusEvent --- void FocusEvent::initialize(int32_t id, bool hasFocus, bool inTouchMode) { void FocusEvent::initialize(int32_t id, bool hasFocus) { InputEvent::initialize(id, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, AINPUT_SOURCE_UNKNOWN, ADISPLAY_ID_NONE, INVALID_HMAC); mHasFocus = hasFocus; mInTouchMode = inTouchMode; } void FocusEvent::initialize(const FocusEvent& from) { InputEvent::initialize(from); mHasFocus = from.mHasFocus; mInTouchMode = from.mInTouchMode; } // --- CaptureEvent --- Loading libs/input/InputTransport.cpp +6 −13 Original line number Diff line number Diff line Loading @@ -278,7 +278,6 @@ void InputMessage::getSanitizedCopy(InputMessage* msg) const { case InputMessage::Type::FOCUS: { msg->body.focus.eventId = body.focus.eventId; msg->body.focus.hasFocus = body.focus.hasFocus; msg->body.focus.inTouchMode = body.focus.inTouchMode; break; } case InputMessage::Type::CAPTURE: { Loading Loading @@ -622,13 +621,10 @@ status_t InputPublisher::publishMotionEvent( return mChannel->sendMessage(&msg); } status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus, bool inTouchMode) { status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus) { if (ATRACE_ENABLED()) { std::string message = StringPrintf("publishFocusEvent(inputChannel=%s, hasFocus=%s, inTouchMode=%s)", mChannel->getName().c_str(), toString(hasFocus), toString(inTouchMode)); std::string message = StringPrintf("publishFocusEvent(inputChannel=%s, hasFocus=%s)", mChannel->getName().c_str(), toString(hasFocus)); ATRACE_NAME(message.c_str()); } Loading @@ -637,7 +633,6 @@ status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool h msg.header.seq = seq; msg.body.focus.eventId = eventId; msg.body.focus.hasFocus = hasFocus; msg.body.focus.inTouchMode = inTouchMode; return mChannel->sendMessage(&msg); } Loading Loading @@ -1371,8 +1366,7 @@ void InputConsumer::initializeKeyEvent(KeyEvent* event, const InputMessage* msg) } void InputConsumer::initializeFocusEvent(FocusEvent* event, const InputMessage* msg) { event->initialize(msg->body.focus.eventId, msg->body.focus.hasFocus, msg->body.focus.inTouchMode); event->initialize(msg->body.focus.eventId, msg->body.focus.hasFocus); } void InputConsumer::initializeCaptureEvent(CaptureEvent* event, const InputMessage* msg) { Loading Loading @@ -1491,9 +1485,8 @@ std::string InputConsumer::dump() const { break; } case InputMessage::Type::FOCUS: { out += android::base::StringPrintf("hasFocus=%s inTouchMode=%s", toString(msg.body.focus.hasFocus), toString(msg.body.focus.inTouchMode)); out += android::base::StringPrintf("hasFocus=%s", toString(msg.body.focus.hasFocus)); break; } case InputMessage::Type::CAPTURE: { Loading libs/input/tests/InputPublisherAndConsumer_test.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -290,10 +290,9 @@ void InputPublisherAndConsumerTest::PublishAndConsumeFocusEvent() { constexpr uint32_t seq = 15; int32_t eventId = InputEvent::nextId(); constexpr bool hasFocus = true; constexpr bool inTouchMode = true; const nsecs_t publishTime = systemTime(SYSTEM_TIME_MONOTONIC); status = mPublisher->publishFocusEvent(seq, eventId, hasFocus, inTouchMode); status = mPublisher->publishFocusEvent(seq, eventId, hasFocus); ASSERT_EQ(OK, status) << "publisher publishFocusEvent should return OK"; uint32_t consumeSeq; Loading @@ -309,7 +308,6 @@ void InputPublisherAndConsumerTest::PublishAndConsumeFocusEvent() { EXPECT_EQ(seq, consumeSeq); EXPECT_EQ(eventId, focusEvent->getId()); EXPECT_EQ(hasFocus, focusEvent->getHasFocus()); EXPECT_EQ(inTouchMode, focusEvent->getInTouchMode()); status = mConsumer->sendFinishedSignal(seq, true); ASSERT_EQ(OK, status) << "consumer sendFinishedSignal should return OK"; Loading Loading
include/input/Input.h +1 −4 Original line number Diff line number Diff line Loading @@ -840,15 +840,12 @@ public: inline bool getHasFocus() const { return mHasFocus; } inline bool getInTouchMode() const { return mInTouchMode; } void initialize(int32_t id, bool hasFocus, bool inTouchMode); void initialize(int32_t id, bool hasFocus); void initialize(const FocusEvent& from); protected: bool mHasFocus; bool mInTouchMode; }; /* Loading
include/input/InputTransport.h +3 −4 Original line number Diff line number Diff line Loading @@ -178,10 +178,9 @@ struct InputMessage { struct Focus { int32_t eventId; // The following 3 fields take up 4 bytes total // The following 2 fields take up 4 bytes total bool hasFocus; bool inTouchMode; uint8_t empty[2]; uint8_t empty[3]; inline size_t size() const { return sizeof(Focus); } } focus; Loading Loading @@ -381,7 +380,7 @@ public: * Returns DEAD_OBJECT if the channel's peer has been closed. * Other errors probably indicate that the channel is broken. */ status_t publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus, bool inTouchMode); status_t publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus); /* Publishes a capture event to the input channel. * Loading
libs/input/Input.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -820,17 +820,15 @@ float MotionEvent::calculateTransformedAxisValue(int32_t axis, uint32_t source, // --- FocusEvent --- void FocusEvent::initialize(int32_t id, bool hasFocus, bool inTouchMode) { void FocusEvent::initialize(int32_t id, bool hasFocus) { InputEvent::initialize(id, ReservedInputDeviceId::VIRTUAL_KEYBOARD_ID, AINPUT_SOURCE_UNKNOWN, ADISPLAY_ID_NONE, INVALID_HMAC); mHasFocus = hasFocus; mInTouchMode = inTouchMode; } void FocusEvent::initialize(const FocusEvent& from) { InputEvent::initialize(from); mHasFocus = from.mHasFocus; mInTouchMode = from.mInTouchMode; } // --- CaptureEvent --- Loading
libs/input/InputTransport.cpp +6 −13 Original line number Diff line number Diff line Loading @@ -278,7 +278,6 @@ void InputMessage::getSanitizedCopy(InputMessage* msg) const { case InputMessage::Type::FOCUS: { msg->body.focus.eventId = body.focus.eventId; msg->body.focus.hasFocus = body.focus.hasFocus; msg->body.focus.inTouchMode = body.focus.inTouchMode; break; } case InputMessage::Type::CAPTURE: { Loading Loading @@ -622,13 +621,10 @@ status_t InputPublisher::publishMotionEvent( return mChannel->sendMessage(&msg); } status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus, bool inTouchMode) { status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus) { if (ATRACE_ENABLED()) { std::string message = StringPrintf("publishFocusEvent(inputChannel=%s, hasFocus=%s, inTouchMode=%s)", mChannel->getName().c_str(), toString(hasFocus), toString(inTouchMode)); std::string message = StringPrintf("publishFocusEvent(inputChannel=%s, hasFocus=%s)", mChannel->getName().c_str(), toString(hasFocus)); ATRACE_NAME(message.c_str()); } Loading @@ -637,7 +633,6 @@ status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool h msg.header.seq = seq; msg.body.focus.eventId = eventId; msg.body.focus.hasFocus = hasFocus; msg.body.focus.inTouchMode = inTouchMode; return mChannel->sendMessage(&msg); } Loading Loading @@ -1371,8 +1366,7 @@ void InputConsumer::initializeKeyEvent(KeyEvent* event, const InputMessage* msg) } void InputConsumer::initializeFocusEvent(FocusEvent* event, const InputMessage* msg) { event->initialize(msg->body.focus.eventId, msg->body.focus.hasFocus, msg->body.focus.inTouchMode); event->initialize(msg->body.focus.eventId, msg->body.focus.hasFocus); } void InputConsumer::initializeCaptureEvent(CaptureEvent* event, const InputMessage* msg) { Loading Loading @@ -1491,9 +1485,8 @@ std::string InputConsumer::dump() const { break; } case InputMessage::Type::FOCUS: { out += android::base::StringPrintf("hasFocus=%s inTouchMode=%s", toString(msg.body.focus.hasFocus), toString(msg.body.focus.inTouchMode)); out += android::base::StringPrintf("hasFocus=%s", toString(msg.body.focus.hasFocus)); break; } case InputMessage::Type::CAPTURE: { Loading
libs/input/tests/InputPublisherAndConsumer_test.cpp +1 −3 Original line number Diff line number Diff line Loading @@ -290,10 +290,9 @@ void InputPublisherAndConsumerTest::PublishAndConsumeFocusEvent() { constexpr uint32_t seq = 15; int32_t eventId = InputEvent::nextId(); constexpr bool hasFocus = true; constexpr bool inTouchMode = true; const nsecs_t publishTime = systemTime(SYSTEM_TIME_MONOTONIC); status = mPublisher->publishFocusEvent(seq, eventId, hasFocus, inTouchMode); status = mPublisher->publishFocusEvent(seq, eventId, hasFocus); ASSERT_EQ(OK, status) << "publisher publishFocusEvent should return OK"; uint32_t consumeSeq; Loading @@ -309,7 +308,6 @@ void InputPublisherAndConsumerTest::PublishAndConsumeFocusEvent() { EXPECT_EQ(seq, consumeSeq); EXPECT_EQ(eventId, focusEvent->getId()); EXPECT_EQ(hasFocus, focusEvent->getHasFocus()); EXPECT_EQ(inTouchMode, focusEvent->getInTouchMode()); status = mConsumer->sendFinishedSignal(seq, true); ASSERT_EQ(OK, status) << "consumer sendFinishedSignal should return OK"; Loading