diff options
author | 2022-02-11 17:50:41 +0530 | |
---|---|---|
committer | 2022-02-14 16:19:45 +0000 | |
commit | e85c348731e0364c3e3acdf1b76cd402ee25de71 (patch) | |
tree | 6c9bb609f6054da9232d632a64bdd2395831d7a3 | |
parent | db33f67f8ddbfb29acbe6fb57763cc2f029ec83b (diff) |
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
-rw-r--r-- | native/android/input.cpp | 15 | ||||
-rw-r--r-- | native/android/libandroid.map.txt | 2 |
2 files changed, 17 insertions, 0 deletions
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<const MotionEvent*>(motion_event)->getActionButton(); +} + +int32_t AMotionEvent_getClassification(const AInputEvent* motion_event) { + switch (static_cast<const MotionEvent*>(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) { diff --git a/native/android/libandroid.map.txt b/native/android/libandroid.map.txt index 3009a36bae2c..67a98a92dd98 100644 --- a/native/android/libandroid.map.txt +++ b/native/android/libandroid.map.txt @@ -114,8 +114,10 @@ LIBANDROID { ALooper_removeFd; ALooper_wake; AMotionEvent_getAction; + AMotionEvent_getActionButton; # introduced=Tiramisu AMotionEvent_getAxisValue; # introduced-arm=13 introduced-arm64=21 introduced-mips=13 introduced-mips64=21 introduced-x86=13 introduced-x86_64=21 AMotionEvent_getButtonState; # introduced-arm=14 introduced-arm64=21 introduced-mips=14 introduced-mips64=21 introduced-x86=14 introduced-x86_64=21 + AMotionEvent_getClassification; # introduced=Tiramisu AMotionEvent_getDownTime; AMotionEvent_getEdgeFlags; AMotionEvent_getEventTime; |