| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2019 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
|  | 17 | #include "Entry.h" | 
|  | 18 |  | 
|  | 19 | #include "Connection.h" | 
|  | 20 |  | 
| Ashwini Oruganti | d399a52 | 2019-10-10 11:16:45 -0700 | [diff] [blame] | 21 | #include <android-base/properties.h> | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 22 | #include <android-base/stringprintf.h> | 
|  | 23 | #include <cutils/atomic.h> | 
|  | 24 | #include <inttypes.h> | 
|  | 25 |  | 
| Ashwini Oruganti | d399a52 | 2019-10-10 11:16:45 -0700 | [diff] [blame] | 26 | using android::base::GetBoolProperty; | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 27 | using android::base::StringPrintf; | 
|  | 28 |  | 
|  | 29 | namespace android::inputdispatcher { | 
|  | 30 |  | 
| Gang Wang | e908789 | 2020-01-07 12:17:14 -0500 | [diff] [blame] | 31 | VerifiedKeyEvent verifiedKeyEventFromKeyEntry(const KeyEntry& entry) { | 
|  | 32 | return {{VerifiedInputEvent::Type::KEY, entry.deviceId, entry.eventTime, entry.source, | 
|  | 33 | entry.displayId}, | 
|  | 34 | entry.action, | 
|  | 35 | entry.downTime, | 
|  | 36 | entry.flags & VERIFIED_KEY_EVENT_FLAGS, | 
|  | 37 | entry.keyCode, | 
|  | 38 | entry.scanCode, | 
|  | 39 | entry.metaState, | 
|  | 40 | entry.repeatCount}; | 
|  | 41 | } | 
|  | 42 |  | 
|  | 43 | VerifiedMotionEvent verifiedMotionEventFromMotionEntry(const MotionEntry& entry) { | 
|  | 44 | const float rawX = entry.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_X); | 
|  | 45 | const float rawY = entry.pointerCoords[0].getAxisValue(AMOTION_EVENT_AXIS_Y); | 
|  | 46 | const int actionMasked = entry.action & AMOTION_EVENT_ACTION_MASK; | 
|  | 47 | return {{VerifiedInputEvent::Type::MOTION, entry.deviceId, entry.eventTime, entry.source, | 
|  | 48 | entry.displayId}, | 
|  | 49 | rawX, | 
|  | 50 | rawY, | 
|  | 51 | actionMasked, | 
|  | 52 | entry.downTime, | 
|  | 53 | entry.flags & VERIFIED_MOTION_EVENT_FLAGS, | 
|  | 54 | entry.metaState, | 
|  | 55 | entry.buttonState}; | 
|  | 56 | } | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 57 |  | 
|  | 58 | // --- EventEntry --- | 
|  | 59 |  | 
| Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 60 | EventEntry::EventEntry(int32_t id, Type type, nsecs_t eventTime, uint32_t policyFlags) | 
|  | 61 | : id(id), | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 62 | type(type), | 
|  | 63 | eventTime(eventTime), | 
|  | 64 | policyFlags(policyFlags), | 
|  | 65 | injectionState(nullptr), | 
|  | 66 | dispatchInProgress(false) {} | 
|  | 67 |  | 
|  | 68 | EventEntry::~EventEntry() { | 
|  | 69 | releaseInjectionState(); | 
|  | 70 | } | 
|  | 71 |  | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 72 | void EventEntry::releaseInjectionState() { | 
|  | 73 | if (injectionState) { | 
|  | 74 | injectionState->release(); | 
|  | 75 | injectionState = nullptr; | 
|  | 76 | } | 
|  | 77 | } | 
|  | 78 |  | 
|  | 79 | // --- ConfigurationChangedEntry --- | 
|  | 80 |  | 
| Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 81 | ConfigurationChangedEntry::ConfigurationChangedEntry(int32_t id, nsecs_t eventTime) | 
|  | 82 | : EventEntry(id, Type::CONFIGURATION_CHANGED, eventTime, 0) {} | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 83 |  | 
|  | 84 | ConfigurationChangedEntry::~ConfigurationChangedEntry() {} | 
|  | 85 |  | 
| Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 86 | std::string ConfigurationChangedEntry::getDescription() const { | 
|  | 87 | return StringPrintf("ConfigurationChangedEvent(), policyFlags=0x%08x", policyFlags); | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 88 | } | 
|  | 89 |  | 
|  | 90 | // --- DeviceResetEntry --- | 
|  | 91 |  | 
| Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 92 | DeviceResetEntry::DeviceResetEntry(int32_t id, nsecs_t eventTime, int32_t deviceId) | 
|  | 93 | : EventEntry(id, Type::DEVICE_RESET, eventTime, 0), deviceId(deviceId) {} | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 94 |  | 
|  | 95 | DeviceResetEntry::~DeviceResetEntry() {} | 
|  | 96 |  | 
| Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 97 | std::string DeviceResetEntry::getDescription() const { | 
|  | 98 | return StringPrintf("DeviceResetEvent(deviceId=%d), policyFlags=0x%08x", deviceId, policyFlags); | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 99 | } | 
|  | 100 |  | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 101 | // --- FocusEntry --- | 
|  | 102 |  | 
|  | 103 | // Focus notifications always go to apps, so set the flag POLICY_FLAG_PASS_TO_USER for all entries | 
| Vishnu Nair | 7d3d00d | 2020-08-03 11:20:42 -0700 | [diff] [blame] | 104 | FocusEntry::FocusEntry(int32_t id, nsecs_t eventTime, sp<IBinder> connectionToken, bool hasFocus, | 
| Vishnu Nair | c519ff7 | 2021-01-21 08:23:08 -0800 | [diff] [blame] | 105 | const std::string& reason) | 
| Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 106 | : EventEntry(id, Type::FOCUS, eventTime, POLICY_FLAG_PASS_TO_USER), | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 107 | connectionToken(connectionToken), | 
| Vishnu Nair | 7d3d00d | 2020-08-03 11:20:42 -0700 | [diff] [blame] | 108 | hasFocus(hasFocus), | 
|  | 109 | reason(reason) {} | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 110 |  | 
|  | 111 | FocusEntry::~FocusEntry() {} | 
|  | 112 |  | 
| Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 113 | std::string FocusEntry::getDescription() const { | 
|  | 114 | return StringPrintf("FocusEvent(hasFocus=%s)", hasFocus ? "true" : "false"); | 
| Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 115 | } | 
|  | 116 |  | 
| Prabir Pradhan | 9998771 | 2020-11-10 18:43:05 -0800 | [diff] [blame] | 117 | // --- PointerCaptureChangedEntry --- | 
|  | 118 |  | 
|  | 119 | // PointerCaptureChanged notifications always go to apps, so set the flag POLICY_FLAG_PASS_TO_USER | 
|  | 120 | // for all entries. | 
|  | 121 | PointerCaptureChangedEntry::PointerCaptureChangedEntry(int32_t id, nsecs_t eventTime, | 
|  | 122 | bool hasPointerCapture) | 
|  | 123 | : EventEntry(id, Type::POINTER_CAPTURE_CHANGED, eventTime, POLICY_FLAG_PASS_TO_USER), | 
|  | 124 | pointerCaptureEnabled(hasPointerCapture) {} | 
|  | 125 |  | 
|  | 126 | PointerCaptureChangedEntry::~PointerCaptureChangedEntry() {} | 
|  | 127 |  | 
|  | 128 | std::string PointerCaptureChangedEntry::getDescription() const { | 
|  | 129 | return StringPrintf("PointerCaptureChangedEvent(pointerCaptureEnabled=%s)", | 
|  | 130 | pointerCaptureEnabled ? "true" : "false"); | 
|  | 131 | } | 
|  | 132 |  | 
| arthurhung | b89ccb0 | 2020-12-30 16:19:01 +0800 | [diff] [blame] | 133 | // --- DragEntry --- | 
|  | 134 |  | 
|  | 135 | // Drag notifications always go to apps, so set the flag POLICY_FLAG_PASS_TO_USER for all entries | 
|  | 136 | DragEntry::DragEntry(int32_t id, nsecs_t eventTime, sp<IBinder> connectionToken, bool isExiting, | 
|  | 137 | float x, float y) | 
|  | 138 | : EventEntry(id, Type::DRAG, eventTime, POLICY_FLAG_PASS_TO_USER), | 
|  | 139 | connectionToken(connectionToken), | 
|  | 140 | isExiting(isExiting), | 
|  | 141 | x(x), | 
|  | 142 | y(y) {} | 
|  | 143 |  | 
|  | 144 | DragEntry::~DragEntry() {} | 
|  | 145 |  | 
|  | 146 | std::string DragEntry::getDescription() const { | 
|  | 147 | return StringPrintf("DragEntry(isExiting=%s, x=%f, y=%f)", isExiting ? "true" : "false", x, y); | 
|  | 148 | } | 
|  | 149 |  | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 150 | // --- KeyEntry --- | 
|  | 151 |  | 
| Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 152 | KeyEntry::KeyEntry(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source, | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 153 | int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags, | 
|  | 154 | int32_t keyCode, int32_t scanCode, int32_t metaState, int32_t repeatCount, | 
|  | 155 | nsecs_t downTime) | 
| Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 156 | : EventEntry(id, Type::KEY, eventTime, policyFlags), | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 157 | deviceId(deviceId), | 
|  | 158 | source(source), | 
|  | 159 | displayId(displayId), | 
|  | 160 | action(action), | 
|  | 161 | flags(flags), | 
|  | 162 | keyCode(keyCode), | 
|  | 163 | scanCode(scanCode), | 
|  | 164 | metaState(metaState), | 
|  | 165 | repeatCount(repeatCount), | 
|  | 166 | downTime(downTime), | 
|  | 167 | syntheticRepeat(false), | 
|  | 168 | interceptKeyResult(KeyEntry::INTERCEPT_KEY_RESULT_UNKNOWN), | 
|  | 169 | interceptKeyWakeupTime(0) {} | 
|  | 170 |  | 
|  | 171 | KeyEntry::~KeyEntry() {} | 
|  | 172 |  | 
| Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 173 | std::string KeyEntry::getDescription() const { | 
| Ashwini Oruganti | d399a52 | 2019-10-10 11:16:45 -0700 | [diff] [blame] | 174 | if (!GetBoolProperty("ro.debuggable", false)) { | 
| Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 175 | return "KeyEvent"; | 
| Ashwini Oruganti | d399a52 | 2019-10-10 11:16:45 -0700 | [diff] [blame] | 176 | } | 
| Siarhei Vishniakou | a1188f5 | 2020-10-20 20:14:52 -0500 | [diff] [blame] | 177 | return StringPrintf("KeyEvent(deviceId=%d, eventTime=%" PRIu64 | 
|  | 178 | ", source=0x%08x, displayId=%" PRId32 ", action=%s, " | 
| Siarhei Vishniakou | 5b6c96f | 2021-02-25 00:21:51 -1000 | [diff] [blame] | 179 | "flags=0x%08x, keyCode=%s(%d), scanCode=%d, metaState=0x%08x, " | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 180 | "repeatCount=%d), policyFlags=0x%08x", | 
| Siarhei Vishniakou | a1188f5 | 2020-10-20 20:14:52 -0500 | [diff] [blame] | 181 | deviceId, eventTime, source, displayId, KeyEvent::actionToString(action), | 
| Siarhei Vishniakou | 5b6c96f | 2021-02-25 00:21:51 -1000 | [diff] [blame] | 182 | flags, KeyEvent::getLabel(keyCode), keyCode, scanCode, metaState, | 
|  | 183 | repeatCount, policyFlags); | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 184 | } | 
|  | 185 |  | 
|  | 186 | void KeyEntry::recycle() { | 
|  | 187 | releaseInjectionState(); | 
|  | 188 |  | 
|  | 189 | dispatchInProgress = false; | 
|  | 190 | syntheticRepeat = false; | 
|  | 191 | interceptKeyResult = KeyEntry::INTERCEPT_KEY_RESULT_UNKNOWN; | 
|  | 192 | interceptKeyWakeupTime = 0; | 
|  | 193 | } | 
|  | 194 |  | 
|  | 195 | // --- MotionEntry --- | 
|  | 196 |  | 
| Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 197 | MotionEntry::MotionEntry(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source, | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 198 | int32_t displayId, uint32_t policyFlags, int32_t action, | 
|  | 199 | int32_t actionButton, int32_t flags, int32_t metaState, | 
|  | 200 | int32_t buttonState, MotionClassification classification, | 
|  | 201 | int32_t edgeFlags, float xPrecision, float yPrecision, | 
|  | 202 | float xCursorPosition, float yCursorPosition, nsecs_t downTime, | 
|  | 203 | uint32_t pointerCount, const PointerProperties* pointerProperties, | 
|  | 204 | const PointerCoords* pointerCoords, float xOffset, float yOffset) | 
| Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 205 | : EventEntry(id, Type::MOTION, eventTime, policyFlags), | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 206 | deviceId(deviceId), | 
|  | 207 | source(source), | 
|  | 208 | displayId(displayId), | 
|  | 209 | action(action), | 
|  | 210 | actionButton(actionButton), | 
|  | 211 | flags(flags), | 
|  | 212 | metaState(metaState), | 
|  | 213 | buttonState(buttonState), | 
|  | 214 | classification(classification), | 
|  | 215 | edgeFlags(edgeFlags), | 
|  | 216 | xPrecision(xPrecision), | 
|  | 217 | yPrecision(yPrecision), | 
|  | 218 | xCursorPosition(xCursorPosition), | 
|  | 219 | yCursorPosition(yCursorPosition), | 
|  | 220 | downTime(downTime), | 
|  | 221 | pointerCount(pointerCount) { | 
|  | 222 | for (uint32_t i = 0; i < pointerCount; i++) { | 
|  | 223 | this->pointerProperties[i].copyFrom(pointerProperties[i]); | 
|  | 224 | this->pointerCoords[i].copyFrom(pointerCoords[i]); | 
|  | 225 | if (xOffset || yOffset) { | 
|  | 226 | this->pointerCoords[i].applyOffset(xOffset, yOffset); | 
|  | 227 | } | 
|  | 228 | } | 
|  | 229 | } | 
|  | 230 |  | 
|  | 231 | MotionEntry::~MotionEntry() {} | 
|  | 232 |  | 
| Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 233 | std::string MotionEntry::getDescription() const { | 
| Ashwini Oruganti | d399a52 | 2019-10-10 11:16:45 -0700 | [diff] [blame] | 234 | if (!GetBoolProperty("ro.debuggable", false)) { | 
| Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 235 | return "MotionEvent"; | 
| Ashwini Oruganti | d399a52 | 2019-10-10 11:16:45 -0700 | [diff] [blame] | 236 | } | 
| Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 237 | std::string msg; | 
| Siarhei Vishniakou | a1188f5 | 2020-10-20 20:14:52 -0500 | [diff] [blame] | 238 | msg += StringPrintf("MotionEvent(deviceId=%d, eventTime=%" PRIu64 | 
|  | 239 | ", source=0x%08x, displayId=%" PRId32 | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 240 | ", action=%s, actionButton=0x%08x, flags=0x%08x, metaState=0x%08x, " | 
|  | 241 | "buttonState=0x%08x, " | 
|  | 242 | "classification=%s, edgeFlags=0x%08x, xPrecision=%.1f, yPrecision=%.1f, " | 
|  | 243 | "xCursorPosition=%0.1f, yCursorPosition=%0.1f, pointers=[", | 
| Siarhei Vishniakou | c68fdec | 2020-10-22 14:58:14 -0500 | [diff] [blame] | 244 | deviceId, eventTime, source, displayId, | 
|  | 245 | MotionEvent::actionToString(action).c_str(), actionButton, flags, metaState, | 
|  | 246 | buttonState, motionClassificationToString(classification), edgeFlags, | 
|  | 247 | xPrecision, yPrecision, xCursorPosition, yCursorPosition); | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 248 |  | 
|  | 249 | for (uint32_t i = 0; i < pointerCount; i++) { | 
|  | 250 | if (i) { | 
|  | 251 | msg += ", "; | 
|  | 252 | } | 
|  | 253 | msg += StringPrintf("%d: (%.1f, %.1f)", pointerProperties[i].id, pointerCoords[i].getX(), | 
|  | 254 | pointerCoords[i].getY()); | 
|  | 255 | } | 
|  | 256 | msg += StringPrintf("]), policyFlags=0x%08x", policyFlags); | 
| Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 257 | return msg; | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 258 | } | 
|  | 259 |  | 
| Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 260 | // --- SensorEntry --- | 
|  | 261 |  | 
|  | 262 | SensorEntry::SensorEntry(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source, | 
|  | 263 | uint32_t policyFlags, nsecs_t hwTimestamp, | 
|  | 264 | InputDeviceSensorType sensorType, InputDeviceSensorAccuracy accuracy, | 
|  | 265 | bool accuracyChanged, std::vector<float> values) | 
|  | 266 | : EventEntry(id, Type::SENSOR, eventTime, policyFlags), | 
|  | 267 | deviceId(deviceId), | 
|  | 268 | source(source), | 
|  | 269 | sensorType(sensorType), | 
|  | 270 | accuracy(accuracy), | 
|  | 271 | accuracyChanged(accuracyChanged), | 
|  | 272 | hwTimestamp(hwTimestamp), | 
|  | 273 | values(std::move(values)) {} | 
|  | 274 |  | 
|  | 275 | SensorEntry::~SensorEntry() {} | 
|  | 276 |  | 
|  | 277 | std::string SensorEntry::getDescription() const { | 
|  | 278 | std::string msg; | 
|  | 279 | msg += StringPrintf("SensorEntry(deviceId=%d, source=0x%08x, sensorType=0x%08x, " | 
|  | 280 | "accuracy=0x%08x, hwTimestamp=%" PRId64, | 
|  | 281 | deviceId, source, sensorType, accuracy, hwTimestamp); | 
|  | 282 |  | 
|  | 283 | if (!GetBoolProperty("ro.debuggable", false)) { | 
|  | 284 | for (size_t i = 0; i < values.size(); i++) { | 
|  | 285 | if (i > 0) { | 
|  | 286 | msg += ", "; | 
|  | 287 | } | 
|  | 288 | msg += StringPrintf("(%.3f)", values[i]); | 
|  | 289 | } | 
|  | 290 | } | 
|  | 291 | msg += StringPrintf(", policyFlags=0x%08x", policyFlags); | 
|  | 292 | return msg; | 
|  | 293 | } | 
|  | 294 |  | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 295 | // --- DispatchEntry --- | 
|  | 296 |  | 
|  | 297 | volatile int32_t DispatchEntry::sNextSeqAtomic; | 
|  | 298 |  | 
| Siarhei Vishniakou | a9a7ee8 | 2019-10-14 16:28:19 -0700 | [diff] [blame] | 299 | DispatchEntry::DispatchEntry(std::shared_ptr<EventEntry> eventEntry, int32_t targetFlags, | 
| Evan Rosky | 0957669 | 2021-07-01 12:22:09 -0700 | [diff] [blame] | 300 | ui::Transform transform, float globalScaleFactor, | 
|  | 301 | uint32_t displayOrientation, int2 displaySize) | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 302 | : seq(nextSeq()), | 
| Siarhei Vishniakou | a9a7ee8 | 2019-10-14 16:28:19 -0700 | [diff] [blame] | 303 | eventEntry(std::move(eventEntry)), | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 304 | targetFlags(targetFlags), | 
| chaviw | 1ff3d1e | 2020-07-01 15:53:47 -0700 | [diff] [blame] | 305 | transform(transform), | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 306 | globalScaleFactor(globalScaleFactor), | 
| Evan Rosky | 0957669 | 2021-07-01 12:22:09 -0700 | [diff] [blame] | 307 | displayOrientation(displayOrientation), | 
| Evan Rosky | 84f07f0 | 2021-04-16 10:42:42 -0700 | [diff] [blame] | 308 | displaySize(displaySize), | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 309 | deliveryTime(0), | 
|  | 310 | resolvedAction(0), | 
| Siarhei Vishniakou | a9a7ee8 | 2019-10-14 16:28:19 -0700 | [diff] [blame] | 311 | resolvedFlags(0) {} | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 312 |  | 
|  | 313 | uint32_t DispatchEntry::nextSeq() { | 
|  | 314 | // Sequence number 0 is reserved and will never be returned. | 
|  | 315 | uint32_t seq; | 
|  | 316 | do { | 
|  | 317 | seq = android_atomic_inc(&sNextSeqAtomic); | 
|  | 318 | } while (!seq); | 
|  | 319 | return seq; | 
|  | 320 | } | 
|  | 321 |  | 
| Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 322 | } // namespace android::inputdispatcher |