文章目录
打开LOG开关
#inputFlinger负责事件读取分发
frameworks\native\services\inputflinger\InputDispatcher.cpp
frameworks/native/services/inputflinger/InputReader.cpp
frameworks/native/services/inputflinger/Eventhub.cpp
### input库
frameworks\native\libs\input\InputTransport.cpp
##inputJNI
frameworks\base\core\java\android\view\InputEventReceiver.java
frameworks\base\core\jni\android_view_InputEventReceiver.cpp
##ViewSystem分发
frameworks\base\core\java\android\view\ViewRootImpl.java
打开LOG_NDEBUG,可以显示ALOG,打开各debug开关
@InputDispatcher.cpp
#define LOG_NDEBUG 0
// Log detailed debug messages about each inbound event notification to the dispatcher.
#define DEBUG_INBOUND_EVENT_DETAILS 1
// Log detailed debug messages about each outbound event processed by the dispatcher.
#define DEBUG_OUTBOUND_EVENT_DETAILS 1
// Log debug messages about the dispatch cycle.
#define DEBUG_DISPATCH_CYCLE 1
+++ b/core/java/android/view/ViewRootImpl.java
@@ -4804,6 +4804,9 @@ public final class ViewRootImpl implements ViewParent,
private int processPointerEvent(QueuedInputEvent q) {
final MotionEvent event = (MotionEvent)q.mEvent;
+ android.util.Log.d("william ","ViewRootImpl processPointerEvent: " + event);
+
+
mAttachInfo.mUnbufferedDispatchRequested = false;
mAttachInfo.mHandlingPointerEvent = true;
boolean handled = mView.dispatchPointerEvent(event);
@@ -6760,6 +6763,7 @@ public final class ViewRootImpl implements ViewParent,
if (mConsumeBatchedInputScheduled) {
mConsumeBatchedInputScheduled = false;
if (mInputEventReceiver != null) {
+ android.util.Log.d(TAG, "william ViewRootImpl doConsumeBatchedInput() consumeBatchedInputEvents...");
Java层的分发类
修改: core/java/android/view/InputEventReceiver.java
修改: core/java/android/view/View.java
修改: core/java/android/view/ViewRootImpl.java
修改: core/java/android/widget/AbsSeekBar.java
修改: core/java/android/widget/ProgressBar.java
修改: core/java/com/android/internal/policy/DecorView.java
修改: core/jni/android_view_InputEventReceiver.cpp
LOG和代码分析
inputReader和EventHub读取事件
//EventHub inputReader坐标和驱动坐标对应,没有问题
01-28 17:10:30.983 618 745 V EventHub /dev/input/event0 got: time=425.832555, type=3, code=53, value=366
01-28 17:10:30.983 618 745 V EventHub /dev/input/event0 got: time=425.832555, type=3, code=54, value=364
01-28 17:10:30.983 618 745 V EventHub /dev/input/event0 got: time=425.832555, type=0, code=0, value=0
01-28 17:10:30.983 618 745 D InputReader : BatchSize: 3 Count: 3
01-28 17:10:30.983 618 745 D InputReader : Input event: device=2 type=0x0003 code=0x0035 value=0x0000016e when=425832555000
01-28 17:10:30.983 618 745 D InputReader : Input event: device=2 type=0x0003 code=0x0036 value=0x0000016c when=425832555000
01-28 17:10:30.983 618 745 D InputReader : Input event: device=2 type=0x0000 code=0x0000 value=0x00000000 when=425832555000
inputDispatcher 分发事件包含服务端dispatch事件
notify是745线程,dispatch是744线程。是2个独立线程。notifyMotion应该是inputReader线程
01-28 17:10:30.983 618 745 D InputReader william: BatchSize: 3 Count: 3
01-28 17:10:30.983 618 745 D InputReader william: Input event: device=2 type=0x0003 code=0x0035 value=0x0000016e when=425832555000
01-28 17:10:30.983 618 745 D InputReader william: Input event: device=2 type=0x0003 code=0x0036 value=0x0000016c when=425832555000
//notifyMotion
01-28 17:10:30.985 618 745 D InputDispatcher william: notifyMotion - eventTime=425832555000, deviceId=2, source=0x1002, policyFlags=0x0, action=0x2, actionButton=0x0, flags=0x0, metaState=0x0, buttonState=0x0,edgeFlags=0x0, xPrecision=1.000521, yPrecision=1.001389, downTime=425739381000
//事件具体信息
01-28 17:10:30.986 618 745 D InputDispatcher william: Pointer 0: id=0, toolType=1, x=365.809479, y=363.495148, pressure=1.000000, size=0.000000, touchMajor=0.000000, touchMinor=0.000000, toolMajor=0.000000, toolMinor=0.000000, orientation=0.000000
//reset Anr timeout
01-28 17:10:30.986 618 744 D InputDispatcher william: Resetting ANR timeouts.
//start 分发 dispatchMotion Event
01-28 17:10:30.986 618 744 D InputDispatcher william: dispatchMotion - eventTime=425832555000, deviceId=2, source=0x1002, policyFlags=0x62000000, action=0x2, actionButton=0x0, flags=0x0, metaState=0x0, buttonState=0x0,edgeFlags=0x0, xPrecision=1.000521, yPrecision=1.001389, downTime=425739381000
01-28 17:10:30.986 618 744 D InputDispatcher william: Pointer 0: id=0, toolType=1, x=365.809479, y=363.495148, pressure=1.000000, size=0.000000, touchMajor=0.000000, touchMinor=0.000000, toolMajor=0.000000, toolMinor=0.000000, orientation=0.000000
//findTouchedWindow 看需要分发给几个客户端
01-28 17:10:30.986 618 744 D InputDispatcher william: findTouchedWindow finished: injectionResult=0, injectionPermission=1, timeSpentWaitingForApplication=0.0ms
01-28 17:10:30.986 618 744 D InputDispatcher william: dispatchEventToCurrentInputTargets
//分发线程744,prepareDispatchCycle -- startDispatchCycle -- publishMotionEvent -- sendMessage()
01-28 17:10:30.986 618 744 D InputDispatcher william: channel 'd082c88 StatusBar (server)' ~ prepareDispatchCycle - flags=0x00004105, xOffset=0.000000, yOffset=0.000000, scaleFactor=1.000000, pointerIds=0x80000000
01-28 17:10:30.986 618 744 D InputDispatcher william: channel 'd082c88 StatusBar (server)' ~ startDispatchCycle
01-28 17:10:30.986 618 744 D InputTransport william: channel 'd082c88 StatusBar (server)' publisher ~ publishMotionEvent: seq=547, deviceId=2, source=0x1002, action=0x2, actionButton=0x00000000, flags=0x2, edgeFlags=0x0, metaState=0x0, buttonState=0x0, xOffset=0.000000, yOffset=0.000000, xPrecision=1.000521, yPrecision=1.001389, downTime=425739381000, eventTime=425832555000, pointerCount=1
01-28 17:10:30.986 618 744 D InputTransport william: channel 'd082c88 StatusBar (server)' ~ sent message of type 2
//window服务端也重复StatusBar流程,都是在SystemServer进程
01-28 17:10:30.986 618 744 D InputDispatcher william: channel 'WindowManager (server)' ~ prepareDispatchCycle - flags=0x00000100, xOffset=0.000000, yOffset=0.000000, scaleFactor=1.000000, pointerIds=0x0
01-28 17:10:30.986 618 744 D InputDispatcher william: channel 'WindowManager (server)' ~ startDispatchCycle
01-28 17:10:30.987 618 744 D InputTransport william: channel 'WindowManager (server)' publisher ~ publishMotionEvent: seq=548, deviceId=2, source=0x1002, action=0x2, actionButton=0x00000000, flags=0x0, edgeFlags=0x0, metaState=0x0, buttonState=0x0, xOffset=0.000000, yOffset=0.000000, xPrecision=1.000521, yPrecision=1.001389, downTime=425739381000, eventTime=425832555000, pointerCount=1
01-28 17:10:30.987 618 744 D InputTransport william: channel 'WindowManager (server)' ~ sent message of type 2
inPutReader收到事件,调用notifyMotion通知给InputDispatcher,放入Inbound队列,然后wake唤醒
void InputDispatcher::notifyMotion(const NotifyMotionArgs* args) {
#if DEBUG_INBOUND_EVENT_DETAILS
ALOGD("notifyMotion - eventTime=%lld, deviceId=%d, source=0x%x, policyFlags=0x%x, "
...
needWake = enqueueInboundEventLocked(newEntry);
mLock.unlock();
} // release lock
if (needWake) {
mLooper->wake();
}
}
然后开始resetANRTimeoutsLocked ,开始分发事件dispatchMotionLocked,然后到dispatchEventLocked
void InputDispatcher::dispatchOnceInnerLocked(nsecs_t* nextWakeupTime) {
nsecs_t currentTime = now();
...
// Get ready to dispatch the event.
resetANRTimeoutsLocked();
}
case EventEntry::TYPE_MOTION: {
MotionEntry* typedEntry = static_cast<MotionEntry*>(mPendingEvent);
if (dropReason == DROP_REASON_NOT_DROPPED && isAppSwitchDue) {
dropReason = DROP_REASON_APP_SWITCH;
}
if (dropReason == DROP_REASON_NOT_DROPPED
&& isStaleEventLocked(currentTime, typedEntry)) {
dropReason = DROP_REASON_STALE;
}
if (dropReason == DROP_REASON_NOT_DROPPED && mNextUnblockedEvent) {
dropReason = DROP_REASON_BLOCKED;
}
done = dispatchMotionLocked(currentTime, typedEntry,
&dropReason, nextWakeupTime);
break;
}
}
logOutboundMotionDetailsLocked打印DispatchMotion LOG开始分发
bool InputDispatcher::dispatchMotionLocked(
nsecs_t currentTime, MotionEntry* entry, DropReason* dropReason, nsecs_t* nextWakeupTime) {
// Preprocessing.
if (! entry->dispatchInProgress) {
entry->dispatchInProgress = true;
logOutboundMotionDetailsLocked("dispatchMotion - ", entry);
}
//inputTargets这里就是需要接收的个数,是一个线程,通过for循环来一个一个分发
打印LOG dispatchEventToCurrentInputTargets,然后执行prepareDispatchCycleLocked
void InputDispatcher::dispatchEventLocked(nsecs_t currentTime,
EventEntry* eventEntry, const Vector<InputTarget>& inputTargets) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("dispatchEventToCurrentInputTargets");
#endif
pokeUserActivityLocked(eventEntry);
for (size_t i = 0; i < inputTargets.size(); i++) {
const InputTarget& inputTarget = inputTargets.itemAt(i);
ssize_t connectionIndex = getConnectionIndexLocked(inputTarget.inputChannel);
if (connectionIndex >= 0) {
sp<Connection> connection = mConnectionsByFd.valueAt(connectionIndex);
prepareDispatchCycleLocked(currentTime, connection, eventEntry, &inputTarget); //走这里
} else {
}
}
}
void InputDispatcher::enqueueDispatchEntriesLocked(nsecs_t currentTime,
const sp<Connection>& connection, EventEntry* eventEntry, const InputTarget* inputTarget) {
bool wasEmpty = connection->outboundQueue.isEmpty();
// Enqueue dispatch entries for the requested modes.
enqueueDispatchEntryLocked(connection, eventEntry, inputTarget,
InputTarget::FLAG_DISPATCH_AS_HOVER_EXIT);
enqueueDispatchEntryLocked(connection, eventEntry, inputTarget,
InputTarget::FLAG_DISPATCH_AS_OUTSIDE);
enqueueDispatchEntryLocked(connection, eventEntry, inputTarget,
InputTarget::FLAG_DISPATCH_AS_HOVER_ENTER);
enqueueDispatchEntryLocked(connection, eventEntry, inputTarget,
InputTarget::FLAG_DISPATCH_AS_IS);
enqueueDispatchEntryLocked(connection, eventEntry, inputTarget,
InputTarget::FLAG_DISPATCH_AS_SLIPPERY_EXIT);
enqueueDispatchEntryLocked(connection, eventEntry, inputTarget,
InputTarget::FLAG_DISPATCH_AS_SLIPPERY_ENTER);
// If the outbound queue was previously empty, start the dispatch cycle going.
if (wasEmpty && !connection->outboundQueue.isEmpty()) {
startDispatchCycleLocked(currentTime, connection);
}
}
startDispatchCycleLocke开始dispatch事件,是在一个while循环里,调用到inputPublisher.publishMotionEvent
void InputDispatcher::startDispatchCycleLocked(nsecs_t currentTime,
const sp<Connection>& connection) {
#if DEBUG_DISPATCH_CYCLE
ALOGD("channel '%s' ~ startDispatchCycle",
connection->getInputChannelName());
#endif
while (connection->status == Connection::STATUS_NORMAL
&& !connection->outboundQueue.isEmpty()) {
DispatchEntry* dispatchEntry = connection->outboundQueue.head;
dispatchEntry->deliveryTime = currentTime;
...
case EventEntry::TYPE_MOTION: {
MotionEntry* motionEntry = static_cast<MotionEntry*>(eventEntry);
...
// Publish the motion event.
status = connection->inputPublisher.publishMotionEvent(dispatchEntry->seq,
motionEntry->deviceId, motionEntry->source, motionEntry->displayId,
dispatchEntry->resolvedAction, motionEntry->actionButton,
dispatchEntry->resolvedFlags, motionEntry->edgeFlags,
motionEntry->metaState, motionEntry->buttonState,
xOffset, yOffset, motionEntry->xPrecision, motionEntry->yPrecision,
motionEntry->downTime, motionEntry->eventTime,
motionEntry->pointerCount, motionEntry->pointerProperties,
usingCoords);
break;
}
...
// Re-enqueue the event on the wait queue.
connection->outboundQueue.dequeue(dispatchEntry);
traceOutboundQueueLengthLocked(connection);
connection->waitQueue.enqueueAtTail(dispatchEntry);
traceWaitQueueLengthLocked(connection);
}
}
InputTransport.cpp的publishMotionEvent,打印LOG,并且sendMessage
status_t InputPublisher::publishMotionEvent(
uint32_t seq,
{
#if DEBUG_TRANSPORT_ACTIONS
ALOGD("channel '%s' publisher ~ publishMotionEvent: seq=%u, deviceId=%d, source=0x%x, "
"action=0x%x, actionButton=0x%08x, flags=0x%x, edgeFlags=0x%x, "
"metaState=0x%x, buttonState=0x%x, xOffset=%f, yOffset=%f, "
"xPrecision=%f, yPrecision=%f, downTime=%lld, eventTime=%lld, "
"pointerCount=%" PRIu32,
mChannel->getName().string(), seq,
deviceId, source, action, actionButton, flags, edgeFlags, metaState, buttonState,
xOffset, yOffset, xPrecision, yPrecision, downTime, eventTime, pointerCount);
#endif
...
return mChannel->sendMessage(&msg);
}
sendMessage调用LOG sent message完成服务端dispatcher
status_t InputChannel::sendMessage(const InputMessage* msg) {
size_t msgLength = msg->size();
ssize_t nWrite;
do {
nWrite = ::send(mFd, msg, msgLength, MSG_DONTWAIT | MSG_NOSIGNAL);
} while (nWrite == -1 && errno == EINTR);
...
#if DEBUG_CHANNEL_MESSAGES
ALOGD("channel '%s' ~ sent message of type %d", mName.string(), msg->header.type);
#endif
return OK;
}
Target客户端消费事件并派发流程
01-28 17:10:30.985 618 745 D InputDispatcher william: notifyMotion - eventTime=425832555000, deviceId=2, source=0x1002, policyFlags=0x0, action=0x2, actionButton=0x0, flags=0x0, metaState=0x0, buttonState=0x0,edgeFlags=0x0, xPrecision=1.000521, yPrecision=1.001389, downTime=425739381000
01-28 17:10:30.986 618 745 D InputDispatcher william: Pointer 0: id=0, toolType=1, x=365.809479, y=363.495148, pressure=1.000000, size=0.000000, touchMajor=0.000000, touchMinor=0.000000, toolMajor=0.000000, toolMinor=0.000000, orientation=0.000000
01-28 17:10:30.986 618 744 D InputDispatcher william: Resetting ANR timeouts.
01-28 17:10:30.986 618 744 D InputDispatcher william: dispatchMotion - eventTime=425832555000, deviceId=2, source=0x1002, policyFlags=0x62000000, action=0x2, actionButton=0x0, flags=0x0, metaState=0x0, buttonState=0x0,edgeFlags=0x0, xPrecision=1.000521, yPrecision=1.001389, downTime=425739381000
01-28 17:10:30.986 618 744 D InputDispatcher william: Pointer 0: id=0, toolType=1, x=365.809479, y=363.495148, pressure=1.000000, size=0.000000, touchMajor=0.000000, touchMinor=0.000000, toolMajor=0.000000, toolMinor=0.000000, orientation=0.000000
01-28 17:10:30.986 618 744 D InputDispatcher william: findTouchedWindow finished: injectionResult=0, injectionPermission=1, timeSpentWaitingForApplication=0.0ms
01-28 17:10:30.986 618 744 D InputDispatcher william: dispatchEventToCurrentInputTargets
01-28 17:10:30.986 618 744 D InputDispatcher william: channel 'd082c88 StatusBar (server)' ~ prepareDispatchCycle - flags=0x00004105, xOffset=0.000000, yOffset=0.000000, scaleFactor=1.000000, pointerIds=0x80000000
01-28 17:10:30.986 618 744 D InputDispatcher william: channel 'd082c88 StatusBar (server)' ~ startDispatchCycle
01-28 17:10:30.986 618 744 D InputTransport william: channel 'd082c88 StatusBar (server)' publisher ~ publishMotionEvent: seq=547, deviceId=2, source=0x1002, action=0x2, actionButton=0x00000000, flags=0x2, edgeFlags=0x0, metaState=0x0, buttonState=0x0, xOffset=0.000000, yOffset=0.000000, xPrecision=1.000521, yPrecision=1.001389, downTime=425739381000, eventTime=425832555000, pointerCount=1
01-28 17:10:30.986 618 744 D InputTransport william: channel 'd082c88 StatusBar (server)' ~ sent message of type 2
01-28 17:10:30.986 618 744 D InputDispatcher william: channel 'WindowManager (server)' ~ prepareDispatchCycle - flags=0x00000100, xOffset=0.000000, yOffset=0.000000, scaleFactor=1.000000, pointerIds=0x0
01-28 17:10:30.986 618 744 D InputDispatcher william: channel 'WindowManager (server)' ~ startDispatchCycle
01-28 17:10:30.987 618 744 D InputTransport william: channel 'WindowManager (server)' publisher ~ publishMotionEvent: seq=548, deviceId=2, source=0x1002, action=0x2, actionButton=0x00000000, flags=0x0, edgeFlags=0x0, metaState=0x0, buttonState=0x0, xOffset=0.000000, yOffset=0.000000, xPrecision=1.000521, yPrecision=1.001389, downTime=425739381000, eventTime=425832555000, pointerCount=1
01-28 17:10:30.987 618 744 D InputTransport william: channel 'WindowManager (server)' ~ sent message of type 2
01-28 17:10:30.987 652 3677 D ISClib : sendMessage channel(1) msgID(1058) len(2)
01-28 17:10:30.987 618 688 D InputEventReceiver william: NativeInputEventReceiver handleEvent receiveFd.
01-28 17:10:30.987 618 744 D InputDispatcher william: Resetting ANR timeouts.
01-28 17:10:30.988 836 836 D InputEventReceiver william: channel 'd082c88 StatusBar (client)' ~ Finished input event.
01-28 17:10:30.988 836 836 D InputTransport william: channel 'd082c88 StatusBar (client)' consumer ~ sendFinishedSignal: seq=545, handled=true
01-28 17:10:30.988 836 836 D InputTransport william: channel 'd082c88 StatusBar (client)' ~ sent message of type 3
01-28 17:10:30.988 836 836 D InputTransport william: channel 'd082c88 StatusBar (client)' consumer ~ consume: consumeBatches=true, frameTime=425833011422
01-28 17:10:30.988 836 836 D InputTransport william: channel 'd082c88 StatusBar (client)' ~ received message of type 2
01-28 17:10:30.988 836 836 D InputTransport william: channel 'd082c88 StatusBar (client)' consumer ~ started batch event
01-28 17:10:30.988 836 836 D InputTransport william: channel 'd082c88 StatusBar (client)' ~ receive message failed, errno=11
//consumeEvents 触发
01-28 17:10:30.988 836 836 D InputEventReceiver william: channel 'd082c88 StatusBar (client)' ~ Dispatching batched input event pending notification.
//这个是vsync_input信号,触发consumeEvents
01-28 17:10:30.998 836 836 D ViewRootImpl: william ViewRootImpl doConsumeBatchedInput() consumeBatchedInputEvents...
//Consuming input events NativeInputEventReceiver::consumeEvents函数
01-28 17:10:30.998 836 836 D InputEventReceiver william: channel 'd082c88 StatusBar (client)' ~ Consuming input events, consumeBatches=true, frameTime=425845530116.
//InputConsumer::consume 带flag
//status_t InputConsumer::consume(InputEventFactoryInterface* factory,
// bool consumeBatches, nsecs_t frameTime, uint32_t* outSeq, InputEvent** outEvent,
// int32_t* displayId, int* motionEventType, int* touchMoveNumber, bool* flag) {
01-28 17:10:30.998 836 836 D InputTransport william: channel 'd082c88 StatusBar (client)' consumer ~ consume: consumeBatches=true, frameTime=425845530116
//InputConsumer::consume 的mChannel->receiveMessage,失败返回-11
01-28 17:10:30.998 836 836 D InputTransport william: channel 'd082c88 StatusBar (client)' ~ receive message failed, errno=11
01-28 17:10:30.998 836 836 D InputTransport william: [0] - out (403.045, 354.742), cur (365.809, 363.495), other (280.854, 383.467), alpha -0.438
01-28 17:10:30.998 836 836 D InputTransport william: channel 'd082c88 StatusBar (client)' consumer ~ consumed batch event, seq=547
case AINPUT_EVENT_TYPE_MOTION: {
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Received motion event.", getInputChannelName());
}
MotionEvent* motionEvent = static_cast<MotionEvent*>(inputEvent);
if ((motionEvent->getAction() & AMOTION_EVENT_ACTION_MOVE) && outConsumedBatch) {
*outConsumedBatch = true;
}
ALOGD("android_view_InputEventReceiver getXOffset:%f getYOffset:%f getXPrecision:%f getYPrecision:%f", motionEvent->getXOffset(), motionEvent->getYOffset(), motionEvent->getXPrecision(),motionEvent->getYPrecision() );
ALOGD("event getEventTime %lld ", (long long)motionEvent->getEventTime());
inputEventObj = android_view_MotionEvent_obtainAsCopy(env, motionEvent);
break;
}
}
//consume之后,走到AINPUT_EVENT_TYPE_MOTION,打印received
01-28 17:10:30.999 836 836 D InputEventReceiver william: channel 'd082c88 StatusBar (client)' ~ Received motion event.
01-28 17:10:30.999 836 836 D InputEventReceiver william: android_view_InputEventReceiver getXOffset:0.000000 getYOffset:0.000000 getXPrecision:1.000521 getYPrecision:1.001389
01-28 17:10:30.999 836 836 D InputEventReceiver william: event getEventTime 425840530116
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Dispatching input event.", getInputChannelName());
}
env->CallVoidMethod(receiverObj.get(),
gInputEventReceiverClassInfo.dispatchInputEvent, seq, inputEventObj,
displayId);
if (env->ExceptionCheck()) {
ALOGE("Exception dispatching input event.");
skipCallbacks = true;
}
//dispatchInputEvent 调用java的
01-28 17:10:30.999 836 836 D InputEventReceiver william: channel 'd082c88 StatusBar (client)' ~ Dispatching input event.
//JAva层回调
01-28 17:10:30.999 836 836 D InputEventReceiver: william InputEventReceiver.java dispatchInputEvent InputEvent:MotionEvent { action=ACTION_MOVE, actionButton=0, id[0]=0, x[0]=403.04468, y[0]=354.74152, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=425840, downTime=425739, deviceId=2, source=0x1002 }
//到View的回调
01-28 17:10:30.999 836 836 D william : ViewRootImpl processPointerEvent: MotionEvent { action=ACTION_MOVE, actionButton=0, id[0]=0, x[0]=403.04468, y[0]=354.74152, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=425840, downTime=425739, deviceId=2, source=0x1002 }
01-28 17:10:31.000 836 836 D william : View dispatchTouchEvent: MotionEvent { action=ACTION_MOVE, actionButton=0, id[0]=0, x[0]=331.04468, y[0]=6.741516, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, metaState=0, flags=0x2, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=425840, downTime=425739, deviceId=2, source=0x1002 }
01-28 17:10:31.000 836 836 D william : AbsSeekBar ACTION_MOVE event:X: 331.04468 Y: 6.741516 RawX: 403.04468 RawY: 354.74152
01-28 17:10:31.000 836 836 D william : AbsSeekBar trackTouchEvent progress:68
status_t NativeInputEventReceiver::finishInputEvent(uint32_t seq, bool handled) {
if (kDebugDispatchCycle) {
ALOGD("channel '%s' ~ Finished input event.", getInputChannelName());
}
//JNI
01-28 17:10:31.000 836 836 D InputEventReceiver william: channel 'd082c88 StatusBar (client)' ~ Finished input event.
01-28 17:10:31.000 836 836 D InputTransport william: channel 'd082c88 StatusBar (client)' consumer ~ sendFinishedSignal: seq=547, handled=true
01-28 17:10:31.001 836 836 D InputTransport william: channel 'd082c88 StatusBar (client)' ~ sent message of type 3
01-28 17:10:31.001 836 836 D InputTransport william: channel 'd082c88 StatusBar (client)' consumer ~ consume: consumeBatches=true, frameTime=425845530116
01-28 17:10:31.001 836 836 D InputTransport william: channel 'd082c88 StatusBar (client)' ~ receive message failed, errno=11
status_t InputConsumer::consume(InputEventFactoryInterface* factory,
bool consumeBatches, nsecs_t frameTime, uint32_t* outSeq, InputEvent** outEvent,
int32_t* displayId, int* motionEventType, int* touchMoveNumber, bool* flag) {
#if DEBUG_TRANSPORT_ACTIONS
ALOGD("channel '%s' consumer ~ consume: consumeBatches=%s, frameTime=%lld", //打印LOG
mChannel->getName().string(), consumeBatches ? "true" : "false", frameTime);
#endif
*outSeq = 0;
*outEvent = NULL;
*displayId = -1; // Invalid display.
// Fetch the next input message.
// Loop until an event can be returned or no additional events are received.
while (!*outEvent) {
if (mMsgDeferred) {
// mMsg contains a valid input message from the previous call to consume
// that has not yet been processed.
mMsgDeferred = false;
} else {
// Receive a fresh message.
status_t result = mChannel->receiveMessage(&mMsg); //接收消息失败LOG
if (result == 0) {
if ((mMsg.body.motion.action & AMOTION_EVENT_ACTION_MASK) == AMOTION_EVENT_ACTION_MOVE){
mTouchMoveCounter++;
} else {
mTouchMoveCounter = 0;
}
*flag = true;
}
*motionEventType = mMsg.body.motion.action & AMOTION_EVENT_ACTION_MASK;
*touchMoveNumber = mTouchMoveCounter;
if (result) {
// Consume the next batched event unless batches are being held for later.
if (consumeBatches || result != WOULD_BLOCK) {
result = consumeBatch(factory, frameTime, outSeq, outEvent, displayId, touchMoveNumber); //consumeBatch
if (*outEvent) {
#if DEBUG_TRANSPORT_ACTIONS
ALOGD("channel '%s' consumer ~ consumed batch event, seq=%u",
mChannel->getName().string(), *outSeq); //打印此LOG
#endif
break;
}
}
return result;
}
}
status_t InputConsumer::consumeBatch(InputEventFactoryInterface* factory,
nsecs_t frameTime, uint32_t* outSeq, InputEvent** outEvent, int32_t* displayId,
int* touchMoveNumber) {
status_t result;
for (size_t i = mBatches.size(); i > 0; ) {
i--;
Batch& batch = mBatches.editItemAt(i);
if (frameTime < 0) {
result = consumeSamples(factory, batch, batch.samples.size(),
outSeq, outEvent, displayId);
mBatches.removeAt(i);
return result;
}
nsecs_t sampleTime = frameTime;
if (mResampleTouch && (*touchMoveNumber !=1)) {
sampleTime -= RESAMPLE_LATENCY;
}
ssize_t split = findSampleNoLaterThan(batch, sampleTime);
if (split < 0) {
continue;
}
result = consumeSamples(factory, batch, split + 1, outSeq, outEvent, displayId);
const InputMessage* next;
if (batch.samples.isEmpty()) {
mBatches.removeAt(i);
next = NULL;
} else {
next = &batch.samples.itemAt(0);
}
if (!result && mResampleTouch) {
resampleTouchState(sampleTime, static_cast<MotionEvent*>(*outEvent), next); //打印lOG,重新采样
}
return result;
}
return WOULD_BLOCK;
}
JAVA事件分发log
1-27 14:27:43.592 1233 1233 W System.err: java.lang.Exception: william
01-27 14:27:43.592 1233 1233 W System.err: at android.widget.ProgressBar.setProgressInternal(ProgressBar.java:1407)
01-27 14:27:43.593 1233 1233 W System.err: at android.widget.AbsSeekBar.trackTouchEvent(AbsSeekBar.java:878)
01-27 14:27:43.593 1233 1233 W System.err: at android.widget.AbsSeekBar.onTouchEvent(AbsSeekBar.java:785)
01-27 14:27:43.593 1233 1233 W System.err: at com.android.systemui.settings.ToggleSeekBar.onTouchEvent(ToggleSeekBar.java:53)
01-27 14:27:43.593 1233 1233 W System.err: at android.view.View.dispatchTouchEvent(View.java:11785)
01-27 14:27:43.593 1233 1233 W System.err: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
01-27 14:27:43.593 1233 1233 W System.err: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
01-27 14:27:43.593 1233 1233 W System.err: at com.android.systemui.settings.tsp.BrightnessView.dispatchTouchEvent(BrightnessView.java:103)
01-27 14:27:43.593 1233 1233 W System.err: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
01-27 14:27:43.593 1233 1233 W System.err: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
01-27 14:27:43.593 1233 1233 W System.err: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
01-27 14:27:43.593 1233 1233 W System.err: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
01-27 14:27:43.593 1233 1233 W System.err: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
01-27 14:27:43.593 1233 1233 W System.err: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
01-27 14:27:43.594 1233 1233 W System.err: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
01-27 14:27:43.594 1233 1233 W System.err: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
01-27 14:27:43.594 1233 1233 W System.err: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
01-27 14:27:43.594 1233 1233 W System.err: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
01-27 14:27:43.602 1233 1233 W System.err: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
01-27 14:27:43.602 1233 1233 W System.err: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
01-27 14:27:43.602 1233 1233 W System.err: at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2968)
01-27 14:27:43.603 1233 1233 W System.err: at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2657)
01-27 14:27:43.603 1233 1233 W System.err: at com.android.systemui.statusbar.phone.StatusBarWindowView.dispatchTouchEvent(StatusBarWindowView.java:290)
01-27 14:27:43.603 1233 1233 W System.err: at android.view.View.dispatchPointerEvent(View.java:12024)
01-27 14:27:43.603 1233 1233 W System.err: at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4809)
01-27 14:27:43.603 1233 1233 W System.err: at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4623)
01-27 14:27:43.603 1233 1233 W System.err: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
01-27 14:27:43.603 1233 1233 W System.err: at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4214)
01-27 14:27:43.603 1233 1233 W System.err: at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4180)
01-27 14:27:43.603 1233 1233 W System.err: at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4307)
01-27 14:27:43.603 1233 1233 W System.err: at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4188)
01-27 14:27:43.603 1233 1233 W System.err: at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4364)
01-27 14:27:43.603 1233 1233 W System.err: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
01-27 14:27:43.603 1233 1233 W System.err: at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4214)
01-27 14:27:43.604 1233 1233 W System.err: at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4180)
01-27 14:27:43.604 1233 1233 W System.err: at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4188)
01-27 14:27:43.604 1233 1233 W System.err: at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4161)
01-27 14:27:43.604 1233 1233 W System.err: at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6689)
01-27 14:27:43.604 1233 1233 W System.err: at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6663)
01-27 14:27:43.604 1233 1233 W System.err: at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6624)
01-27 14:27:43.604 1233 1233 W System.err: at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6792)
01-27 14:27:43.605 1233 1233 W System.err: at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:187)
01-27 14:27:43.605 1233 1233 W System.err: at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
01-27 14:27:43.605 1233 1233 W System.err: at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:178)
01-27 14:27:43.605 1233 1233 W System.err: at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:6763)
01-27 14:27:43.606 1233 1233 W System.err: at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:6815)
01-27 14:27:43.606 1233 1233 W System.err: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:966)
01-27 14:27:43.606 1233 1233 W System.err: at android.view.Choreographer.doCallbacks(Choreographer.java:778)
01-27 14:27:43.606 1233 1233 W System.err: at android.view.Choreographer.doFrame(Choreographer.java:707)
01-27 14:27:43.606 1233 1233 W System.err: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:952)
01-27 14:27:43.606 1233 1233 W System.err: at android.os.Handler.handleCallback(Handler.java:790)
01-27 14:27:43.606 1233 1233 W System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
01-27 14:27:43.606 1233 1233 W System.err: at android.os.Looper.loop(Looper.java:164)
01-27 14:27:43.606 1233 1233 W System.err: at android.app.ActivityThread.main(ActivityThread.java:6549)
01-27 14:27:43.606 1233 1233 W System.err: at java.lang.reflect.Method.invoke(Native Method)
01-27 14:27:43.606 1233 1233 W System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
01-27 14:27:43.606 1233 1233 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
01-27 14:27:43.606 1233 1233 D william : ProgressBar setProgressInternal progress:19
01-27 14:27:43.606 1233 1233 D william : ProgressBar setProgressInternal refreshProgress:19