开机时触摸TP开机后TP不能滑动
1.
frameworks/base/core/java/android/view/ViewRootImpl.java
public void onInputEvent(InputEvent event)
打印event
MotionEvent { action=ACTION_HOVER_MOVE, actionButton=0, id[0]=0, x[0]=169.63597, y[0]=424.08994, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=53268, downTime=0, deviceId=5, source=0x1002, displayId=0, eventId=265124550 }
action为ACTION_HOVER_MOVE不正常
2.继续往下追踪
frameworks/native/services/inputflinger/reader/InputReader.cpp
296 void InputReader::processEventsForDeviceLocked(int32_t eventHubId, const RawEvent* rawEvents,
297 size_t count)
这个函数中会处理input数据。其中看到会查找对应的inputdevice,并调用对应的process函数。
frameworks/native/services/inputflinger/reader/InputDevice.cpp
void InputDevice::process(const RawEvent* rawEvents, size_t count)
然后在该函数中看到会调用mapper.process(rawEvent);
然后在frameworks/native/services/inputflinger/reader/mapper/下面可以看到各个mapper
如果屏幕是支持多点触摸,那对应的应该是MultiTouchInputMapper
而且看到class MultiTouchInputMapper : public TouchInputMapper这个派生关系。
238 void MultiTouchInputMapper::process(const RawEvent* rawEvent) {
239 TouchInputMapper::process(rawEvent);
240
241 mMultiTouchMotionAccumulator.process(rawEvent);
242 }
这里看到会调用父类的process函数。
frameworks/native/services/inputflinger/reader/mapper/TouchInputMapper.cpp
void TouchInputMapper::process(const RawEvent* rawEvent)
这个中看到会调用
1459 if (rawEvent->type == EV_SYN && rawEvent->code == SYN_REPORT) {
1460 sync(rawEvent->when, rawEvent->readTime);
1461 }
void TouchInputMapper::sync(nsecs_t when, nsecs_t readTime)
这个中又调用了
processRawTouches(false /*timeout*/)
其中又调用了cookAndDispatch
其中又调用了 cookPointerData()
然后调用dispatchPointerUsage
在这个环节中 cookAndDispatch 中有个判断 没有顺利走进去,而是走到了else里 所以没有执行dispatchPointerUsage
其中看到
2383 switch (mPointerUsage) {
2384 case PointerUsage::GESTURES:
2385 dispatchPointerGestures(when, readTime, policyFlags, false /*isTimeout*/);
2386 break;
2387 case PointerUsage::STYLUS:
2388 dispatchPointerStylus(when, readTime, policyFlags);
2389 break;
2390 case PointerUsage::MOUSE:
2391 dispatchPointerMouse(when, readTime, policyFlags);
2392 break;
2393 case PointerUsage::NONE:
2394 break;
2395 }
3.
走到else后dispatchTouches(when, readTime, policyFlags);
有这个调用,然后看到其中会调用到dispatchMotion
frameworks/native/services/inputflinger/reader/mapper/TouchInputMapper.cpp
void TouchInputMapper::cookAndDispatch(nsecs_t when, nsecs_t readTime)
正常情况下会action 分别会经历 AMOTION_EVENT_ACTION_POINTER_DOWN > AMOTION_EVENT_ACTION_MOVE > AMOTION_EVENT_ACTION_POINTER_UP
异常情况下不会走到任何一个dispatchMotion
而且发现开机后所有的触摸逻辑都会走进 if (currentIdBits == lastIdBits) 并且 if (!currentIdBits.isEmpty()) 条件不成立 currentIdBits.isEmpty()是空的
if (currentIdBits == lastIdBits) {
ALOGE("log: currentIdBits == lastIdBits");
if (!currentIdBits.isEmpty()) {
ALOGE("log: !currentIdBits.isEmpty()");
// No pointer id changes so this is a move event.
// The listener takes care of batching moves so we don't have to deal with that here.
dispatchMotion(when, readTime, policyFlags, mSource, AMOTION_EVENT_ACTION_MOVE, 0, 0,
metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE,
mCurrentCookedState.cookedPointerData.pointerProperties,
mCurrentCookedState.cookedPointerData.pointerCoords,
mCurrentCookedState.cookedPointerData.idToIndex, currentIdBits, -1,
mOrientedXPrecision, mOrientedYPrecision, mDownTime);
}
} else {
TouchInputMapper.cpp
1934 BitSet32 currentIdBits = mCurrentCookedState.cookedPointerData.touchingIdBits;
1935 BitSet32 lastIdBits = mLastCookedState.cookedPointerData.touchingIdBits;
排查该文件中,void TouchInputMapper::dispatchTouches(nsecs_t when, nsecs_t readTime, uint32_t policyFlags)这个函数中执行上面的2行代码的时候,获取的值有问题,导致后面没有调用dispatchMotion 来继续分发input。
4.控制上面赋值的是isHovering 通过log发现异常
frameworks/native/services/inputflinger/reader/mapper/MultiTouchInputMapper.cpp
如果屏幕支持多点触摸,请查看该文件,其中看到
void MultiTouchInputMapper::syncTouch(nsecs_t when, RawState* outState)
这个函数中
313 bool isHovering = mTouchButtonAccumulator.getToolType() != AMOTION_EVENT_TOOL_TYPE_MOUSE &&
314 (mTouchButtonAccumulator.isHovering() ||
315 (mRawPointerAxes.pressure.valid && inSlot->getPressure() <= 0));
316 outPointer.isHovering = isHovering;
异常时isHovering 为1 ,getPressure()为0获取不到压力值