diff options
| author | 2024-06-17 18:51:24 +0000 | |
|---|---|---|
| committer | 2024-06-17 18:51:24 +0000 | |
| commit | c33d8a06dd84bd1c4e2f65aa8fc2577dbecb3f86 (patch) | |
| tree | fe85543b236df7a67e0025ab54e67f8f14106726 /native/android/input.cpp | |
| parent | a8da8e6cca9e19dd64b8e353db17a2c676e09c66 (diff) | |
| parent | ae20e8151b7cbff5d90187aeea2132fc42a35836 (diff) | |
Merge "Merge Android 14 QPR3 to AOSP main" into main
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); |