From e85c348731e0364c3e3acdf1b76cd402ee25de71 Mon Sep 17 00:00:00 2001 From: Vaibhav Date: Fri, 11 Feb 2022 17:50:41 +0530 Subject: Add implementation for new NDK functions added to input.h Added new methods for getActionButton and getClassification in input.h. In this CL we are adding implementations for the corresponding functions Test: atest android.view.cts.MotionEventTest Bug: 213266814 Change-Id: Ia7c7b83fe19bac7d5e5c7c107e86328e160ba2b5 --- native/android/input.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'native/android/input.cpp') diff --git a/native/android/input.cpp b/native/android/input.cpp index c06c81ed03ec..a231d8f153e7 100644 --- a/native/android/input.cpp +++ b/native/android/input.cpp @@ -283,6 +283,21 @@ float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event, axis, pointer_index, history_index); } +int32_t AMotionEvent_getActionButton(const AInputEvent* motion_event) { + return static_cast(motion_event)->getActionButton(); +} + +int32_t AMotionEvent_getClassification(const AInputEvent* motion_event) { + switch (static_cast(motion_event)->getClassification()) { + case android::MotionClassification::NONE: + return AMOTION_EVENT_CLASSIFICATION_NONE; + case android::MotionClassification::AMBIGUOUS_GESTURE: + return AMOTION_EVENT_CLASSIFICATION_AMBIGUOUS_GESTURE; + case android::MotionClassification::DEEP_PRESS: + return AMOTION_EVENT_CLASSIFICATION_DEEP_PRESS; + } +} + const AInputEvent* AMotionEvent_fromJava(JNIEnv* env, jobject motionEvent) { MotionEvent* eventSrc = android::android_view_MotionEvent_getNativePtr(env, motionEvent); if (eventSrc == nullptr) { -- cgit v1.2.3-59-g8ed1b