summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2021-03-06 00:23:24 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-03-06 00:23:24 +0000
commitc3435c0eced0d1769cb75f5f6f6a115ea1489bfc (patch)
tree4e84440789815d158b3a29f0e9fabca591aab907 /libs
parent7a3b698b7729da8b5e9af44401be2ad5e700c99c (diff)
parent38b7f7faaede3ad09c55d933e94d28366e2a1cdd (diff)
Merge "Use bool directly in InputMessage" into sc-dev
Diffstat (limited to 'libs')
-rw-r--r--libs/input/InputTransport.cpp16
-rw-r--r--libs/input/tests/StructLayout_test.cpp10
2 files changed, 16 insertions, 10 deletions
diff --git a/libs/input/InputTransport.cpp b/libs/input/InputTransport.cpp
index 1e47a3c3e6..ee2daec5fc 100644
--- a/libs/input/InputTransport.cpp
+++ b/libs/input/InputTransport.cpp
@@ -577,8 +577,8 @@ status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool h
msg.header.type = InputMessage::Type::FOCUS;
msg.header.seq = seq;
msg.body.focus.eventId = eventId;
- msg.body.focus.hasFocus = hasFocus ? 1 : 0;
- msg.body.focus.inTouchMode = inTouchMode ? 1 : 0;
+ msg.body.focus.hasFocus = hasFocus;
+ msg.body.focus.inTouchMode = inTouchMode;
return mChannel->sendMessage(&msg);
}
@@ -595,7 +595,7 @@ status_t InputPublisher::publishCaptureEvent(uint32_t seq, int32_t eventId,
msg.header.type = InputMessage::Type::CAPTURE;
msg.header.seq = seq;
msg.body.capture.eventId = eventId;
- msg.body.capture.pointerCaptureEnabled = pointerCaptureEnabled ? 1 : 0;
+ msg.body.capture.pointerCaptureEnabled = pointerCaptureEnabled;
return mChannel->sendMessage(&msg);
}
@@ -615,7 +615,7 @@ status_t InputPublisher::receiveFinishedSignal(
mChannel->getName().c_str(), NamedEnum::string(msg.header.type).c_str());
return UNKNOWN_ERROR;
}
- callback(msg.header.seq, msg.body.finished.handled == 1, msg.body.finished.consumeTime);
+ callback(msg.header.seq, msg.body.finished.handled, msg.body.finished.consumeTime);
return OK;
}
@@ -1168,7 +1168,7 @@ status_t InputConsumer::sendUnchainedFinishedSignal(uint32_t seq, bool handled)
InputMessage msg;
msg.header.type = InputMessage::Type::FINISHED;
msg.header.seq = seq;
- msg.body.finished.handled = handled ? 1 : 0;
+ msg.body.finished.handled = handled;
msg.body.finished.consumeTime = getConsumeTime(seq);
status_t result = mChannel->sendMessage(&msg);
if (result == OK) {
@@ -1228,12 +1228,12 @@ 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 == 1,
- msg->body.focus.inTouchMode == 1);
+ event->initialize(msg->body.focus.eventId, msg->body.focus.hasFocus,
+ msg->body.focus.inTouchMode);
}
void InputConsumer::initializeCaptureEvent(CaptureEvent* event, const InputMessage* msg) {
- event->initialize(msg->body.capture.eventId, msg->body.capture.pointerCaptureEnabled == 1);
+ event->initialize(msg->body.capture.eventId, msg->body.capture.pointerCaptureEnabled);
}
void InputConsumer::initializeMotionEvent(MotionEvent* event, const InputMessage* msg) {
diff --git a/libs/input/tests/StructLayout_test.cpp b/libs/input/tests/StructLayout_test.cpp
index a8865858d3..8f436085f7 100644
--- a/libs/input/tests/StructLayout_test.cpp
+++ b/libs/input/tests/StructLayout_test.cpp
@@ -49,6 +49,7 @@ void TestInputMessageAlignment() {
CHECK_OFFSET(InputMessage::Body::Key, downTime, 88);
CHECK_OFFSET(InputMessage::Body::Motion, eventId, 0);
+ CHECK_OFFSET(InputMessage::Body::Motion, empty1, 4);
CHECK_OFFSET(InputMessage::Body::Motion, eventTime, 8);
CHECK_OFFSET(InputMessage::Body::Motion, deviceId, 16);
CHECK_OFFSET(InputMessage::Body::Motion, source, 20);
@@ -60,6 +61,7 @@ void TestInputMessageAlignment() {
CHECK_OFFSET(InputMessage::Body::Motion, metaState, 72);
CHECK_OFFSET(InputMessage::Body::Motion, buttonState, 76);
CHECK_OFFSET(InputMessage::Body::Motion, classification, 80);
+ CHECK_OFFSET(InputMessage::Body::Motion, empty2, 81);
CHECK_OFFSET(InputMessage::Body::Motion, edgeFlags, 84);
CHECK_OFFSET(InputMessage::Body::Motion, downTime, 88);
CHECK_OFFSET(InputMessage::Body::Motion, dsdx, 96);
@@ -73,16 +75,20 @@ void TestInputMessageAlignment() {
CHECK_OFFSET(InputMessage::Body::Motion, xCursorPosition, 128);
CHECK_OFFSET(InputMessage::Body::Motion, yCursorPosition, 132);
CHECK_OFFSET(InputMessage::Body::Motion, pointerCount, 136);
+ CHECK_OFFSET(InputMessage::Body::Motion, empty3, 140);
CHECK_OFFSET(InputMessage::Body::Motion, pointers, 144);
CHECK_OFFSET(InputMessage::Body::Focus, eventId, 0);
CHECK_OFFSET(InputMessage::Body::Focus, hasFocus, 4);
- CHECK_OFFSET(InputMessage::Body::Focus, inTouchMode, 6);
+ CHECK_OFFSET(InputMessage::Body::Focus, inTouchMode, 5);
+ CHECK_OFFSET(InputMessage::Body::Focus, empty, 6);
CHECK_OFFSET(InputMessage::Body::Capture, eventId, 0);
CHECK_OFFSET(InputMessage::Body::Capture, pointerCaptureEnabled, 4);
+ CHECK_OFFSET(InputMessage::Body::Capture, empty, 5);
- CHECK_OFFSET(InputMessage::Body::Finished, handled, 4);
+ CHECK_OFFSET(InputMessage::Body::Finished, handled, 0);
+ CHECK_OFFSET(InputMessage::Body::Finished, empty, 1);
CHECK_OFFSET(InputMessage::Body::Finished, consumeTime, 8);
}