Input improvements and bug fixes.

Associate each motion axis with the source from which it comes.
It is possible for multiple sources of the same device to define
the same axis.  This fixes new API that was introduced in MR1.
(Bug: 4066146)

Fixed a bug that might cause a segfault when using a trackball.

Only fade out the mouse pointer when touching the touch screen,
ignore other touch pads.

Changed the plural "sources" to "source" in several places in
the InputReader where we intend to refer to a particular source
rather than to a combination of sources.

Improved the batching code to support batching events from different
sources of the same device in parallel.  (Bug: 3391564)

Change-Id: I0189e18e464338f126f7bf94370b928e1b1695f2
diff --git a/services/input/InputDispatcher.cpp b/services/input/InputDispatcher.cpp
index 487ecff..19295e6d 100644
--- a/services/input/InputDispatcher.cpp
+++ b/services/input/InputDispatcher.cpp
@@ -2343,17 +2343,17 @@
                 }
 
                 MotionEntry* motionEntry = static_cast<MotionEntry*>(entry);
-                if (motionEntry->deviceId != deviceId) {
-                    // Keep looking for this device.
+                if (motionEntry->deviceId != deviceId
+                        || motionEntry->source != source) {
+                    // Keep looking for this device and source.
                     continue;
                 }
 
                 if (motionEntry->action != action
-                        || motionEntry->source != source
                         || motionEntry->pointerCount != pointerCount
                         || motionEntry->isInjected()) {
-                    // Last motion event in the queue for this device is not compatible for
-                    // appending new samples.  Stop here.
+                    // Last motion event in the queue for this device and source is
+                    // not compatible for appending new samples.  Stop here.
                     goto NoBatchingOrStreaming;
                 }