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 | |
Prabir Pradhan | b5cb957 | 2021-09-24 06:35:16 -0700 | [diff] [blame] | 43 | VerifiedMotionEvent verifiedMotionEventFromMotionEntry(const MotionEntry& entry, |
| 44 | const ui::Transform& rawTransform) { |
| 45 | const vec2 rawXY = MotionEvent::calculateTransformedXY(entry.source, rawTransform, |
| 46 | entry.pointerCoords[0].getXYValue()); |
Gang Wang | e908789 | 2020-01-07 12:17:14 -0500 | [diff] [blame] | 47 | const int actionMasked = entry.action & AMOTION_EVENT_ACTION_MASK; |
| 48 | return {{VerifiedInputEvent::Type::MOTION, entry.deviceId, entry.eventTime, entry.source, |
| 49 | entry.displayId}, |
Prabir Pradhan | b5cb957 | 2021-09-24 06:35:16 -0700 | [diff] [blame] | 50 | rawXY.x, |
| 51 | rawXY.y, |
Gang Wang | e908789 | 2020-01-07 12:17:14 -0500 | [diff] [blame] | 52 | actionMasked, |
| 53 | entry.downTime, |
| 54 | entry.flags & VERIFIED_MOTION_EVENT_FLAGS, |
| 55 | entry.metaState, |
| 56 | entry.buttonState}; |
| 57 | } |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 58 | |
| 59 | // --- EventEntry --- |
| 60 | |
Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 61 | EventEntry::EventEntry(int32_t id, Type type, nsecs_t eventTime, uint32_t policyFlags) |
| 62 | : id(id), |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 63 | type(type), |
| 64 | eventTime(eventTime), |
| 65 | policyFlags(policyFlags), |
| 66 | injectionState(nullptr), |
| 67 | dispatchInProgress(false) {} |
| 68 | |
| 69 | EventEntry::~EventEntry() { |
| 70 | releaseInjectionState(); |
| 71 | } |
| 72 | |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 73 | void EventEntry::releaseInjectionState() { |
| 74 | if (injectionState) { |
| 75 | injectionState->release(); |
| 76 | injectionState = nullptr; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | // --- ConfigurationChangedEntry --- |
| 81 | |
Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 82 | ConfigurationChangedEntry::ConfigurationChangedEntry(int32_t id, nsecs_t eventTime) |
| 83 | : EventEntry(id, Type::CONFIGURATION_CHANGED, eventTime, 0) {} |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 84 | |
| 85 | ConfigurationChangedEntry::~ConfigurationChangedEntry() {} |
| 86 | |
Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 87 | std::string ConfigurationChangedEntry::getDescription() const { |
| 88 | return StringPrintf("ConfigurationChangedEvent(), policyFlags=0x%08x", policyFlags); |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | // --- DeviceResetEntry --- |
| 92 | |
Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 93 | DeviceResetEntry::DeviceResetEntry(int32_t id, nsecs_t eventTime, int32_t deviceId) |
| 94 | : EventEntry(id, Type::DEVICE_RESET, eventTime, 0), deviceId(deviceId) {} |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 95 | |
| 96 | DeviceResetEntry::~DeviceResetEntry() {} |
| 97 | |
Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 98 | std::string DeviceResetEntry::getDescription() const { |
| 99 | return StringPrintf("DeviceResetEvent(deviceId=%d), policyFlags=0x%08x", deviceId, policyFlags); |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 102 | // --- FocusEntry --- |
| 103 | |
| 104 | // 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] | 105 | 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] | 106 | const std::string& reason) |
Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 107 | : EventEntry(id, Type::FOCUS, eventTime, POLICY_FLAG_PASS_TO_USER), |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 108 | connectionToken(connectionToken), |
Vishnu Nair | 7d3d00d | 2020-08-03 11:20:42 -0700 | [diff] [blame] | 109 | hasFocus(hasFocus), |
| 110 | reason(reason) {} |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 111 | |
| 112 | FocusEntry::~FocusEntry() {} |
| 113 | |
Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 114 | std::string FocusEntry::getDescription() const { |
| 115 | return StringPrintf("FocusEvent(hasFocus=%s)", hasFocus ? "true" : "false"); |
Siarhei Vishniakou | f1035d4 | 2019-09-20 16:32:01 +0100 | [diff] [blame] | 116 | } |
| 117 | |
Prabir Pradhan | 9998771 | 2020-11-10 18:43:05 -0800 | [diff] [blame] | 118 | // --- PointerCaptureChangedEntry --- |
| 119 | |
| 120 | // PointerCaptureChanged notifications always go to apps, so set the flag POLICY_FLAG_PASS_TO_USER |
| 121 | // for all entries. |
| 122 | PointerCaptureChangedEntry::PointerCaptureChangedEntry(int32_t id, nsecs_t eventTime, |
Prabir Pradhan | 5cc1a69 | 2021-08-06 14:01:18 +0000 | [diff] [blame] | 123 | const PointerCaptureRequest& request) |
Prabir Pradhan | 9998771 | 2020-11-10 18:43:05 -0800 | [diff] [blame] | 124 | : EventEntry(id, Type::POINTER_CAPTURE_CHANGED, eventTime, POLICY_FLAG_PASS_TO_USER), |
Prabir Pradhan | 5cc1a69 | 2021-08-06 14:01:18 +0000 | [diff] [blame] | 125 | pointerCaptureRequest(request) {} |
Prabir Pradhan | 9998771 | 2020-11-10 18:43:05 -0800 | [diff] [blame] | 126 | |
| 127 | PointerCaptureChangedEntry::~PointerCaptureChangedEntry() {} |
| 128 | |
| 129 | std::string PointerCaptureChangedEntry::getDescription() const { |
| 130 | return StringPrintf("PointerCaptureChangedEvent(pointerCaptureEnabled=%s)", |
Prabir Pradhan | 5cc1a69 | 2021-08-06 14:01:18 +0000 | [diff] [blame] | 131 | pointerCaptureRequest.enable ? "true" : "false"); |
Prabir Pradhan | 9998771 | 2020-11-10 18:43:05 -0800 | [diff] [blame] | 132 | } |
| 133 | |
arthurhung | b89ccb0 | 2020-12-30 16:19:01 +0800 | [diff] [blame] | 134 | // --- DragEntry --- |
| 135 | |
| 136 | // Drag notifications always go to apps, so set the flag POLICY_FLAG_PASS_TO_USER for all entries |
| 137 | DragEntry::DragEntry(int32_t id, nsecs_t eventTime, sp<IBinder> connectionToken, bool isExiting, |
| 138 | float x, float y) |
| 139 | : EventEntry(id, Type::DRAG, eventTime, POLICY_FLAG_PASS_TO_USER), |
| 140 | connectionToken(connectionToken), |
| 141 | isExiting(isExiting), |
| 142 | x(x), |
| 143 | y(y) {} |
| 144 | |
| 145 | DragEntry::~DragEntry() {} |
| 146 | |
| 147 | std::string DragEntry::getDescription() const { |
| 148 | return StringPrintf("DragEntry(isExiting=%s, x=%f, y=%f)", isExiting ? "true" : "false", x, y); |
| 149 | } |
| 150 | |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 151 | // --- KeyEntry --- |
| 152 | |
Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 153 | 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] | 154 | int32_t displayId, uint32_t policyFlags, int32_t action, int32_t flags, |
| 155 | int32_t keyCode, int32_t scanCode, int32_t metaState, int32_t repeatCount, |
| 156 | nsecs_t downTime) |
Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 157 | : EventEntry(id, Type::KEY, eventTime, policyFlags), |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 158 | deviceId(deviceId), |
| 159 | source(source), |
| 160 | displayId(displayId), |
| 161 | action(action), |
| 162 | flags(flags), |
| 163 | keyCode(keyCode), |
| 164 | scanCode(scanCode), |
| 165 | metaState(metaState), |
| 166 | repeatCount(repeatCount), |
| 167 | downTime(downTime), |
| 168 | syntheticRepeat(false), |
| 169 | interceptKeyResult(KeyEntry::INTERCEPT_KEY_RESULT_UNKNOWN), |
| 170 | interceptKeyWakeupTime(0) {} |
| 171 | |
| 172 | KeyEntry::~KeyEntry() {} |
| 173 | |
Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 174 | std::string KeyEntry::getDescription() const { |
Ashwini Oruganti | d399a52 | 2019-10-10 11:16:45 -0700 | [diff] [blame] | 175 | if (!GetBoolProperty("ro.debuggable", false)) { |
Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 176 | return "KeyEvent"; |
Ashwini Oruganti | d399a52 | 2019-10-10 11:16:45 -0700 | [diff] [blame] | 177 | } |
Siarhei Vishniakou | d948957 | 2021-11-12 20:08:38 -0800 | [diff] [blame^] | 178 | return StringPrintf("KeyEvent(deviceId=%d, eventTime=%" PRIu64 ", source=%s, displayId=%" PRId32 |
| 179 | ", action=%s, " |
Siarhei Vishniakou | 5b6c96f | 2021-02-25 00:21:51 -1000 | [diff] [blame] | 180 | "flags=0x%08x, keyCode=%s(%d), scanCode=%d, metaState=0x%08x, " |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 181 | "repeatCount=%d), policyFlags=0x%08x", |
Siarhei Vishniakou | d948957 | 2021-11-12 20:08:38 -0800 | [diff] [blame^] | 182 | deviceId, eventTime, inputEventSourceToString(source).c_str(), displayId, |
| 183 | KeyEvent::actionToString(action), flags, KeyEvent::getLabel(keyCode), |
| 184 | keyCode, scanCode, metaState, repeatCount, policyFlags); |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | void KeyEntry::recycle() { |
| 188 | releaseInjectionState(); |
| 189 | |
| 190 | dispatchInProgress = false; |
| 191 | syntheticRepeat = false; |
| 192 | interceptKeyResult = KeyEntry::INTERCEPT_KEY_RESULT_UNKNOWN; |
| 193 | interceptKeyWakeupTime = 0; |
| 194 | } |
| 195 | |
Antonio Kantek | 7242d8b | 2021-08-05 16:07:20 -0700 | [diff] [blame] | 196 | // --- TouchModeEntry --- |
| 197 | |
| 198 | TouchModeEntry::TouchModeEntry(int32_t id, nsecs_t eventTime, bool inTouchMode) |
| 199 | : EventEntry(id, Type::TOUCH_MODE_CHANGED, eventTime, POLICY_FLAG_PASS_TO_USER), |
| 200 | inTouchMode(inTouchMode) {} |
| 201 | |
| 202 | TouchModeEntry::~TouchModeEntry() {} |
| 203 | |
| 204 | std::string TouchModeEntry::getDescription() const { |
| 205 | return StringPrintf("TouchModeEvent(inTouchMode=%s)", inTouchMode ? "true" : "false"); |
| 206 | } |
| 207 | |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 208 | // --- MotionEntry --- |
| 209 | |
Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 210 | 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] | 211 | int32_t displayId, uint32_t policyFlags, int32_t action, |
| 212 | int32_t actionButton, int32_t flags, int32_t metaState, |
| 213 | int32_t buttonState, MotionClassification classification, |
| 214 | int32_t edgeFlags, float xPrecision, float yPrecision, |
| 215 | float xCursorPosition, float yCursorPosition, nsecs_t downTime, |
| 216 | uint32_t pointerCount, const PointerProperties* pointerProperties, |
| 217 | const PointerCoords* pointerCoords, float xOffset, float yOffset) |
Garfield Tan | c51d1ba | 2020-01-28 13:24:04 -0800 | [diff] [blame] | 218 | : EventEntry(id, Type::MOTION, eventTime, policyFlags), |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 219 | deviceId(deviceId), |
| 220 | source(source), |
| 221 | displayId(displayId), |
| 222 | action(action), |
| 223 | actionButton(actionButton), |
| 224 | flags(flags), |
| 225 | metaState(metaState), |
| 226 | buttonState(buttonState), |
| 227 | classification(classification), |
| 228 | edgeFlags(edgeFlags), |
| 229 | xPrecision(xPrecision), |
| 230 | yPrecision(yPrecision), |
| 231 | xCursorPosition(xCursorPosition), |
| 232 | yCursorPosition(yCursorPosition), |
| 233 | downTime(downTime), |
| 234 | pointerCount(pointerCount) { |
| 235 | for (uint32_t i = 0; i < pointerCount; i++) { |
| 236 | this->pointerProperties[i].copyFrom(pointerProperties[i]); |
| 237 | this->pointerCoords[i].copyFrom(pointerCoords[i]); |
| 238 | if (xOffset || yOffset) { |
| 239 | this->pointerCoords[i].applyOffset(xOffset, yOffset); |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | |
| 244 | MotionEntry::~MotionEntry() {} |
| 245 | |
Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 246 | std::string MotionEntry::getDescription() const { |
Ashwini Oruganti | d399a52 | 2019-10-10 11:16:45 -0700 | [diff] [blame] | 247 | if (!GetBoolProperty("ro.debuggable", false)) { |
Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 248 | return "MotionEvent"; |
Ashwini Oruganti | d399a52 | 2019-10-10 11:16:45 -0700 | [diff] [blame] | 249 | } |
Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 250 | std::string msg; |
Siarhei Vishniakou | a1188f5 | 2020-10-20 20:14:52 -0500 | [diff] [blame] | 251 | msg += StringPrintf("MotionEvent(deviceId=%d, eventTime=%" PRIu64 |
Siarhei Vishniakou | d948957 | 2021-11-12 20:08:38 -0800 | [diff] [blame^] | 252 | ", source=%s, displayId=%" PRId32 |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 253 | ", action=%s, actionButton=0x%08x, flags=0x%08x, metaState=0x%08x, " |
| 254 | "buttonState=0x%08x, " |
| 255 | "classification=%s, edgeFlags=0x%08x, xPrecision=%.1f, yPrecision=%.1f, " |
| 256 | "xCursorPosition=%0.1f, yCursorPosition=%0.1f, pointers=[", |
Siarhei Vishniakou | d948957 | 2021-11-12 20:08:38 -0800 | [diff] [blame^] | 257 | deviceId, eventTime, inputEventSourceToString(source).c_str(), displayId, |
Siarhei Vishniakou | c68fdec | 2020-10-22 14:58:14 -0500 | [diff] [blame] | 258 | MotionEvent::actionToString(action).c_str(), actionButton, flags, metaState, |
| 259 | buttonState, motionClassificationToString(classification), edgeFlags, |
| 260 | xPrecision, yPrecision, xCursorPosition, yCursorPosition); |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 261 | |
| 262 | for (uint32_t i = 0; i < pointerCount; i++) { |
| 263 | if (i) { |
| 264 | msg += ", "; |
| 265 | } |
| 266 | msg += StringPrintf("%d: (%.1f, %.1f)", pointerProperties[i].id, pointerCoords[i].getX(), |
| 267 | pointerCoords[i].getY()); |
| 268 | } |
| 269 | msg += StringPrintf("]), policyFlags=0x%08x", policyFlags); |
Siarhei Vishniakou | 14411c9 | 2020-09-18 21:15:05 -0500 | [diff] [blame] | 270 | return msg; |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 271 | } |
| 272 | |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 273 | // --- SensorEntry --- |
| 274 | |
| 275 | SensorEntry::SensorEntry(int32_t id, nsecs_t eventTime, int32_t deviceId, uint32_t source, |
| 276 | uint32_t policyFlags, nsecs_t hwTimestamp, |
| 277 | InputDeviceSensorType sensorType, InputDeviceSensorAccuracy accuracy, |
| 278 | bool accuracyChanged, std::vector<float> values) |
| 279 | : EventEntry(id, Type::SENSOR, eventTime, policyFlags), |
| 280 | deviceId(deviceId), |
| 281 | source(source), |
| 282 | sensorType(sensorType), |
| 283 | accuracy(accuracy), |
| 284 | accuracyChanged(accuracyChanged), |
| 285 | hwTimestamp(hwTimestamp), |
| 286 | values(std::move(values)) {} |
| 287 | |
| 288 | SensorEntry::~SensorEntry() {} |
| 289 | |
| 290 | std::string SensorEntry::getDescription() const { |
| 291 | std::string msg; |
Siarhei Vishniakou | d948957 | 2021-11-12 20:08:38 -0800 | [diff] [blame^] | 292 | std::string sensorTypeStr(ftl::enum_name(sensorType).value_or("?")); |
| 293 | msg += StringPrintf("SensorEntry(deviceId=%d, source=%s, sensorType=%s, " |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 294 | "accuracy=0x%08x, hwTimestamp=%" PRId64, |
Siarhei Vishniakou | d948957 | 2021-11-12 20:08:38 -0800 | [diff] [blame^] | 295 | deviceId, inputEventSourceToString(source).c_str(), sensorTypeStr.c_str(), |
| 296 | accuracy, hwTimestamp); |
Chris Ye | f59a2f4 | 2020-10-16 12:55:26 -0700 | [diff] [blame] | 297 | |
| 298 | if (!GetBoolProperty("ro.debuggable", false)) { |
| 299 | for (size_t i = 0; i < values.size(); i++) { |
| 300 | if (i > 0) { |
| 301 | msg += ", "; |
| 302 | } |
| 303 | msg += StringPrintf("(%.3f)", values[i]); |
| 304 | } |
| 305 | } |
| 306 | msg += StringPrintf(", policyFlags=0x%08x", policyFlags); |
| 307 | return msg; |
| 308 | } |
| 309 | |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 310 | // --- DispatchEntry --- |
| 311 | |
| 312 | volatile int32_t DispatchEntry::sNextSeqAtomic; |
| 313 | |
Siarhei Vishniakou | a9a7ee8 | 2019-10-14 16:28:19 -0700 | [diff] [blame] | 314 | DispatchEntry::DispatchEntry(std::shared_ptr<EventEntry> eventEntry, int32_t targetFlags, |
Prabir Pradhan | b9b1850 | 2021-08-26 12:30:32 -0700 | [diff] [blame] | 315 | const ui::Transform& transform, const ui::Transform& rawTransform, |
| 316 | float globalScaleFactor) |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 317 | : seq(nextSeq()), |
Siarhei Vishniakou | a9a7ee8 | 2019-10-14 16:28:19 -0700 | [diff] [blame] | 318 | eventEntry(std::move(eventEntry)), |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 319 | targetFlags(targetFlags), |
chaviw | 1ff3d1e | 2020-07-01 15:53:47 -0700 | [diff] [blame] | 320 | transform(transform), |
Prabir Pradhan | b9b1850 | 2021-08-26 12:30:32 -0700 | [diff] [blame] | 321 | rawTransform(rawTransform), |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 322 | globalScaleFactor(globalScaleFactor), |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 323 | deliveryTime(0), |
| 324 | resolvedAction(0), |
Siarhei Vishniakou | a9a7ee8 | 2019-10-14 16:28:19 -0700 | [diff] [blame] | 325 | resolvedFlags(0) {} |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 326 | |
| 327 | uint32_t DispatchEntry::nextSeq() { |
| 328 | // Sequence number 0 is reserved and will never be returned. |
| 329 | uint32_t seq; |
| 330 | do { |
| 331 | seq = android_atomic_inc(&sNextSeqAtomic); |
| 332 | } while (!seq); |
| 333 | return seq; |
| 334 | } |
| 335 | |
Garfield Tan | e84e6f9 | 2019-08-29 17:28:41 -0700 | [diff] [blame] | 336 | } // namespace android::inputdispatcher |