Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2010 The Android Open Source Project |
| 3 | // |
| 4 | // Provides a shared memory transport for input events. |
| 5 | // |
| 6 | #define LOG_TAG "InputTransport" |
Zim | d8402b6 | 2023-06-02 11:56:26 +0100 | [diff] [blame] | 7 | #define ATRACE_TAG ATRACE_TAG_INPUT |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 8 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 9 | #include <errno.h> |
| 10 | #include <fcntl.h> |
Michael Wright | d0a4a62 | 2014-06-09 19:03:32 -0700 | [diff] [blame] | 11 | #include <inttypes.h> |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 12 | #include <math.h> |
Egor Pasko | a0d32af | 2023-12-14 17:45:41 +0100 | [diff] [blame] | 13 | #include <poll.h> |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 14 | #include <sys/socket.h> |
Mark Salyzyn | a5e161b | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 15 | #include <sys/types.h> |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 16 | #include <unistd.h> |
| 17 | |
Siarhei Vishniakou | 5c02a71 | 2023-05-15 15:45:02 -0700 | [diff] [blame] | 18 | #include <android-base/logging.h> |
Prabir Pradhan | b2bd83c | 2023-02-23 02:34:40 +0000 | [diff] [blame] | 19 | #include <android-base/properties.h> |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 20 | #include <android-base/stringprintf.h> |
| 21 | #include <binder/Parcel.h> |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 22 | #include <cutils/properties.h> |
Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 23 | #include <ftl/enum.h> |
Mark Salyzyn | 7823e12 | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 24 | #include <log/log.h> |
Michael Wright | 3dd60e2 | 2019-03-27 22:06:44 +0000 | [diff] [blame] | 25 | #include <utils/Trace.h> |
Mark Salyzyn | 7823e12 | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 26 | |
Siarhei Vishniakou | 9681896 | 2023-08-23 10:19:02 -0700 | [diff] [blame] | 27 | #include <com_android_input_flags.h> |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 28 | #include <input/InputTransport.h> |
Siarhei Vishniakou | 6c1e622 | 2024-03-07 13:39:24 -0800 | [diff] [blame] | 29 | #include <input/PrintTools.h> |
Prabir Pradhan | a37bad1 | 2023-08-18 15:55:32 +0000 | [diff] [blame] | 30 | #include <input/TraceTools.h> |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 31 | |
Siarhei Vishniakou | 9681896 | 2023-08-23 10:19:02 -0700 | [diff] [blame] | 32 | namespace input_flags = com::android::input::flags; |
| 33 | |
Siarhei Vishniakou | 9dbf637 | 2024-03-06 16:08:01 -0800 | [diff] [blame] | 34 | namespace android { |
| 35 | |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 36 | namespace { |
| 37 | |
| 38 | /** |
| 39 | * Log debug messages about channel messages (send message, receive message). |
| 40 | * Enable this via "adb shell setprop log.tag.InputTransportMessages DEBUG" |
| 41 | * (requires restart) |
| 42 | */ |
| 43 | const bool DEBUG_CHANNEL_MESSAGES = |
| 44 | __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Messages", ANDROID_LOG_INFO); |
| 45 | |
| 46 | /** |
| 47 | * Log debug messages whenever InputChannel objects are created/destroyed. |
| 48 | * Enable this via "adb shell setprop log.tag.InputTransportLifecycle DEBUG" |
| 49 | * (requires restart) |
| 50 | */ |
| 51 | const bool DEBUG_CHANNEL_LIFECYCLE = |
| 52 | __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Lifecycle", ANDROID_LOG_INFO); |
| 53 | |
Prabir Pradhan | b2bd83c | 2023-02-23 02:34:40 +0000 | [diff] [blame] | 54 | const bool IS_DEBUGGABLE_BUILD = |
| 55 | #if defined(__ANDROID__) |
| 56 | android::base::GetBoolProperty("ro.debuggable", false); |
| 57 | #else |
| 58 | true; |
| 59 | #endif |
| 60 | |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 61 | /** |
| 62 | * Log debug messages relating to the producer end of the transport channel. |
Prabir Pradhan | b2bd83c | 2023-02-23 02:34:40 +0000 | [diff] [blame] | 63 | * Enable this via "adb shell setprop log.tag.InputTransportPublisher DEBUG". |
| 64 | * This requires a restart on non-debuggable (e.g. user) builds, but should take effect immediately |
| 65 | * on debuggable builds (e.g. userdebug). |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 66 | */ |
Prabir Pradhan | b2bd83c | 2023-02-23 02:34:40 +0000 | [diff] [blame] | 67 | bool debugTransportPublisher() { |
| 68 | if (!IS_DEBUGGABLE_BUILD) { |
| 69 | static const bool DEBUG_TRANSPORT_PUBLISHER = |
| 70 | __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Publisher", ANDROID_LOG_INFO); |
| 71 | return DEBUG_TRANSPORT_PUBLISHER; |
| 72 | } |
| 73 | return __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "Publisher", ANDROID_LOG_INFO); |
| 74 | } |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 75 | |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 76 | android::base::unique_fd dupChannelFd(int fd) { |
| 77 | android::base::unique_fd newFd(::dup(fd)); |
| 78 | if (!newFd.ok()) { |
| 79 | ALOGE("Could not duplicate fd %i : %s", fd, strerror(errno)); |
| 80 | const bool hitFdLimit = errno == EMFILE || errno == ENFILE; |
| 81 | // If this process is out of file descriptors, then throwing that might end up exploding |
| 82 | // on the other side of a binder call, which isn't really helpful. |
| 83 | // Better to just crash here and hope that the FD leak is slow. |
| 84 | // Other failures could be client errors, so we still propagate those back to the caller. |
| 85 | LOG_ALWAYS_FATAL_IF(hitFdLimit, "Too many open files, could not duplicate input channel"); |
| 86 | return {}; |
| 87 | } |
| 88 | return newFd; |
| 89 | } |
| 90 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 91 | // Socket buffer size. The default is typically about 128KB, which is much larger than |
| 92 | // we really need. So we make it smaller. It just needs to be big enough to hold |
| 93 | // a few dozen large multi-finger motion events in the case where an application gets |
| 94 | // behind processing touches. |
Siarhei Vishniakou | 0438ca8 | 2024-03-12 14:27:25 -0700 | [diff] [blame] | 95 | constexpr size_t SOCKET_BUFFER_SIZE = 32 * 1024; |
Siarhei Vishniakou | b5433e9 | 2019-02-21 09:27:39 -0600 | [diff] [blame] | 96 | |
Siarhei Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 97 | /** |
| 98 | * Crash if the events that are getting sent to the InputPublisher are inconsistent. |
| 99 | * Enable this via "adb shell setprop log.tag.InputTransportVerifyEvents DEBUG" |
| 100 | */ |
Siarhei Vishniakou | 6c1e622 | 2024-03-07 13:39:24 -0800 | [diff] [blame] | 101 | bool verifyEvents() { |
Siarhei Vishniakou | 9681896 | 2023-08-23 10:19:02 -0700 | [diff] [blame] | 102 | return input_flags::enable_outbound_event_verification() || |
| 103 | __android_log_is_loggable(ANDROID_LOG_DEBUG, LOG_TAG "VerifyEvents", ANDROID_LOG_INFO); |
Siarhei Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 104 | } |
| 105 | |
Siarhei Vishniakou | 6c1e622 | 2024-03-07 13:39:24 -0800 | [diff] [blame] | 106 | } // namespace |
| 107 | |
| 108 | using android::base::Result; |
| 109 | using android::base::StringPrintf; |
| 110 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 111 | // --- InputMessage --- |
| 112 | |
| 113 | bool InputMessage::isValid(size_t actualSize) const { |
Siarhei Vishniakou | dbdb673 | 2021-04-26 19:40:26 +0000 | [diff] [blame] | 114 | if (size() != actualSize) { |
| 115 | ALOGE("Received message of incorrect size %zu (expected %zu)", actualSize, size()); |
| 116 | return false; |
| 117 | } |
| 118 | |
| 119 | switch (header.type) { |
| 120 | case Type::KEY: |
| 121 | return true; |
| 122 | case Type::MOTION: { |
| 123 | const bool valid = |
| 124 | body.motion.pointerCount > 0 && body.motion.pointerCount <= MAX_POINTERS; |
| 125 | if (!valid) { |
| 126 | ALOGE("Received invalid MOTION: pointerCount = %" PRIu32, body.motion.pointerCount); |
| 127 | } |
| 128 | return valid; |
| 129 | } |
| 130 | case Type::FINISHED: |
| 131 | case Type::FOCUS: |
| 132 | case Type::CAPTURE: |
| 133 | case Type::DRAG: |
Antonio Kantek | 7cdf8ef | 2021-07-13 18:04:53 -0700 | [diff] [blame] | 134 | case Type::TOUCH_MODE: |
Siarhei Vishniakou | dbdb673 | 2021-04-26 19:40:26 +0000 | [diff] [blame] | 135 | return true; |
| 136 | case Type::TIMELINE: { |
| 137 | const nsecs_t gpuCompletedTime = |
| 138 | body.timeline.graphicsTimeline[GraphicsTimeline::GPU_COMPLETED_TIME]; |
| 139 | const nsecs_t presentTime = |
| 140 | body.timeline.graphicsTimeline[GraphicsTimeline::PRESENT_TIME]; |
| 141 | const bool valid = presentTime > gpuCompletedTime; |
| 142 | if (!valid) { |
| 143 | ALOGE("Received invalid TIMELINE: gpuCompletedTime = %" PRId64 |
| 144 | " presentTime = %" PRId64, |
| 145 | gpuCompletedTime, presentTime); |
| 146 | } |
| 147 | return valid; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 148 | } |
| 149 | } |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 150 | ALOGE("Invalid message type: %s", ftl::enum_string(header.type).c_str()); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 151 | return false; |
| 152 | } |
| 153 | |
| 154 | size_t InputMessage::size() const { |
| 155 | switch (header.type) { |
Siarhei Vishniakou | 5240277 | 2019-10-22 09:32:30 -0700 | [diff] [blame] | 156 | case Type::KEY: |
| 157 | return sizeof(Header) + body.key.size(); |
| 158 | case Type::MOTION: |
| 159 | return sizeof(Header) + body.motion.size(); |
| 160 | case Type::FINISHED: |
| 161 | return sizeof(Header) + body.finished.size(); |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 162 | case Type::FOCUS: |
| 163 | return sizeof(Header) + body.focus.size(); |
Prabir Pradhan | 3f37b7b | 2020-11-10 16:50:18 -0800 | [diff] [blame] | 164 | case Type::CAPTURE: |
| 165 | return sizeof(Header) + body.capture.size(); |
arthurhung | 7632c33 | 2020-12-30 16:58:01 +0800 | [diff] [blame] | 166 | case Type::DRAG: |
| 167 | return sizeof(Header) + body.drag.size(); |
Siarhei Vishniakou | f94ae02 | 2021-02-04 01:23:17 +0000 | [diff] [blame] | 168 | case Type::TIMELINE: |
| 169 | return sizeof(Header) + body.timeline.size(); |
Antonio Kantek | 7cdf8ef | 2021-07-13 18:04:53 -0700 | [diff] [blame] | 170 | case Type::TOUCH_MODE: |
| 171 | return sizeof(Header) + body.touchMode.size(); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 172 | } |
| 173 | return sizeof(Header); |
| 174 | } |
| 175 | |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 176 | /** |
| 177 | * There could be non-zero bytes in-between InputMessage fields. Force-initialize the entire |
| 178 | * memory to zero, then only copy the valid bytes on a per-field basis. |
| 179 | */ |
| 180 | void InputMessage::getSanitizedCopy(InputMessage* msg) const { |
| 181 | memset(msg, 0, sizeof(*msg)); |
| 182 | |
| 183 | // Write the header |
| 184 | msg->header.type = header.type; |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 185 | msg->header.seq = header.seq; |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 186 | |
| 187 | // Write the body |
| 188 | switch(header.type) { |
Siarhei Vishniakou | 5240277 | 2019-10-22 09:32:30 -0700 | [diff] [blame] | 189 | case InputMessage::Type::KEY: { |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 190 | // int32_t eventId |
| 191 | msg->body.key.eventId = body.key.eventId; |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 192 | // nsecs_t eventTime |
| 193 | msg->body.key.eventTime = body.key.eventTime; |
| 194 | // int32_t deviceId |
| 195 | msg->body.key.deviceId = body.key.deviceId; |
| 196 | // int32_t source |
| 197 | msg->body.key.source = body.key.source; |
| 198 | // int32_t displayId |
| 199 | msg->body.key.displayId = body.key.displayId; |
Siarhei Vishniakou | 9c858ac | 2020-01-23 14:20:11 -0600 | [diff] [blame] | 200 | // std::array<uint8_t, 32> hmac |
| 201 | msg->body.key.hmac = body.key.hmac; |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 202 | // int32_t action |
| 203 | msg->body.key.action = body.key.action; |
| 204 | // int32_t flags |
| 205 | msg->body.key.flags = body.key.flags; |
| 206 | // int32_t keyCode |
| 207 | msg->body.key.keyCode = body.key.keyCode; |
| 208 | // int32_t scanCode |
| 209 | msg->body.key.scanCode = body.key.scanCode; |
| 210 | // int32_t metaState |
| 211 | msg->body.key.metaState = body.key.metaState; |
| 212 | // int32_t repeatCount |
| 213 | msg->body.key.repeatCount = body.key.repeatCount; |
| 214 | // nsecs_t downTime |
| 215 | msg->body.key.downTime = body.key.downTime; |
| 216 | break; |
| 217 | } |
Siarhei Vishniakou | 5240277 | 2019-10-22 09:32:30 -0700 | [diff] [blame] | 218 | case InputMessage::Type::MOTION: { |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 219 | // int32_t eventId |
| 220 | msg->body.motion.eventId = body.motion.eventId; |
Prabir Pradhan | b9b1850 | 2021-08-26 12:30:32 -0700 | [diff] [blame] | 221 | // uint32_t pointerCount |
| 222 | msg->body.motion.pointerCount = body.motion.pointerCount; |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 223 | // nsecs_t eventTime |
| 224 | msg->body.motion.eventTime = body.motion.eventTime; |
| 225 | // int32_t deviceId |
| 226 | msg->body.motion.deviceId = body.motion.deviceId; |
| 227 | // int32_t source |
| 228 | msg->body.motion.source = body.motion.source; |
| 229 | // int32_t displayId |
| 230 | msg->body.motion.displayId = body.motion.displayId; |
Siarhei Vishniakou | 9c858ac | 2020-01-23 14:20:11 -0600 | [diff] [blame] | 231 | // std::array<uint8_t, 32> hmac |
| 232 | msg->body.motion.hmac = body.motion.hmac; |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 233 | // int32_t action |
| 234 | msg->body.motion.action = body.motion.action; |
| 235 | // int32_t actionButton |
| 236 | msg->body.motion.actionButton = body.motion.actionButton; |
| 237 | // int32_t flags |
| 238 | msg->body.motion.flags = body.motion.flags; |
| 239 | // int32_t metaState |
| 240 | msg->body.motion.metaState = body.motion.metaState; |
| 241 | // int32_t buttonState |
| 242 | msg->body.motion.buttonState = body.motion.buttonState; |
Siarhei Vishniakou | 16a2e30 | 2019-01-14 19:21:45 -0800 | [diff] [blame] | 243 | // MotionClassification classification |
| 244 | msg->body.motion.classification = body.motion.classification; |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 245 | // int32_t edgeFlags |
| 246 | msg->body.motion.edgeFlags = body.motion.edgeFlags; |
| 247 | // nsecs_t downTime |
| 248 | msg->body.motion.downTime = body.motion.downTime; |
chaviw | 9eaa22c | 2020-07-01 16:21:27 -0700 | [diff] [blame] | 249 | |
| 250 | msg->body.motion.dsdx = body.motion.dsdx; |
| 251 | msg->body.motion.dtdx = body.motion.dtdx; |
| 252 | msg->body.motion.dtdy = body.motion.dtdy; |
| 253 | msg->body.motion.dsdy = body.motion.dsdy; |
| 254 | msg->body.motion.tx = body.motion.tx; |
| 255 | msg->body.motion.ty = body.motion.ty; |
| 256 | |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 257 | // float xPrecision |
| 258 | msg->body.motion.xPrecision = body.motion.xPrecision; |
| 259 | // float yPrecision |
| 260 | msg->body.motion.yPrecision = body.motion.yPrecision; |
Garfield Tan | 00f511d | 2019-06-12 16:55:40 -0700 | [diff] [blame] | 261 | // float xCursorPosition |
| 262 | msg->body.motion.xCursorPosition = body.motion.xCursorPosition; |
| 263 | // float yCursorPosition |
| 264 | msg->body.motion.yCursorPosition = body.motion.yCursorPosition; |
Prabir Pradhan | b9b1850 | 2021-08-26 12:30:32 -0700 | [diff] [blame] | 265 | |
| 266 | msg->body.motion.dsdxRaw = body.motion.dsdxRaw; |
| 267 | msg->body.motion.dtdxRaw = body.motion.dtdxRaw; |
| 268 | msg->body.motion.dtdyRaw = body.motion.dtdyRaw; |
| 269 | msg->body.motion.dsdyRaw = body.motion.dsdyRaw; |
| 270 | msg->body.motion.txRaw = body.motion.txRaw; |
| 271 | msg->body.motion.tyRaw = body.motion.tyRaw; |
| 272 | |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 273 | //struct Pointer pointers[MAX_POINTERS] |
| 274 | for (size_t i = 0; i < body.motion.pointerCount; i++) { |
| 275 | // PointerProperties properties |
| 276 | msg->body.motion.pointers[i].properties.id = body.motion.pointers[i].properties.id; |
| 277 | msg->body.motion.pointers[i].properties.toolType = |
| 278 | body.motion.pointers[i].properties.toolType, |
| 279 | // PointerCoords coords |
| 280 | msg->body.motion.pointers[i].coords.bits = body.motion.pointers[i].coords.bits; |
| 281 | const uint32_t count = BitSet64::count(body.motion.pointers[i].coords.bits); |
| 282 | memcpy(&msg->body.motion.pointers[i].coords.values[0], |
| 283 | &body.motion.pointers[i].coords.values[0], |
| 284 | count * (sizeof(body.motion.pointers[i].coords.values[0]))); |
Philip Quinn | afb3128 | 2022-12-20 18:17:55 -0800 | [diff] [blame] | 285 | msg->body.motion.pointers[i].coords.isResampled = |
| 286 | body.motion.pointers[i].coords.isResampled; |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 287 | } |
| 288 | break; |
| 289 | } |
Siarhei Vishniakou | 5240277 | 2019-10-22 09:32:30 -0700 | [diff] [blame] | 290 | case InputMessage::Type::FINISHED: { |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 291 | msg->body.finished.handled = body.finished.handled; |
Siarhei Vishniakou | 3531ae7 | 2021-02-02 12:12:27 -1000 | [diff] [blame] | 292 | msg->body.finished.consumeTime = body.finished.consumeTime; |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 293 | break; |
| 294 | } |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 295 | case InputMessage::Type::FOCUS: { |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 296 | msg->body.focus.eventId = body.focus.eventId; |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 297 | msg->body.focus.hasFocus = body.focus.hasFocus; |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 298 | break; |
| 299 | } |
Prabir Pradhan | 3f37b7b | 2020-11-10 16:50:18 -0800 | [diff] [blame] | 300 | case InputMessage::Type::CAPTURE: { |
| 301 | msg->body.capture.eventId = body.capture.eventId; |
| 302 | msg->body.capture.pointerCaptureEnabled = body.capture.pointerCaptureEnabled; |
| 303 | break; |
| 304 | } |
arthurhung | 7632c33 | 2020-12-30 16:58:01 +0800 | [diff] [blame] | 305 | case InputMessage::Type::DRAG: { |
| 306 | msg->body.drag.eventId = body.drag.eventId; |
| 307 | msg->body.drag.x = body.drag.x; |
| 308 | msg->body.drag.y = body.drag.y; |
| 309 | msg->body.drag.isExiting = body.drag.isExiting; |
| 310 | break; |
| 311 | } |
Siarhei Vishniakou | f94ae02 | 2021-02-04 01:23:17 +0000 | [diff] [blame] | 312 | case InputMessage::Type::TIMELINE: { |
| 313 | msg->body.timeline.eventId = body.timeline.eventId; |
| 314 | msg->body.timeline.graphicsTimeline = body.timeline.graphicsTimeline; |
| 315 | break; |
| 316 | } |
Antonio Kantek | 7cdf8ef | 2021-07-13 18:04:53 -0700 | [diff] [blame] | 317 | case InputMessage::Type::TOUCH_MODE: { |
| 318 | msg->body.touchMode.eventId = body.touchMode.eventId; |
| 319 | msg->body.touchMode.isInTouchMode = body.touchMode.isInTouchMode; |
| 320 | } |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 321 | } |
| 322 | } |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 323 | |
| 324 | // --- InputChannel --- |
| 325 | |
Siarhei Vishniakou | d258827 | 2020-07-10 11:15:40 -0500 | [diff] [blame] | 326 | std::unique_ptr<InputChannel> InputChannel::create(const std::string& name, |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 327 | android::base::unique_fd fd, sp<IBinder> token) { |
Josh Gao | 2ccbe3a | 2019-08-09 14:35:36 -0700 | [diff] [blame] | 328 | const int result = fcntl(fd, F_SETFL, O_NONBLOCK); |
| 329 | if (result != 0) { |
| 330 | LOG_ALWAYS_FATAL("channel '%s' ~ Could not make socket non-blocking: %s", name.c_str(), |
| 331 | strerror(errno)); |
| 332 | return nullptr; |
| 333 | } |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 334 | // using 'new' to access a non-public constructor |
Siarhei Vishniakou | d258827 | 2020-07-10 11:15:40 -0500 | [diff] [blame] | 335 | return std::unique_ptr<InputChannel>(new InputChannel(name, std::move(fd), token)); |
Josh Gao | 2ccbe3a | 2019-08-09 14:35:36 -0700 | [diff] [blame] | 336 | } |
| 337 | |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 338 | std::unique_ptr<InputChannel> InputChannel::create( |
| 339 | android::os::InputChannelCore&& parceledChannel) { |
| 340 | return InputChannel::create(parceledChannel.name, parceledChannel.fd.release(), |
| 341 | parceledChannel.token); |
| 342 | } |
| 343 | |
| 344 | InputChannel::InputChannel(const std::string name, android::base::unique_fd fd, sp<IBinder> token) { |
| 345 | this->name = std::move(name); |
| 346 | this->fd.reset(std::move(fd)); |
| 347 | this->token = std::move(token); |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 348 | ALOGD_IF(DEBUG_CHANNEL_LIFECYCLE, "Input channel constructed: name='%s', fd=%d", |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 349 | getName().c_str(), getFd()); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 350 | } |
| 351 | |
| 352 | InputChannel::~InputChannel() { |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 353 | ALOGD_IF(DEBUG_CHANNEL_LIFECYCLE, "Input channel destroyed: name='%s', fd=%d", |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 354 | getName().c_str(), getFd()); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 355 | } |
| 356 | |
Siarhei Vishniakou | f93fcf4 | 2017-11-22 16:00:14 -0800 | [diff] [blame] | 357 | status_t InputChannel::openInputChannelPair(const std::string& name, |
Siarhei Vishniakou | d258827 | 2020-07-10 11:15:40 -0500 | [diff] [blame] | 358 | std::unique_ptr<InputChannel>& outServerChannel, |
| 359 | std::unique_ptr<InputChannel>& outClientChannel) { |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 360 | int sockets[2]; |
| 361 | if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, sockets)) { |
| 362 | status_t result = -errno; |
Siarhei Vishniakou | 09b02ac | 2021-04-14 22:24:04 +0000 | [diff] [blame] | 363 | ALOGE("channel '%s' ~ Could not create socket pair. errno=%s(%d)", name.c_str(), |
| 364 | strerror(errno), errno); |
Siarhei Vishniakou | ce5ab08 | 2020-07-09 17:03:21 -0500 | [diff] [blame] | 365 | outServerChannel.reset(); |
| 366 | outClientChannel.reset(); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 367 | return result; |
| 368 | } |
| 369 | |
| 370 | int bufferSize = SOCKET_BUFFER_SIZE; |
| 371 | setsockopt(sockets[0], SOL_SOCKET, SO_SNDBUF, &bufferSize, sizeof(bufferSize)); |
| 372 | setsockopt(sockets[0], SOL_SOCKET, SO_RCVBUF, &bufferSize, sizeof(bufferSize)); |
| 373 | setsockopt(sockets[1], SOL_SOCKET, SO_SNDBUF, &bufferSize, sizeof(bufferSize)); |
| 374 | setsockopt(sockets[1], SOL_SOCKET, SO_RCVBUF, &bufferSize, sizeof(bufferSize)); |
| 375 | |
Siarhei Vishniakou | 4c155eb | 2023-06-30 11:47:12 -0700 | [diff] [blame] | 376 | sp<IBinder> token = sp<BBinder>::make(); |
Siarhei Vishniakou | 26d3cfb | 2019-10-15 17:02:32 -0700 | [diff] [blame] | 377 | |
Josh Gao | 2ccbe3a | 2019-08-09 14:35:36 -0700 | [diff] [blame] | 378 | std::string serverChannelName = name + " (server)"; |
| 379 | android::base::unique_fd serverFd(sockets[0]); |
Siarhei Vishniakou | 26d3cfb | 2019-10-15 17:02:32 -0700 | [diff] [blame] | 380 | outServerChannel = InputChannel::create(serverChannelName, std::move(serverFd), token); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 381 | |
Josh Gao | 2ccbe3a | 2019-08-09 14:35:36 -0700 | [diff] [blame] | 382 | std::string clientChannelName = name + " (client)"; |
| 383 | android::base::unique_fd clientFd(sockets[1]); |
Siarhei Vishniakou | 26d3cfb | 2019-10-15 17:02:32 -0700 | [diff] [blame] | 384 | outClientChannel = InputChannel::create(clientChannelName, std::move(clientFd), token); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 385 | return OK; |
| 386 | } |
| 387 | |
| 388 | status_t InputChannel::sendMessage(const InputMessage* msg) { |
Prabir Pradhan | 2dac8b8 | 2023-09-06 01:11:51 +0000 | [diff] [blame] | 389 | ATRACE_NAME_IF(ATRACE_ENABLED(), |
Harry Cutts | c57cd3c | 2024-04-24 13:52:55 +0000 | [diff] [blame] | 390 | StringPrintf("sendMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=%s)", |
| 391 | name.c_str(), msg->header.seq, |
| 392 | ftl::enum_string(msg->header.type).c_str())); |
Siarhei Vishniakou | 1f7c0e4 | 2018-11-16 22:18:53 -0800 | [diff] [blame] | 393 | const size_t msgLength = msg->size(); |
| 394 | InputMessage cleanMsg; |
| 395 | msg->getSanitizedCopy(&cleanMsg); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 396 | ssize_t nWrite; |
| 397 | do { |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 398 | nWrite = ::send(getFd(), &cleanMsg, msgLength, MSG_DONTWAIT | MSG_NOSIGNAL); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 399 | } while (nWrite == -1 && errno == EINTR); |
| 400 | |
| 401 | if (nWrite < 0) { |
| 402 | int error = errno; |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 403 | ALOGD_IF(DEBUG_CHANNEL_MESSAGES, "channel '%s' ~ error sending message of type %s, %s", |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 404 | name.c_str(), ftl::enum_string(msg->header.type).c_str(), strerror(error)); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 405 | if (error == EAGAIN || error == EWOULDBLOCK) { |
| 406 | return WOULD_BLOCK; |
| 407 | } |
| 408 | if (error == EPIPE || error == ENOTCONN || error == ECONNREFUSED || error == ECONNRESET) { |
| 409 | return DEAD_OBJECT; |
| 410 | } |
| 411 | return -error; |
| 412 | } |
| 413 | |
| 414 | if (size_t(nWrite) != msgLength) { |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 415 | ALOGD_IF(DEBUG_CHANNEL_MESSAGES, |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 416 | "channel '%s' ~ error sending message type %s, send was incomplete", name.c_str(), |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 417 | ftl::enum_string(msg->header.type).c_str()); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 418 | return DEAD_OBJECT; |
| 419 | } |
| 420 | |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 421 | ALOGD_IF(DEBUG_CHANNEL_MESSAGES, "channel '%s' ~ sent message of type %s", name.c_str(), |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 422 | ftl::enum_string(msg->header.type).c_str()); |
Zim | d8402b6 | 2023-06-02 11:56:26 +0100 | [diff] [blame] | 423 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 424 | return OK; |
| 425 | } |
| 426 | |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 427 | android::base::Result<InputMessage> InputChannel::receiveMessage() { |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 428 | ssize_t nRead; |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 429 | InputMessage msg; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 430 | do { |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 431 | nRead = ::recv(getFd(), &msg, sizeof(InputMessage), MSG_DONTWAIT); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 432 | } while (nRead == -1 && errno == EINTR); |
| 433 | |
| 434 | if (nRead < 0) { |
| 435 | int error = errno; |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 436 | ALOGD_IF(DEBUG_CHANNEL_MESSAGES, "channel '%s' ~ receive message failed, errno=%d", |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 437 | name.c_str(), errno); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 438 | if (error == EAGAIN || error == EWOULDBLOCK) { |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 439 | return android::base::Error(WOULD_BLOCK); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 440 | } |
| 441 | if (error == EPIPE || error == ENOTCONN || error == ECONNREFUSED) { |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 442 | return android::base::Error(DEAD_OBJECT); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 443 | } |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 444 | return android::base::Error(-error); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | if (nRead == 0) { // check for EOF |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 448 | ALOGD_IF(DEBUG_CHANNEL_MESSAGES, |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 449 | "channel '%s' ~ receive message failed because peer was closed", name.c_str()); |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 450 | return android::base::Error(DEAD_OBJECT); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 451 | } |
| 452 | |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 453 | if (!msg.isValid(nRead)) { |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 454 | ALOGE("channel '%s' ~ received invalid message of size %zd", name.c_str(), nRead); |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 455 | return android::base::Error(BAD_VALUE); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 456 | } |
| 457 | |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 458 | ALOGD_IF(DEBUG_CHANNEL_MESSAGES, "channel '%s' ~ received message of type %s", name.c_str(), |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 459 | ftl::enum_string(msg.header.type).c_str()); |
Zim | d8402b6 | 2023-06-02 11:56:26 +0100 | [diff] [blame] | 460 | if (ATRACE_ENABLED()) { |
Prabir Pradhan | a37bad1 | 2023-08-18 15:55:32 +0000 | [diff] [blame] | 461 | // Add an additional trace point to include data about the received message. |
Harry Cutts | c57cd3c | 2024-04-24 13:52:55 +0000 | [diff] [blame] | 462 | std::string message = |
| 463 | StringPrintf("receiveMessage(inputChannel=%s, seq=0x%" PRIx32 ", type=%s)", |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 464 | name.c_str(), msg.header.seq, |
| 465 | ftl::enum_string(msg.header.type).c_str()); |
Zim | d8402b6 | 2023-06-02 11:56:26 +0100 | [diff] [blame] | 466 | ATRACE_NAME(message.c_str()); |
| 467 | } |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 468 | return msg; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 469 | } |
| 470 | |
Egor Pasko | a0d32af | 2023-12-14 17:45:41 +0100 | [diff] [blame] | 471 | bool InputChannel::probablyHasInput() const { |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 472 | struct pollfd pfds = {.fd = fd.get(), .events = POLLIN}; |
Egor Pasko | a0d32af | 2023-12-14 17:45:41 +0100 | [diff] [blame] | 473 | if (::poll(&pfds, /*nfds=*/1, /*timeout=*/0) <= 0) { |
Egor Pasko | 5a67a56 | 2024-01-16 16:46:45 +0100 | [diff] [blame] | 474 | // This can be a false negative because EINTR and ENOMEM are not handled. The latter should |
| 475 | // be extremely rare. The EINTR is also unlikely because it happens only when the signal |
| 476 | // arrives while the syscall is executed, and the syscall is quick. Hitting EINTR too often |
Egor Pasko | a0d32af | 2023-12-14 17:45:41 +0100 | [diff] [blame] | 477 | // would be a sign of having too many signals, which is a bigger performance problem. A |
Egor Pasko | 5a67a56 | 2024-01-16 16:46:45 +0100 | [diff] [blame] | 478 | // common tradition is to repeat the syscall on each EINTR, but it is not necessary here. |
Egor Pasko | a0d32af | 2023-12-14 17:45:41 +0100 | [diff] [blame] | 479 | // In other words, the missing one liner is replaced by a multiline explanation. |
| 480 | return false; |
| 481 | } |
| 482 | // From poll(2): The bits returned in |revents| can include any of those specified in |events|, |
| 483 | // or one of the values POLLERR, POLLHUP, or POLLNVAL. |
| 484 | return (pfds.revents & POLLIN) != 0; |
| 485 | } |
| 486 | |
Egor Pasko | 5a67a56 | 2024-01-16 16:46:45 +0100 | [diff] [blame] | 487 | void InputChannel::waitForMessage(std::chrono::milliseconds timeout) const { |
| 488 | if (timeout < 0ms) { |
| 489 | LOG(FATAL) << "Timeout cannot be negative, received " << timeout.count(); |
| 490 | } |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 491 | struct pollfd pfds = {.fd = fd.get(), .events = POLLIN}; |
Egor Pasko | 5a67a56 | 2024-01-16 16:46:45 +0100 | [diff] [blame] | 492 | int ret; |
| 493 | std::chrono::time_point<std::chrono::steady_clock> stopTime = |
| 494 | std::chrono::steady_clock::now() + timeout; |
| 495 | std::chrono::milliseconds remaining = timeout; |
| 496 | do { |
| 497 | ret = ::poll(&pfds, /*nfds=*/1, /*timeout=*/remaining.count()); |
| 498 | remaining = std::chrono::duration_cast<std::chrono::milliseconds>( |
| 499 | stopTime - std::chrono::steady_clock::now()); |
| 500 | } while (ret == -1 && errno == EINTR && remaining > 0ms); |
| 501 | } |
| 502 | |
Siarhei Vishniakou | d258827 | 2020-07-10 11:15:40 -0500 | [diff] [blame] | 503 | std::unique_ptr<InputChannel> InputChannel::dup() const { |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 504 | base::unique_fd newFd(dupChannelFd(fd.get())); |
Chris Ye | 0783e99 | 2020-06-02 21:34:49 -0700 | [diff] [blame] | 505 | return InputChannel::create(getName(), std::move(newFd), getConnectionToken()); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 506 | } |
| 507 | |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 508 | void InputChannel::copyTo(android::os::InputChannelCore& outChannel) const { |
| 509 | outChannel.name = getName(); |
| 510 | outChannel.fd.reset(dupChannelFd(fd.get())); |
| 511 | outChannel.token = getConnectionToken(); |
Robert Carr | 3720ed0 | 2018-08-08 16:08:27 -0700 | [diff] [blame] | 512 | } |
| 513 | |
Siarhei Vishniakou | 7b9f4f5 | 2024-02-02 13:07:16 -0800 | [diff] [blame] | 514 | void InputChannel::moveChannel(std::unique_ptr<InputChannel> from, |
| 515 | android::os::InputChannelCore& outChannel) { |
| 516 | outChannel.name = from->getName(); |
| 517 | outChannel.fd = android::os::ParcelFileDescriptor(std::move(from->fd)); |
| 518 | outChannel.token = from->getConnectionToken(); |
| 519 | } |
| 520 | |
Siarhei Vishniakou | 26d3cfb | 2019-10-15 17:02:32 -0700 | [diff] [blame] | 521 | sp<IBinder> InputChannel::getConnectionToken() const { |
Siarhei Vishniakou | 8d66013 | 2024-01-11 16:48:44 -0800 | [diff] [blame] | 522 | return token; |
Garfield Tan | 1560166 | 2020-09-22 15:32:38 -0700 | [diff] [blame] | 523 | } |
| 524 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 525 | // --- InputPublisher --- |
| 526 | |
Siarhei Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 527 | InputPublisher::InputPublisher(const std::shared_ptr<InputChannel>& channel) |
Siarhei Vishniakou | 7b9f4f5 | 2024-02-02 13:07:16 -0800 | [diff] [blame] | 528 | : mChannel(channel), mInputVerifier(mChannel->getName()) {} |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 529 | |
| 530 | InputPublisher::~InputPublisher() { |
| 531 | } |
| 532 | |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 533 | status_t InputPublisher::publishKeyEvent(uint32_t seq, int32_t eventId, int32_t deviceId, |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 534 | int32_t source, ui::LogicalDisplayId displayId, |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 535 | std::array<uint8_t, 32> hmac, int32_t action, |
| 536 | int32_t flags, int32_t keyCode, int32_t scanCode, |
| 537 | int32_t metaState, int32_t repeatCount, nsecs_t downTime, |
| 538 | nsecs_t eventTime) { |
Prabir Pradhan | 2dac8b8 | 2023-09-06 01:11:51 +0000 | [diff] [blame] | 539 | ATRACE_NAME_IF(ATRACE_ENABLED(), |
| 540 | StringPrintf("publishKeyEvent(inputChannel=%s, action=%s, keyCode=%s)", |
| 541 | mChannel->getName().c_str(), KeyEvent::actionToString(action), |
| 542 | KeyEvent::getLabel(keyCode))); |
Prabir Pradhan | b2bd83c | 2023-02-23 02:34:40 +0000 | [diff] [blame] | 543 | ALOGD_IF(debugTransportPublisher(), |
Prabir Pradhan | 96282b0 | 2023-02-24 22:36:17 +0000 | [diff] [blame] | 544 | "channel '%s' publisher ~ %s: seq=%u, id=%d, deviceId=%d, source=%s, " |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 545 | "action=%s, flags=0x%x, keyCode=%s, scanCode=%d, metaState=0x%x, repeatCount=%d," |
| 546 | "downTime=%" PRId64 ", eventTime=%" PRId64, |
Prabir Pradhan | 96282b0 | 2023-02-24 22:36:17 +0000 | [diff] [blame] | 547 | mChannel->getName().c_str(), __func__, seq, eventId, deviceId, |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 548 | inputEventSourceToString(source).c_str(), KeyEvent::actionToString(action), flags, |
| 549 | KeyEvent::getLabel(keyCode), scanCode, metaState, repeatCount, downTime, eventTime); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 550 | |
| 551 | if (!seq) { |
| 552 | ALOGE("Attempted to publish a key event with sequence number 0."); |
| 553 | return BAD_VALUE; |
| 554 | } |
| 555 | |
| 556 | InputMessage msg; |
Siarhei Vishniakou | 5240277 | 2019-10-22 09:32:30 -0700 | [diff] [blame] | 557 | msg.header.type = InputMessage::Type::KEY; |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 558 | msg.header.seq = seq; |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 559 | msg.body.key.eventId = eventId; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 560 | msg.body.key.deviceId = deviceId; |
| 561 | msg.body.key.source = source; |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 562 | msg.body.key.displayId = displayId.val(); |
Edgar Arriaga | c6ae4bb | 2020-04-16 18:46:48 -0700 | [diff] [blame] | 563 | msg.body.key.hmac = std::move(hmac); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 564 | msg.body.key.action = action; |
| 565 | msg.body.key.flags = flags; |
| 566 | msg.body.key.keyCode = keyCode; |
| 567 | msg.body.key.scanCode = scanCode; |
| 568 | msg.body.key.metaState = metaState; |
| 569 | msg.body.key.repeatCount = repeatCount; |
| 570 | msg.body.key.downTime = downTime; |
| 571 | msg.body.key.eventTime = eventTime; |
| 572 | return mChannel->sendMessage(&msg); |
| 573 | } |
| 574 | |
| 575 | status_t InputPublisher::publishMotionEvent( |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 576 | uint32_t seq, int32_t eventId, int32_t deviceId, int32_t source, |
| 577 | ui::LogicalDisplayId displayId, std::array<uint8_t, 32> hmac, int32_t action, |
| 578 | int32_t actionButton, int32_t flags, int32_t edgeFlags, int32_t metaState, |
| 579 | int32_t buttonState, MotionClassification classification, const ui::Transform& transform, |
| 580 | float xPrecision, float yPrecision, float xCursorPosition, float yCursorPosition, |
Prabir Pradhan | b9b1850 | 2021-08-26 12:30:32 -0700 | [diff] [blame] | 581 | const ui::Transform& rawTransform, nsecs_t downTime, nsecs_t eventTime, |
Evan Rosky | 0957669 | 2021-07-01 12:22:09 -0700 | [diff] [blame] | 582 | uint32_t pointerCount, const PointerProperties* pointerProperties, |
| 583 | const PointerCoords* pointerCoords) { |
Prabir Pradhan | 2dac8b8 | 2023-09-06 01:11:51 +0000 | [diff] [blame] | 584 | ATRACE_NAME_IF(ATRACE_ENABLED(), |
| 585 | StringPrintf("publishMotionEvent(inputChannel=%s, action=%s)", |
| 586 | mChannel->getName().c_str(), |
| 587 | MotionEvent::actionToString(action).c_str())); |
Siarhei Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 588 | if (verifyEvents()) { |
Siarhei Vishniakou | 5c02a71 | 2023-05-15 15:45:02 -0700 | [diff] [blame] | 589 | Result<void> result = |
Siarhei Vishniakou | 2d151ac | 2023-09-19 13:30:24 -0700 | [diff] [blame] | 590 | mInputVerifier.processMovement(deviceId, source, action, pointerCount, |
| 591 | pointerProperties, pointerCoords, flags); |
Siarhei Vishniakou | 5c02a71 | 2023-05-15 15:45:02 -0700 | [diff] [blame] | 592 | if (!result.ok()) { |
| 593 | LOG(FATAL) << "Bad stream: " << result.error(); |
| 594 | } |
Siarhei Vishniakou | 92c8fd5 | 2023-01-29 14:57:43 -0800 | [diff] [blame] | 595 | } |
Prabir Pradhan | b2bd83c | 2023-02-23 02:34:40 +0000 | [diff] [blame] | 596 | if (debugTransportPublisher()) { |
chaviw | 9eaa22c | 2020-07-01 16:21:27 -0700 | [diff] [blame] | 597 | std::string transformString; |
chaviw | 85b4420 | 2020-07-24 11:46:21 -0700 | [diff] [blame] | 598 | transform.dump(transformString, "transform", " "); |
Prabir Pradhan | 96282b0 | 2023-02-24 22:36:17 +0000 | [diff] [blame] | 599 | ALOGD("channel '%s' publisher ~ %s: seq=%u, id=%d, deviceId=%d, source=%s, " |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 600 | "displayId=%s, " |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 601 | "action=%s, actionButton=0x%08x, flags=0x%x, edgeFlags=0x%x, " |
chaviw | 9eaa22c | 2020-07-01 16:21:27 -0700 | [diff] [blame] | 602 | "metaState=0x%x, buttonState=0x%x, classification=%s," |
Siarhei Vishniakou | 3b37f9a | 2019-11-23 13:42:41 -0800 | [diff] [blame] | 603 | "xPrecision=%f, yPrecision=%f, downTime=%" PRId64 ", eventTime=%" PRId64 ", " |
Siarhei Vishniakou | f77f60a | 2023-10-23 17:26:05 -0700 | [diff] [blame] | 604 | "pointerCount=%" PRIu32 "\n%s", |
Prabir Pradhan | 96282b0 | 2023-02-24 22:36:17 +0000 | [diff] [blame] | 605 | mChannel->getName().c_str(), __func__, seq, eventId, deviceId, |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 606 | inputEventSourceToString(source).c_str(), displayId.toString().c_str(), |
Prabir Pradhan | 60dd97a | 2023-02-23 02:23:02 +0000 | [diff] [blame] | 607 | MotionEvent::actionToString(action).c_str(), actionButton, flags, edgeFlags, |
| 608 | metaState, buttonState, motionClassificationToString(classification), xPrecision, |
| 609 | yPrecision, downTime, eventTime, pointerCount, transformString.c_str()); |
Siarhei Vishniakou | 3b37f9a | 2019-11-23 13:42:41 -0800 | [diff] [blame] | 610 | } |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 611 | |
| 612 | if (!seq) { |
| 613 | ALOGE("Attempted to publish a motion event with sequence number 0."); |
| 614 | return BAD_VALUE; |
| 615 | } |
| 616 | |
| 617 | if (pointerCount > MAX_POINTERS || pointerCount < 1) { |
Michael Wright | 63ff3a8 | 2014-06-10 13:03:17 -0700 | [diff] [blame] | 618 | ALOGE("channel '%s' publisher ~ Invalid number of pointers provided: %" PRIu32 ".", |
Siarhei Vishniakou | f93fcf4 | 2017-11-22 16:00:14 -0800 | [diff] [blame] | 619 | mChannel->getName().c_str(), pointerCount); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 620 | return BAD_VALUE; |
| 621 | } |
| 622 | |
| 623 | InputMessage msg; |
Siarhei Vishniakou | 5240277 | 2019-10-22 09:32:30 -0700 | [diff] [blame] | 624 | msg.header.type = InputMessage::Type::MOTION; |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 625 | msg.header.seq = seq; |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 626 | msg.body.motion.eventId = eventId; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 627 | msg.body.motion.deviceId = deviceId; |
| 628 | msg.body.motion.source = source; |
Linnan Li | 13bf76a | 2024-05-05 19:18:02 +0800 | [diff] [blame] | 629 | msg.body.motion.displayId = displayId.val(); |
Edgar Arriaga | c6ae4bb | 2020-04-16 18:46:48 -0700 | [diff] [blame] | 630 | msg.body.motion.hmac = std::move(hmac); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 631 | msg.body.motion.action = action; |
Michael Wright | 7b159c9 | 2015-05-14 14:48:03 +0100 | [diff] [blame] | 632 | msg.body.motion.actionButton = actionButton; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 633 | msg.body.motion.flags = flags; |
| 634 | msg.body.motion.edgeFlags = edgeFlags; |
| 635 | msg.body.motion.metaState = metaState; |
| 636 | msg.body.motion.buttonState = buttonState; |
Siarhei Vishniakou | 16a2e30 | 2019-01-14 19:21:45 -0800 | [diff] [blame] | 637 | msg.body.motion.classification = classification; |
chaviw | 9eaa22c | 2020-07-01 16:21:27 -0700 | [diff] [blame] | 638 | msg.body.motion.dsdx = transform.dsdx(); |
| 639 | msg.body.motion.dtdx = transform.dtdx(); |
| 640 | msg.body.motion.dtdy = transform.dtdy(); |
| 641 | msg.body.motion.dsdy = transform.dsdy(); |
| 642 | msg.body.motion.tx = transform.tx(); |
| 643 | msg.body.motion.ty = transform.ty(); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 644 | msg.body.motion.xPrecision = xPrecision; |
| 645 | msg.body.motion.yPrecision = yPrecision; |
Garfield Tan | 00f511d | 2019-06-12 16:55:40 -0700 | [diff] [blame] | 646 | msg.body.motion.xCursorPosition = xCursorPosition; |
| 647 | msg.body.motion.yCursorPosition = yCursorPosition; |
Prabir Pradhan | b9b1850 | 2021-08-26 12:30:32 -0700 | [diff] [blame] | 648 | msg.body.motion.dsdxRaw = rawTransform.dsdx(); |
| 649 | msg.body.motion.dtdxRaw = rawTransform.dtdx(); |
| 650 | msg.body.motion.dtdyRaw = rawTransform.dtdy(); |
| 651 | msg.body.motion.dsdyRaw = rawTransform.dsdy(); |
| 652 | msg.body.motion.txRaw = rawTransform.tx(); |
| 653 | msg.body.motion.tyRaw = rawTransform.ty(); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 654 | msg.body.motion.downTime = downTime; |
| 655 | msg.body.motion.eventTime = eventTime; |
| 656 | msg.body.motion.pointerCount = pointerCount; |
Narayan Kamath | bc6001b | 2014-05-02 17:53:33 +0100 | [diff] [blame] | 657 | for (uint32_t i = 0; i < pointerCount; i++) { |
Siarhei Vishniakou | 73e6d37 | 2023-07-06 18:07:21 -0700 | [diff] [blame] | 658 | msg.body.motion.pointers[i].properties = pointerProperties[i]; |
| 659 | msg.body.motion.pointers[i].coords = pointerCoords[i]; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 660 | } |
Atif Niyaz | 3d3fa52 | 2019-07-25 11:12:39 -0700 | [diff] [blame] | 661 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 662 | return mChannel->sendMessage(&msg); |
| 663 | } |
| 664 | |
Antonio Kantek | 3cfec7b | 2021-11-05 18:26:17 -0700 | [diff] [blame] | 665 | status_t InputPublisher::publishFocusEvent(uint32_t seq, int32_t eventId, bool hasFocus) { |
Prabir Pradhan | 2dac8b8 | 2023-09-06 01:11:51 +0000 | [diff] [blame] | 666 | ATRACE_NAME_IF(ATRACE_ENABLED(), |
| 667 | StringPrintf("publishFocusEvent(inputChannel=%s, hasFocus=%s)", |
| 668 | mChannel->getName().c_str(), toString(hasFocus))); |
Prabir Pradhan | 96282b0 | 2023-02-24 22:36:17 +0000 | [diff] [blame] | 669 | ALOGD_IF(debugTransportPublisher(), "channel '%s' publisher ~ %s: seq=%u, id=%d, hasFocus=%s", |
| 670 | mChannel->getName().c_str(), __func__, seq, eventId, toString(hasFocus)); |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 671 | |
| 672 | InputMessage msg; |
| 673 | msg.header.type = InputMessage::Type::FOCUS; |
Siarhei Vishniakou | a64c159 | 2020-06-22 12:02:29 -0500 | [diff] [blame] | 674 | msg.header.seq = seq; |
Garfield Tan | 1c7bc86 | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 675 | msg.body.focus.eventId = eventId; |
Siarhei Vishniakou | 38b7f7f | 2021-03-05 01:57:08 +0000 | [diff] [blame] | 676 | msg.body.focus.hasFocus = hasFocus; |
Siarhei Vishniakou | 7feb2ea | 2019-11-25 15:11:23 -0800 | [diff] [blame] | 677 | return mChannel->sendMessage(&msg); |
| 678 | } |
| 679 | |
Prabir Pradhan | 3f37b7b | 2020-11-10 16:50:18 -0800 | [diff] [blame] | 680 | status_t InputPublisher::publishCaptureEvent(uint32_t seq, int32_t eventId, |
| 681 | bool pointerCaptureEnabled) { |
Prabir Pradhan | 2dac8b8 | 2023-09-06 01:11:51 +0000 | [diff] [blame] | 682 | ATRACE_NAME_IF(ATRACE_ENABLED(), |
| 683 | StringPrintf("publishCaptureEvent(inputChannel=%s, pointerCaptureEnabled=%s)", |
| 684 | mChannel->getName().c_str(), toString(pointerCaptureEnabled))); |
Prabir Pradhan | b2bd83c | 2023-02-23 02:34:40 +0000 | [diff] [blame] | 685 | ALOGD_IF(debugTransportPublisher(), |
Prabir Pradhan | 96282b0 | 2023-02-24 22:36:17 +0000 | [diff] [blame] | 686 | "channel '%s' publisher ~ %s: seq=%u, id=%d, pointerCaptureEnabled=%s", |
| 687 | mChannel->getName().c_str(), __func__, seq, eventId, toString(pointerCaptureEnabled)); |
Prabir Pradhan | 3f37b7b | 2020-11-10 16:50:18 -0800 | [diff] [blame] | 688 | |
| 689 | InputMessage msg; |
| 690 | msg.header.type = InputMessage::Type::CAPTURE; |
| 691 | msg.header.seq = seq; |
| 692 | msg.body.capture.eventId = eventId; |
Siarhei Vishniakou | 38b7f7f | 2021-03-05 01:57:08 +0000 | [diff] [blame] | 693 | msg.body.capture.pointerCaptureEnabled = pointerCaptureEnabled; |
Prabir Pradhan | 3f37b7b | 2020-11-10 16:50:18 -0800 | [diff] [blame] | 694 | return mChannel->sendMessage(&msg); |
| 695 | } |
| 696 | |
arthurhung | 7632c33 | 2020-12-30 16:58:01 +0800 | [diff] [blame] | 697 | status_t InputPublisher::publishDragEvent(uint32_t seq, int32_t eventId, float x, float y, |
| 698 | bool isExiting) { |
Prabir Pradhan | 2dac8b8 | 2023-09-06 01:11:51 +0000 | [diff] [blame] | 699 | ATRACE_NAME_IF(ATRACE_ENABLED(), |
| 700 | StringPrintf("publishDragEvent(inputChannel=%s, x=%f, y=%f, isExiting=%s)", |
| 701 | mChannel->getName().c_str(), x, y, toString(isExiting))); |
Prabir Pradhan | b2bd83c | 2023-02-23 02:34:40 +0000 | [diff] [blame] | 702 | ALOGD_IF(debugTransportPublisher(), |
Prabir Pradhan | 96282b0 | 2023-02-24 22:36:17 +0000 | [diff] [blame] | 703 | "channel '%s' publisher ~ %s: seq=%u, id=%d, x=%f, y=%f, isExiting=%s", |
| 704 | mChannel->getName().c_str(), __func__, seq, eventId, x, y, toString(isExiting)); |
arthurhung | 7632c33 | 2020-12-30 16:58:01 +0800 | [diff] [blame] | 705 | |
| 706 | InputMessage msg; |
| 707 | msg.header.type = InputMessage::Type::DRAG; |
| 708 | msg.header.seq = seq; |
| 709 | msg.body.drag.eventId = eventId; |
| 710 | msg.body.drag.isExiting = isExiting; |
| 711 | msg.body.drag.x = x; |
| 712 | msg.body.drag.y = y; |
| 713 | return mChannel->sendMessage(&msg); |
| 714 | } |
| 715 | |
Antonio Kantek | 7cdf8ef | 2021-07-13 18:04:53 -0700 | [diff] [blame] | 716 | status_t InputPublisher::publishTouchModeEvent(uint32_t seq, int32_t eventId, bool isInTouchMode) { |
Prabir Pradhan | 2dac8b8 | 2023-09-06 01:11:51 +0000 | [diff] [blame] | 717 | ATRACE_NAME_IF(ATRACE_ENABLED(), |
| 718 | StringPrintf("publishTouchModeEvent(inputChannel=%s, isInTouchMode=%s)", |
| 719 | mChannel->getName().c_str(), toString(isInTouchMode))); |
Prabir Pradhan | 96282b0 | 2023-02-24 22:36:17 +0000 | [diff] [blame] | 720 | ALOGD_IF(debugTransportPublisher(), |
| 721 | "channel '%s' publisher ~ %s: seq=%u, id=%d, isInTouchMode=%s", |
| 722 | mChannel->getName().c_str(), __func__, seq, eventId, toString(isInTouchMode)); |
Antonio Kantek | 7cdf8ef | 2021-07-13 18:04:53 -0700 | [diff] [blame] | 723 | |
| 724 | InputMessage msg; |
| 725 | msg.header.type = InputMessage::Type::TOUCH_MODE; |
| 726 | msg.header.seq = seq; |
| 727 | msg.body.touchMode.eventId = eventId; |
| 728 | msg.body.touchMode.isInTouchMode = isInTouchMode; |
| 729 | return mChannel->sendMessage(&msg); |
| 730 | } |
| 731 | |
Siarhei Vishniakou | f94ae02 | 2021-02-04 01:23:17 +0000 | [diff] [blame] | 732 | android::base::Result<InputPublisher::ConsumerResponse> InputPublisher::receiveConsumerResponse() { |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 733 | android::base::Result<InputMessage> result = mChannel->receiveMessage(); |
| 734 | if (!result.ok()) { |
| 735 | if (debugTransportPublisher() && result.error().code() != WOULD_BLOCK) { |
Siarhei Vishniakou | 6911265 | 2023-08-24 08:34:18 -0700 | [diff] [blame] | 736 | LOG(INFO) << "channel '" << mChannel->getName() << "' publisher ~ " << __func__ << ": " |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 737 | << result.error().message(); |
Siarhei Vishniakou | 6911265 | 2023-08-24 08:34:18 -0700 | [diff] [blame] | 738 | } |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 739 | return result.error(); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 740 | } |
Paul Ramirez | 10bae11 | 2024-06-18 21:33:33 +0000 | [diff] [blame] | 741 | |
| 742 | const InputMessage& msg = *result; |
Siarhei Vishniakou | f94ae02 | 2021-02-04 01:23:17 +0000 | [diff] [blame] | 743 | if (msg.header.type == InputMessage::Type::FINISHED) { |
Prabir Pradhan | 96282b0 | 2023-02-24 22:36:17 +0000 | [diff] [blame] | 744 | ALOGD_IF(debugTransportPublisher(), |
| 745 | "channel '%s' publisher ~ %s: finished: seq=%u, handled=%s", |
| 746 | mChannel->getName().c_str(), __func__, msg.header.seq, |
| 747 | toString(msg.body.finished.handled)); |
Siarhei Vishniakou | f94ae02 | 2021-02-04 01:23:17 +0000 | [diff] [blame] | 748 | return Finished{ |
| 749 | .seq = msg.header.seq, |
| 750 | .handled = msg.body.finished.handled, |
| 751 | .consumeTime = msg.body.finished.consumeTime, |
| 752 | }; |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 753 | } |
Siarhei Vishniakou | f94ae02 | 2021-02-04 01:23:17 +0000 | [diff] [blame] | 754 | |
| 755 | if (msg.header.type == InputMessage::Type::TIMELINE) { |
Prabir Pradhan | 96282b0 | 2023-02-24 22:36:17 +0000 | [diff] [blame] | 756 | ALOGD_IF(debugTransportPublisher(), "channel '%s' publisher ~ %s: timeline: id=%d", |
| 757 | mChannel->getName().c_str(), __func__, msg.body.timeline.eventId); |
Siarhei Vishniakou | f94ae02 | 2021-02-04 01:23:17 +0000 | [diff] [blame] | 758 | return Timeline{ |
| 759 | .inputEventId = msg.body.timeline.eventId, |
| 760 | .graphicsTimeline = msg.body.timeline.graphicsTimeline, |
| 761 | }; |
| 762 | } |
| 763 | |
| 764 | ALOGE("channel '%s' publisher ~ Received unexpected %s message from consumer", |
Dominik Laskowski | 7578845 | 2021-02-09 18:51:25 -0800 | [diff] [blame] | 765 | mChannel->getName().c_str(), ftl::enum_string(msg.header.type).c_str()); |
Siarhei Vishniakou | f94ae02 | 2021-02-04 01:23:17 +0000 | [diff] [blame] | 766 | return android::base::Error(UNKNOWN_ERROR); |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 767 | } |
| 768 | |
Jeff Brown | 5912f95 | 2013-07-01 19:10:31 -0700 | [diff] [blame] | 769 | } // namespace android |