This article is based on android 4.2.1. Starting from the view to get the event information, first do some detection and preprocessing of the event; if the event has a problem, discard the information, otherwise start to analyze the event.
First determine whether mListenerInfo is empty and whether the onTouch event is set; if the event is set, the onTouch event is executed. When the onTouch method consumes the event, the message delivery ends; otherwise, the event is handed over to the OnTouchEvent method for processing. The event is still a long press event. If the event is not consumed, the event is thrown to the parent control or the end event (the end event if there is no parent control).
7226 public boolean dispatchTouchEvent(MotionEvent event) {
7227 if (mInputEventConsistencyVerifier != null) {
7228 mInputEventConsistencyVerifier.onTouchEvent(event, 0);
7229 }
7230
7231 if (onFilterTouchEventForSecurity(event)) {
7232 //noinspection SimplifiableIfStatement
7233 ListenerInfo li = mListenerInfo;//包括onTouch,onClick和onLongClick事件
7234 if (li != null && li.mOnTouchListener != null && (mViewFlags & ENABLED_MASK) == ENABLED
7235 && li.mOnTouchListener.onTouch(this, event)) {
7236 return true;
7237 }
7238
7239 if (onTouchEvent(event)) {
7240 return true;
7241 }
7242 }
7243
7244 if (mInputEventConsistencyVerifier != null) {
7245 mInputEventConsistencyVerifier.onUnhandledEvent(event, 0);
7246 }
7247 return false;
7248 }