Fix AMotionEvent_getHistorical* to take const AInputEvent* motion_event

See b.android.com/55873

Change-Id: I92c549e1a595662d4df8fa0e47675ccb2b8814fd
fix mem leak on error handling

Change-Id: I40d8e371c46184aa701fa676246201a9d8f6e27d