diff options
Diffstat (limited to 'native')
| -rw-r--r-- | native/android/input.cpp | 23 | ||||
| -rw-r--r-- | native/android/libandroid.map.txt | 3 | ||||
| -rw-r--r-- | native/android/sharedmem.cpp | 4 | ||||
| -rw-r--r-- | native/android/surface_control.cpp | 3 | ||||
| -rw-r--r-- | native/webview/loader/Android.bp | 2 |
5 files changed, 32 insertions, 3 deletions
diff --git a/native/android/input.cpp b/native/android/input.cpp index fc521386e6e1..8eeb9555c51c 100644 --- a/native/android/input.cpp +++ b/native/android/input.cpp @@ -26,6 +26,8 @@ #include <android_runtime/android_app_NativeActivity.h> #include <android_runtime/android_view_InputQueue.h> +#include <android_view_MotionEvent.h> +#include <android_view_KeyEvent.h> #include <poll.h> #include <errno.h> @@ -50,6 +52,10 @@ int32_t AInputEvent_getSource(const AInputEvent* event) { return static_cast<const InputEvent*>(event)->getSource(); } +void AInputEvent_release(const AInputEvent* event) { + delete event; +} + int32_t AKeyEvent_getAction(const AInputEvent* key_event) { return static_cast<const KeyEvent*>(key_event)->getAction(); } @@ -77,6 +83,14 @@ int64_t AKeyEvent_getDownTime(const AInputEvent* key_event) { return static_cast<const KeyEvent*>(key_event)->getDownTime(); } +const AInputEvent* AKeyEvent_fromJava(JNIEnv* env, jobject keyEvent) { + std::unique_ptr<KeyEvent> event = std::make_unique<KeyEvent>(); + android::status_t ret = android::android_view_KeyEvent_toNative(env, keyEvent, event.get()); + if (ret == android::OK) { + return event.release(); + } + return nullptr; +} int64_t AKeyEvent_getEventTime(const AInputEvent* key_event) { return static_cast<const KeyEvent*>(key_event)->getEventTime(); @@ -269,6 +283,15 @@ float AMotionEvent_getHistoricalAxisValue(const AInputEvent* motion_event, axis, pointer_index, history_index); } +const AInputEvent* AMotionEvent_fromJava(JNIEnv* env, jobject motionEvent) { + MotionEvent* eventSrc = android::android_view_MotionEvent_getNativePtr(env, motionEvent); + if (eventSrc == nullptr) { + return nullptr; + } + MotionEvent* event = new MotionEvent(); + event->copyFrom(eventSrc, true); + return event; +} void AInputQueue_attachLooper(AInputQueue* queue, ALooper* looper, int ident, ALooper_callbackFunc callback, void* data) { diff --git a/native/android/libandroid.map.txt b/native/android/libandroid.map.txt index d56aa86ae6fa..0414930b4078 100644 --- a/native/android/libandroid.map.txt +++ b/native/android/libandroid.map.txt @@ -76,6 +76,7 @@ LIBANDROID { AInputEvent_getDeviceId; AInputEvent_getSource; AInputEvent_getType; + AInputEvent_release; # introduced=31 AInputQueue_attachLooper; AInputQueue_detachLooper; AInputQueue_finishEvent; @@ -90,6 +91,7 @@ LIBANDROID { AKeyEvent_getMetaState; AKeyEvent_getRepeatCount; AKeyEvent_getScanCode; + AKeyEvent_fromJava; # introduced=31 ALooper_acquire; ALooper_addFd; ALooper_forThread; @@ -139,6 +141,7 @@ LIBANDROID { AMotionEvent_getY; AMotionEvent_getYOffset; AMotionEvent_getYPrecision; + AMotionEvent_fromJava; # introduced=31 ANativeActivity_finish; ANativeActivity_hideSoftInput; ANativeActivity_setWindowFlags; diff --git a/native/android/sharedmem.cpp b/native/android/sharedmem.cpp index 4410bd6fbeed..338b280a8ebe 100644 --- a/native/android/sharedmem.cpp +++ b/native/android/sharedmem.cpp @@ -16,6 +16,9 @@ #include <jni.h> +#include <fcntl.h> +#include <unistd.h> + #include <android/sharedmem.h> #include <android/sharedmem_jni.h> #include <cutils/ashmem.h> @@ -23,7 +26,6 @@ #include <utils/Errors.h> #include <mutex> -#include <unistd.h> static struct { jclass clazz; diff --git a/native/android/surface_control.cpp b/native/android/surface_control.cpp index 0af6cbf3cb40..0a466f424cec 100644 --- a/native/android/surface_control.cpp +++ b/native/android/surface_control.cpp @@ -317,10 +317,9 @@ void ASurfaceTransaction_reparent(ASurfaceTransaction* aSurfaceTransaction, sp<SurfaceControl> surfaceControl = ASurfaceControl_to_SurfaceControl(aSurfaceControl); sp<SurfaceControl> newParentSurfaceControl = ASurfaceControl_to_SurfaceControl( newParentASurfaceControl); - sp<IBinder> newParentHandle = (newParentSurfaceControl)? newParentSurfaceControl->getHandle() : nullptr; Transaction* transaction = ASurfaceTransaction_to_Transaction(aSurfaceTransaction); - transaction->reparent(surfaceControl, newParentHandle); + transaction->reparent(surfaceControl, newParentSurfaceControl); } void ASurfaceTransaction_setVisibility(ASurfaceTransaction* aSurfaceTransaction, diff --git a/native/webview/loader/Android.bp b/native/webview/loader/Android.bp index 0ba256facb6d..dfa5bdde0785 100644 --- a/native/webview/loader/Android.bp +++ b/native/webview/loader/Android.bp @@ -24,6 +24,8 @@ cc_library_shared { cflags: ["-Werror"], + header_libs: ["jni_headers"], + shared_libs: [ "libdl", "liblog", |