diff options
author | 2024-05-24 08:27:25 -0700 | |
---|---|---|
committer | 2024-05-24 11:35:17 -0700 | |
commit | fe285426c4f9149537bdd7cb351b02ec102e6082 (patch) | |
tree | a50559e0969480b7f613fc086e380a290ee3d6b1 /native/android/input.cpp | |
parent | e2447a31771717fe6259043760ba02484f09d4da (diff) | |
parent | ed6f98ac9f4049f370e1db86e1b4e141bb83f5cc (diff) |
Merge Android 24Q2 Release (ab/11526283) to aosp-main-future
Bug: 337098550
Merged-In: Ie71e752f0224aa239ba1350d50996ce4b510949a
Change-Id: Ib25c1abf055b0114e0494088df5585f65df27595
Diffstat (limited to 'native/android/input.cpp')
-rw-r--r-- | native/android/input.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/native/android/input.cpp b/native/android/input.cpp index 64e8efeaa4e8..53699bc706ea 100644 --- a/native/android/input.cpp +++ b/native/android/input.cpp @@ -87,7 +87,7 @@ int64_t AKeyEvent_getDownTime(const AInputEvent* key_event) { const AInputEvent* AKeyEvent_fromJava(JNIEnv* env, jobject keyEvent) { std::unique_ptr<KeyEvent> event = std::make_unique<KeyEvent>(); - *event = android::android_view_KeyEvent_toNative(env, keyEvent); + *event = android::android_view_KeyEvent_obtainAsCopy(env, keyEvent); return event.release(); } @@ -314,6 +314,25 @@ const AInputEvent* AMotionEvent_fromJava(JNIEnv* env, jobject motionEvent) { return event; } +jobject AInputEvent_toJava(JNIEnv* env, const AInputEvent* aInputEvent) { + LOG_ALWAYS_FATAL_IF(aInputEvent == nullptr, "Expected aInputEvent to be non-null"); + const int32_t eventType = AInputEvent_getType(aInputEvent); + switch (eventType) { + case AINPUT_EVENT_TYPE_MOTION: + return android::android_view_MotionEvent_obtainAsCopy(env, + static_cast<const MotionEvent&>( + *aInputEvent)) + .release(); + case AINPUT_EVENT_TYPE_KEY: + return android::android_view_KeyEvent_obtainAsCopy(env, + static_cast<const KeyEvent&>( + *aInputEvent)) + .release(); + default: + LOG_ALWAYS_FATAL("Unexpected event type %d in AInputEvent_toJava.", eventType); + } +} + void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, int ident, ALooper_callbackFunc callback, void* data) { InputQueue* iq = static_cast<InputQueue*>(queue); |