|
24 | 24 | #include <cinttypes> |
25 | 25 | #include <cmath> |
26 | 26 | #include <cstddef> |
| 27 | +#include <sstream> |
| 28 | +#include <string> |
27 | 29 | #include <tuple> |
28 | 30 |
|
29 | 31 | #include <math.h> |
@@ -138,6 +140,40 @@ void RawPointerData::getCentroidOfTouchingPointers(float* outX, float* outY) con |
138 | 140 | *outY = y; |
139 | 141 | } |
140 | 142 |
|
| 143 | +std::ostream& operator<<(std::ostream& out, const RawPointerData::Pointer& p) { |
| 144 | + out << "id=" << p.id << ", x=" << p.x << ", y=" << p.y << ", pressure=" << p.pressure |
| 145 | + << ", touchMajor=" << p.touchMajor << ", touchMinor=" << p.touchMinor |
| 146 | + << ", toolMajor=" << p.toolMajor << ", toolMinor=" << p.toolMinor |
| 147 | + << ", orientation=" << p.orientation << ", tiltX=" << p.tiltX << ", tiltY=" << p.tiltY |
| 148 | + << ", distance=" << p.distance << ", toolType=" << ftl::enum_string(p.toolType) |
| 149 | + << ", isHovering=" << p.isHovering; |
| 150 | + return out; |
| 151 | +} |
| 152 | + |
| 153 | +std::ostream& operator<<(std::ostream& out, const RawPointerData& data) { |
| 154 | + out << data.pointerCount << " pointers:\n"; |
| 155 | + for (uint32_t i = 0; i < data.pointerCount; i++) { |
| 156 | + out << INDENT << "[" << i << "]: " << data.pointers[i] << std::endl; |
| 157 | + } |
| 158 | + out << "ID bits: hovering = 0x" << std::hex << std::setfill('0') << std::setw(8) |
| 159 | + << data.hoveringIdBits.value << ", touching = 0x" << std::setfill('0') << std::setw(8) |
| 160 | + << data.touchingIdBits.value << ", canceled = 0x" << std::setfill('0') << std::setw(8) |
| 161 | + << data.canceledIdBits.value << std::dec; |
| 162 | + return out; |
| 163 | +} |
| 164 | + |
| 165 | +// --- TouchInputMapper::RawState --- |
| 166 | + |
| 167 | +std::ostream& operator<<(std::ostream& out, const TouchInputMapper::RawState& state) { |
| 168 | + out << "When: " << state.when << std::endl; |
| 169 | + out << "Read time: " << state.readTime << std::endl; |
| 170 | + out << "Button state: 0x" << std::setfill('0') << std::setw(8) << std::hex << state.buttonState |
| 171 | + << std::dec << std::endl; |
| 172 | + out << "Raw pointer data:" << std::endl; |
| 173 | + out << addLinePrefix(streamableToString(state.rawPointerData), INDENT); |
| 174 | + return out; |
| 175 | +} |
| 176 | + |
141 | 177 | // --- TouchInputMapper --- |
142 | 178 |
|
143 | 179 | TouchInputMapper::TouchInputMapper(InputDeviceContext& deviceContext, |
@@ -232,20 +268,8 @@ void TouchInputMapper::dump(std::string& dump) { |
232 | 268 | dump += StringPrintf(INDENT4 "TiltYScale: %0.3f\n", mTiltYScale); |
233 | 269 |
|
234 | 270 | dump += StringPrintf(INDENT3 "Last Raw Button State: 0x%08x\n", mLastRawState.buttonState); |
235 | | - dump += StringPrintf(INDENT3 "Last Raw Touch: pointerCount=%d\n", |
236 | | - mLastRawState.rawPointerData.pointerCount); |
237 | | - for (uint32_t i = 0; i < mLastRawState.rawPointerData.pointerCount; i++) { |
238 | | - const RawPointerData::Pointer& pointer = mLastRawState.rawPointerData.pointers[i]; |
239 | | - dump += StringPrintf(INDENT4 "[%d]: id=%d, x=%d, y=%d, pressure=%d, " |
240 | | - "touchMajor=%d, touchMinor=%d, toolMajor=%d, toolMinor=%d, " |
241 | | - "orientation=%d, tiltX=%d, tiltY=%d, distance=%d, " |
242 | | - "toolType=%s, isHovering=%s\n", |
243 | | - i, pointer.id, pointer.x, pointer.y, pointer.pressure, |
244 | | - pointer.touchMajor, pointer.touchMinor, pointer.toolMajor, |
245 | | - pointer.toolMinor, pointer.orientation, pointer.tiltX, pointer.tiltY, |
246 | | - pointer.distance, ftl::enum_string(pointer.toolType).c_str(), |
247 | | - toString(pointer.isHovering)); |
248 | | - } |
| 271 | + dump += INDENT3 "Last Raw Touch:\n"; |
| 272 | + dump += addLinePrefix(streamableToString(mLastRawState), INDENT4) + "\n"; |
249 | 273 |
|
250 | 274 | dump += StringPrintf(INDENT3 "Last Cooked Button State: 0x%08x\n", |
251 | 275 | mLastCookedState.buttonState); |
@@ -1476,6 +1500,22 @@ std::list<NotifyArgs> TouchInputMapper::sync(nsecs_t when, nsecs_t readTime) { |
1476 | 1500 | last.rawPointerData.touchingIdBits.value, next.rawPointerData.touchingIdBits.value, |
1477 | 1501 | last.rawPointerData.hoveringIdBits.value, next.rawPointerData.hoveringIdBits.value, |
1478 | 1502 | next.rawPointerData.canceledIdBits.value); |
| 1503 | + if (debugRawEvents() && last.rawPointerData.pointerCount == 0 && |
| 1504 | + next.rawPointerData.pointerCount == 1) { |
| 1505 | + // Dump a bunch of info to try to debug b/396796958. |
| 1506 | + // TODO(b/396796958): remove this debug dump. |
| 1507 | + ALOGD("pointerCount went from 0 to 1. last:\n%s", |
| 1508 | + addLinePrefix(streamableToString(last), INDENT).c_str()); |
| 1509 | + ALOGD("next:\n%s", addLinePrefix(streamableToString(next), INDENT).c_str()); |
| 1510 | + ALOGD("InputReader dump:"); |
| 1511 | + // The dump is too long to simply add as a format parameter in one log message, so we have |
| 1512 | + // to split it by line and log them individually. |
| 1513 | + std::istringstream stream(mDeviceContext.getContext()->dump()); |
| 1514 | + std::string line; |
| 1515 | + while (std::getline(stream, line, '\n')) { |
| 1516 | + ALOGD(INDENT "%s", line.c_str()); |
| 1517 | + } |
| 1518 | + } |
1479 | 1519 |
|
1480 | 1520 | if (!next.rawPointerData.touchingIdBits.isEmpty() && |
1481 | 1521 | !next.rawPointerData.hoveringIdBits.isEmpty() && |
|
0 commit comments