Siarhei Vishniakou | 6e1e987 | 2022-11-08 17:51:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 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 "TouchedWindow.h" |
| 18 | |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 19 | #include <android-base/logging.h> |
Siarhei Vishniakou | 6e1e987 | 2022-11-08 17:51:35 -0800 | [diff] [blame] | 20 | #include <android-base/stringprintf.h> |
| 21 | #include <input/PrintTools.h> |
| 22 | |
| 23 | using android::base::StringPrintf; |
| 24 | |
| 25 | namespace android { |
| 26 | |
| 27 | namespace inputdispatcher { |
| 28 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 29 | namespace { |
| 30 | |
| 31 | bool hasPointerId(const std::vector<PointerProperties>& pointers, int32_t pointerId) { |
| 32 | return std::find_if(pointers.begin(), pointers.end(), |
| 33 | [&pointerId](const PointerProperties& properties) { |
| 34 | return properties.id == pointerId; |
| 35 | }) != pointers.end(); |
| 36 | } |
| 37 | |
| 38 | } // namespace |
| 39 | |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 40 | bool TouchedWindow::hasHoveringPointers() const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 41 | for (const auto& [_, state] : mDeviceStates) { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 42 | if (!state.hoveringPointers.empty()) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 43 | return true; |
| 44 | } |
| 45 | } |
| 46 | return false; |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 49 | bool TouchedWindow::hasHoveringPointers(DeviceId deviceId) const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 50 | const auto stateIt = mDeviceStates.find(deviceId); |
| 51 | if (stateIt == mDeviceStates.end()) { |
| 52 | return false; |
| 53 | } |
| 54 | const DeviceState& state = stateIt->second; |
| 55 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 56 | return !state.hoveringPointers.empty(); |
Siarhei Vishniakou | e0431e4 | 2023-01-28 17:01:39 -0800 | [diff] [blame] | 57 | } |
| 58 | |
Siarhei Vishniakou | 2899c55 | 2023-07-10 18:20:46 -0700 | [diff] [blame] | 59 | void TouchedWindow::clearHoveringPointers(DeviceId deviceId) { |
| 60 | auto stateIt = mDeviceStates.find(deviceId); |
| 61 | if (stateIt == mDeviceStates.end()) { |
| 62 | return; |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 63 | } |
Siarhei Vishniakou | 2899c55 | 2023-07-10 18:20:46 -0700 | [diff] [blame] | 64 | DeviceState& state = stateIt->second; |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 65 | state.hoveringPointers.clear(); |
Siarhei Vishniakou | 2899c55 | 2023-07-10 18:20:46 -0700 | [diff] [blame] | 66 | if (!state.hasPointers()) { |
| 67 | mDeviceStates.erase(stateIt); |
| 68 | } |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 71 | bool TouchedWindow::hasHoveringPointer(DeviceId deviceId, int32_t pointerId) const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 72 | const auto stateIt = mDeviceStates.find(deviceId); |
| 73 | if (stateIt == mDeviceStates.end()) { |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 74 | return false; |
| 75 | } |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 76 | const DeviceState& state = stateIt->second; |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 77 | return hasPointerId(state.hoveringPointers, pointerId); |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 80 | void TouchedWindow::addHoveringPointer(DeviceId deviceId, const PointerProperties& pointer) { |
| 81 | std::vector<PointerProperties>& hoveringPointers = mDeviceStates[deviceId].hoveringPointers; |
| 82 | const size_t initialSize = hoveringPointers.size(); |
| 83 | std::erase_if(hoveringPointers, [&pointer](const PointerProperties& properties) { |
| 84 | return properties.id == pointer.id; |
| 85 | }); |
| 86 | if (hoveringPointers.size() != initialSize) { |
| 87 | LOG(ERROR) << __func__ << ": " << pointer << ", device " << deviceId << " was in " << *this; |
| 88 | } |
| 89 | hoveringPointers.push_back(pointer); |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 90 | } |
| 91 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 92 | void TouchedWindow::addTouchingPointers(DeviceId deviceId, |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 93 | const std::vector<PointerProperties>& pointers) { |
| 94 | std::vector<PointerProperties>& touchingPointers = mDeviceStates[deviceId].touchingPointers; |
| 95 | const size_t initialSize = touchingPointers.size(); |
| 96 | for (const PointerProperties& pointer : pointers) { |
| 97 | std::erase_if(touchingPointers, [&pointer](const PointerProperties& properties) { |
| 98 | return properties.id == pointer.id; |
| 99 | }); |
| 100 | } |
| 101 | if (touchingPointers.size() != initialSize) { |
| 102 | LOG(ERROR) << __func__ << ": " << dumpVector(pointers, streamableToString) << ", device " |
| 103 | << deviceId << " already in " << *this; |
| 104 | } |
| 105 | touchingPointers.insert(touchingPointers.end(), pointers.begin(), pointers.end()); |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | bool TouchedWindow::hasTouchingPointers() const { |
| 109 | for (const auto& [_, state] : mDeviceStates) { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 110 | if (!state.touchingPointers.empty()) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 111 | return true; |
| 112 | } |
| 113 | } |
| 114 | return false; |
| 115 | } |
| 116 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 117 | bool TouchedWindow::hasTouchingPointers(DeviceId deviceId) const { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 118 | return !getTouchingPointers(deviceId).empty(); |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 119 | } |
| 120 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 121 | bool TouchedWindow::hasTouchingPointer(DeviceId deviceId, int32_t pointerId) const { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 122 | const auto stateIt = mDeviceStates.find(deviceId); |
| 123 | if (stateIt == mDeviceStates.end()) { |
| 124 | return false; |
| 125 | } |
| 126 | const DeviceState& state = stateIt->second; |
| 127 | return hasPointerId(state.touchingPointers, pointerId); |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 130 | std::vector<PointerProperties> TouchedWindow::getTouchingPointers(DeviceId deviceId) const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 131 | const auto stateIt = mDeviceStates.find(deviceId); |
| 132 | if (stateIt == mDeviceStates.end()) { |
| 133 | return {}; |
| 134 | } |
| 135 | const DeviceState& state = stateIt->second; |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 136 | return state.touchingPointers; |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 137 | } |
| 138 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 139 | void TouchedWindow::removeTouchingPointer(DeviceId deviceId, int32_t pointerId) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 140 | std::bitset<MAX_POINTER_ID + 1> pointerIds; |
| 141 | pointerIds.set(pointerId, true); |
| 142 | |
| 143 | removeTouchingPointers(deviceId, pointerIds); |
| 144 | } |
| 145 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 146 | void TouchedWindow::removeTouchingPointers(DeviceId deviceId, |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 147 | std::bitset<MAX_POINTER_ID + 1> pointers) { |
| 148 | const auto stateIt = mDeviceStates.find(deviceId); |
| 149 | if (stateIt == mDeviceStates.end()) { |
| 150 | return; |
| 151 | } |
| 152 | DeviceState& state = stateIt->second; |
| 153 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 154 | std::erase_if(state.touchingPointers, [&pointers](const PointerProperties& properties) { |
| 155 | return pointers.test(properties.id); |
| 156 | }); |
| 157 | |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 158 | state.pilferingPointerIds &= ~pointers; |
| 159 | |
| 160 | if (!state.hasPointers()) { |
| 161 | mDeviceStates.erase(stateIt); |
Siarhei Vishniakou | 6464e46 | 2023-02-06 18:57:59 -0800 | [diff] [blame] | 162 | } |
| 163 | } |
| 164 | |
Siarhei Vishniakou | f77f60a | 2023-10-23 17:26:05 -0700 | [diff] [blame] | 165 | bool TouchedWindow::hasActiveStylus() const { |
| 166 | for (const auto& [_, state] : mDeviceStates) { |
| 167 | for (const PointerProperties& properties : state.touchingPointers) { |
| 168 | if (properties.toolType == ToolType::STYLUS) { |
| 169 | return true; |
| 170 | } |
| 171 | } |
| 172 | for (const PointerProperties& properties : state.hoveringPointers) { |
| 173 | if (properties.toolType == ToolType::STYLUS) { |
| 174 | return true; |
| 175 | } |
| 176 | } |
| 177 | } |
| 178 | return false; |
| 179 | } |
| 180 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 181 | std::set<DeviceId> TouchedWindow::getTouchingDeviceIds() const { |
| 182 | std::set<DeviceId> deviceIds; |
Prabir Pradhan | 9cd9eb6 | 2023-11-22 17:58:06 +0000 | [diff] [blame] | 183 | for (const auto& [deviceId, deviceState] : mDeviceStates) { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 184 | if (!deviceState.touchingPointers.empty()) { |
Prabir Pradhan | 9cd9eb6 | 2023-11-22 17:58:06 +0000 | [diff] [blame] | 185 | deviceIds.insert(deviceId); |
| 186 | } |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 187 | } |
| 188 | return deviceIds; |
| 189 | } |
| 190 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 191 | bool TouchedWindow::hasPilferingPointers(DeviceId deviceId) const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 192 | const auto stateIt = mDeviceStates.find(deviceId); |
| 193 | if (stateIt == mDeviceStates.end()) { |
| 194 | return false; |
| 195 | } |
| 196 | const DeviceState& state = stateIt->second; |
| 197 | |
| 198 | return state.pilferingPointerIds.any(); |
| 199 | } |
| 200 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 201 | void TouchedWindow::addPilferingPointers(DeviceId deviceId, |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 202 | std::bitset<MAX_POINTER_ID + 1> pointerIds) { |
| 203 | mDeviceStates[deviceId].pilferingPointerIds |= pointerIds; |
| 204 | } |
| 205 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 206 | void TouchedWindow::addPilferingPointer(DeviceId deviceId, int32_t pointerId) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 207 | mDeviceStates[deviceId].pilferingPointerIds.set(pointerId); |
| 208 | } |
| 209 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 210 | std::bitset<MAX_POINTER_ID + 1> TouchedWindow::getPilferingPointers(DeviceId deviceId) const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 211 | const auto stateIt = mDeviceStates.find(deviceId); |
| 212 | if (stateIt == mDeviceStates.end()) { |
| 213 | return {}; |
| 214 | } |
| 215 | const DeviceState& state = stateIt->second; |
| 216 | |
| 217 | return state.pilferingPointerIds; |
| 218 | } |
| 219 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 220 | std::map<DeviceId, std::bitset<MAX_POINTER_ID + 1>> TouchedWindow::getPilferingPointers() const { |
| 221 | std::map<DeviceId, std::bitset<MAX_POINTER_ID + 1>> out; |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 222 | for (const auto& [deviceId, state] : mDeviceStates) { |
| 223 | out.emplace(deviceId, state.pilferingPointerIds); |
| 224 | } |
| 225 | return out; |
| 226 | } |
| 227 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 228 | std::optional<nsecs_t> TouchedWindow::getDownTimeInTarget(DeviceId deviceId) const { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 229 | const auto stateIt = mDeviceStates.find(deviceId); |
| 230 | if (stateIt == mDeviceStates.end()) { |
| 231 | return {}; |
| 232 | } |
| 233 | const DeviceState& state = stateIt->second; |
| 234 | return state.downTimeInTarget; |
| 235 | } |
| 236 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 237 | void TouchedWindow::trySetDownTimeInTarget(DeviceId deviceId, nsecs_t downTime) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 238 | auto [stateIt, _] = mDeviceStates.try_emplace(deviceId); |
| 239 | DeviceState& state = stateIt->second; |
| 240 | |
| 241 | if (!state.downTimeInTarget) { |
| 242 | state.downTimeInTarget = downTime; |
| 243 | } |
| 244 | } |
| 245 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 246 | void TouchedWindow::removeAllTouchingPointersForDevice(DeviceId deviceId) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 247 | const auto stateIt = mDeviceStates.find(deviceId); |
| 248 | if (stateIt == mDeviceStates.end()) { |
| 249 | return; |
| 250 | } |
| 251 | DeviceState& state = stateIt->second; |
| 252 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 253 | state.touchingPointers.clear(); |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 254 | state.pilferingPointerIds.reset(); |
| 255 | state.downTimeInTarget.reset(); |
| 256 | |
| 257 | if (!state.hasPointers()) { |
| 258 | mDeviceStates.erase(stateIt); |
| 259 | } |
Siarhei Vishniakou | 0686f0c | 2023-05-02 11:56:15 -0700 | [diff] [blame] | 260 | } |
| 261 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 262 | void TouchedWindow::removeHoveringPointer(DeviceId deviceId, int32_t pointerId) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 263 | const auto stateIt = mDeviceStates.find(deviceId); |
| 264 | if (stateIt == mDeviceStates.end()) { |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 265 | return; |
| 266 | } |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 267 | DeviceState& state = stateIt->second; |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 268 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 269 | std::erase_if(state.hoveringPointers, [&pointerId](const PointerProperties& properties) { |
| 270 | return properties.id == pointerId; |
| 271 | }); |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 272 | |
| 273 | if (!state.hasPointers()) { |
| 274 | mDeviceStates.erase(stateIt); |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 275 | } |
| 276 | } |
| 277 | |
Siarhei Vishniakou | d38a1e0 | 2023-07-18 11:55:17 -0700 | [diff] [blame] | 278 | void TouchedWindow::removeAllHoveringPointersForDevice(DeviceId deviceId) { |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 279 | const auto stateIt = mDeviceStates.find(deviceId); |
| 280 | if (stateIt == mDeviceStates.end()) { |
| 281 | return; |
| 282 | } |
| 283 | DeviceState& state = stateIt->second; |
| 284 | |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 285 | state.hoveringPointers.clear(); |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 286 | |
| 287 | if (!state.hasPointers()) { |
| 288 | mDeviceStates.erase(stateIt); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | std::string TouchedWindow::deviceStateToString(const TouchedWindow::DeviceState& state) { |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 293 | return StringPrintf("[touchingPointers=%s, " |
| 294 | "downTimeInTarget=%s, hoveringPointers=%s, pilferingPointerIds=%s]", |
| 295 | dumpVector(state.touchingPointers, streamableToString).c_str(), |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 296 | toString(state.downTimeInTarget).c_str(), |
Siarhei Vishniakou | 1ff00cc | 2023-12-13 16:12:13 -0800 | [diff] [blame] | 297 | dumpVector(state.hoveringPointers, streamableToString).c_str(), |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 298 | bitsetToString(state.pilferingPointerIds).c_str()); |
Siarhei Vishniakou | 0686f0c | 2023-05-02 11:56:15 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Siarhei Vishniakou | 6e1e987 | 2022-11-08 17:51:35 -0800 | [diff] [blame] | 301 | std::string TouchedWindow::dump() const { |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 302 | std::string out; |
Siarhei Vishniakou | 0836a30 | 2023-05-03 13:54:30 -0700 | [diff] [blame] | 303 | std::string deviceStates = |
| 304 | dumpMap(mDeviceStates, constToString, TouchedWindow::deviceStateToString); |
| 305 | out += StringPrintf("name='%s', targetFlags=%s, mDeviceStates=%s\n", |
| 306 | windowHandle->getName().c_str(), targetFlags.string().c_str(), |
| 307 | deviceStates.c_str()); |
Siarhei Vishniakou | b581f7f | 2022-12-07 20:23:06 +0000 | [diff] [blame] | 308 | return out; |
Siarhei Vishniakou | 6e1e987 | 2022-11-08 17:51:35 -0800 | [diff] [blame] | 309 | } |
| 310 | |
Siarhei Vishniakou | 72945a0 | 2023-09-18 18:30:25 -0700 | [diff] [blame] | 311 | std::ostream& operator<<(std::ostream& out, const TouchedWindow& window) { |
| 312 | out << window.dump(); |
| 313 | return out; |
| 314 | } |
| 315 | |
Siarhei Vishniakou | 6e1e987 | 2022-11-08 17:51:35 -0800 | [diff] [blame] | 316 | } // namespace inputdispatcher |
| 317 | } // namespace android |