Add support for arbitrary axes in MotionEvents.

This change makes it possible to extend the set of axes that
are reported in MotionEvents by defining new axis constants.

The MotionEvent object is now backed by its C++ counterpart
to avoid having to maintain multiple representations of the
same data.

Change-Id: Ibe93c90d4b390d43c176cce48d558d20869ee608
diff --git a/services/input/InputDispatcher.cpp b/services/input/InputDispatcher.cpp
index cbfdd75..466a9b3 100644
--- a/services/input/InputDispatcher.cpp
+++ b/services/input/InputDispatcher.cpp
@@ -482,8 +482,10 @@
                 && (motionEntry->source & AINPUT_SOURCE_CLASS_POINTER)
                 && mInputTargetWaitCause == INPUT_TARGET_WAIT_CAUSE_APPLICATION_NOT_READY
                 && mInputTargetWaitApplication != NULL) {
-            int32_t x = int32_t(motionEntry->firstSample.pointerCoords[0].x);
-            int32_t y = int32_t(motionEntry->firstSample.pointerCoords[0].y);
+            int32_t x = int32_t(motionEntry->firstSample.pointerCoords[0].
+                    getAxisValue(AINPUT_MOTION_AXIS_X));
+            int32_t y = int32_t(motionEntry->firstSample.pointerCoords[0].
+                    getAxisValue(AINPUT_MOTION_AXIS_Y));
             const InputWindow* touchedWindow = findTouchedWindowAtLocked(x, y);
             if (touchedWindow
                     && touchedWindow->inputWindowHandle != NULL
@@ -888,11 +890,15 @@
                 "touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, "
                 "orientation=%f",
                 i, entry->pointerIds[i],
-                sample->pointerCoords[i].x, sample->pointerCoords[i].y,
-                sample->pointerCoords[i].pressure, sample->pointerCoords[i].size,
-                sample->pointerCoords[i].touchMajor, sample->pointerCoords[i].touchMinor,
-                sample->pointerCoords[i].toolMajor, sample->pointerCoords[i].toolMinor,
-                sample->pointerCoords[i].orientation);
+                sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_X),
+                sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_Y),
+                sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_PRESSURE),
+                sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_SIZE),
+                sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR),
+                sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR),
+                sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR),
+                sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR),
+                sample->pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION));
     }
 
     // Keep in mind that due to batching, it is possible for the number of samples actually
@@ -1188,8 +1194,10 @@
         /* Case 1: New splittable pointer going down. */
 
         int32_t pointerIndex = getMotionEventActionPointerIndex(action);
-        int32_t x = int32_t(entry->firstSample.pointerCoords[pointerIndex].x);
-        int32_t y = int32_t(entry->firstSample.pointerCoords[pointerIndex].y);
+        int32_t x = int32_t(entry->firstSample.pointerCoords[pointerIndex].
+                getAxisValue(AINPUT_MOTION_AXIS_X));
+        int32_t y = int32_t(entry->firstSample.pointerCoords[pointerIndex].
+                getAxisValue(AINPUT_MOTION_AXIS_Y));
         const InputWindow* newTouchedWindow = NULL;
         const InputWindow* topErrorWindow = NULL;
 
@@ -2275,11 +2283,16 @@
         LOGD("  Pointer %d: id=%d, x=%f, y=%f, pressure=%f, size=%f, "
                 "touchMajor=%f, touchMinor=%f, toolMajor=%f, toolMinor=%f, "
                 "orientation=%f",
-                i, pointerIds[i], pointerCoords[i].x, pointerCoords[i].y,
-                pointerCoords[i].pressure, pointerCoords[i].size,
-                pointerCoords[i].touchMajor, pointerCoords[i].touchMinor,
-                pointerCoords[i].toolMajor, pointerCoords[i].toolMinor,
-                pointerCoords[i].orientation);
+                i, pointerIds[i],
+                pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_X),
+                pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_Y),
+                pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_PRESSURE),
+                pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_SIZE),
+                pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MAJOR),
+                pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOUCH_MINOR),
+                pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MAJOR),
+                pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_TOOL_MINOR),
+                pointerCoords[i].getAxisValue(AINPUT_MOTION_AXIS_ORIENTATION));
     }
 #endif
     if (! validateMotionEvent(action, pointerCount, pointerIds)) {