开机时触摸TP开机后TP不能滑动

文章分析了Android设备开机后触摸屏无法滑动的问题,通过追踪从ViewRootImpl到InputFlinger的输入事件处理流程,发现dispatchPointerUsage环节存在问题,特别是isHovering变量的计算错误导致触控逻辑中断。
摘要由CSDN通过智能技术生成

开机时触摸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.
走到elsedispatchTouches(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 为1getPressure()0获取不到压力值
  • 8
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值