diff options
| author | Po Lu | 2024-05-01 11:45:53 +0800 |
|---|---|---|
| committer | Po Lu | 2024-05-01 11:46:31 +0800 |
| commit | 2451456695d0e03b89365cbbe64effb2f99af2d5 (patch) | |
| tree | b6bcd3e227454b436ab4ee0fad447d946b5179cf /src/androidvfs.c | |
| parent | 294335b2304028cc97aca036bd37adf2f8e1c508 (diff) | |
| download | emacs-2451456695d0e03b89365cbbe64effb2f99af2d5.tar.gz emacs-2451456695d0e03b89365cbbe64effb2f99af2d5.zip | |
Fix compatibility issues with Android clipboards
* java/org/gnu/emacs/EmacsClipboard.java (getClipboardData):
Return an AssetFileDescriptor.
* java/org/gnu/emacs/EmacsContextMenu.java (onMenuItemClick):
Typo corrections in commentary.
* java/org/gnu/emacs/EmacsOpenActivity.java (onCreate): Raise
minimum version on which to read file descriptors from
ParcelFileDescriptor objects to Honeycomb.
* java/org/gnu/emacs/EmacsSdk11Clipboard.java
(getClipboardData): Return the asset file descriptor.
* java/org/gnu/emacs/EmacsSdk8Clipboard.java (getClipboardData):
Adjust return type to match.
* src/android.h (struct android_parcel_file_descriptor_class):
Move from androidselect.c.
* src/androidselect.c (fd_class): Export function.
(android_init_emacs_clipboard): Adjust signature of
getClipboardData.
(android_init_asset_file_descriptor, close_asset_fd)
(extract_fd_offsets): New functions.
(Fandroid_get_clipboard_data): Extract file descriptor and
offset from the AssetFileDescriptor here, rather than in
getClipboardData.
(init_androidselect): Call android_init_asset_file_descriptor.
* src/androidvfs.c (android_init_fd_class): Export and enable
calling this function more than once.
Diffstat (limited to 'src/androidvfs.c')
| -rw-r--r-- | src/androidvfs.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/androidvfs.c b/src/androidvfs.c index c4b3dba4af0..38bec7d349a 100644 --- a/src/androidvfs.c +++ b/src/androidvfs.c | |||
| @@ -290,17 +290,6 @@ struct emacs_directory_entry_class | |||
| 290 | jfieldID d_name; | 290 | jfieldID d_name; |
| 291 | }; | 291 | }; |
| 292 | 292 | ||
| 293 | /* Structure describing the android.os.ParcelFileDescriptor class used | ||
| 294 | to wrap file descriptors sent over IPC. */ | ||
| 295 | |||
| 296 | struct android_parcel_file_descriptor_class | ||
| 297 | { | ||
| 298 | jclass class; | ||
| 299 | jmethodID close; | ||
| 300 | jmethodID get_fd; | ||
| 301 | jmethodID detach_fd; | ||
| 302 | }; | ||
| 303 | |||
| 304 | /* The java.lang.String class. */ | 293 | /* The java.lang.String class. */ |
| 305 | jclass java_string_class; | 294 | jclass java_string_class; |
| 306 | 295 | ||
| @@ -313,7 +302,7 @@ static struct emacs_directory_entry_class entry_class; | |||
| 313 | 302 | ||
| 314 | /* Fields and methods associated with the ParcelFileDescriptor | 303 | /* Fields and methods associated with the ParcelFileDescriptor |
| 315 | class. */ | 304 | class. */ |
| 316 | static struct android_parcel_file_descriptor_class fd_class; | 305 | struct android_parcel_file_descriptor_class fd_class; |
| 317 | 306 | ||
| 318 | /* Global references to several exception classes. */ | 307 | /* Global references to several exception classes. */ |
| 319 | static jclass file_not_found_exception, security_exception; | 308 | static jclass file_not_found_exception, security_exception; |
| @@ -380,13 +369,18 @@ android_init_entry_class (JNIEnv *env) | |||
| 380 | } | 369 | } |
| 381 | 370 | ||
| 382 | 371 | ||
| 383 | /* Initialize `fd_class' using the given JNI environment ENV. Calling | 372 | /* Initialize `fd_class' using the given JNI environment ENV. Called on |
| 384 | this function is not necessary on Android 4.4 and earlier. */ | 373 | API 12 (Android 3.1) and later by androidselect.c and on 5.0 and |
| 374 | later in this file. */ | ||
| 385 | 375 | ||
| 386 | static void | 376 | void |
| 387 | android_init_fd_class (JNIEnv *env) | 377 | android_init_fd_class (JNIEnv *env) |
| 388 | { | 378 | { |
| 389 | jclass old; | 379 | jclass old; |
| 380 | static bool fd_class_initialized; | ||
| 381 | |||
| 382 | if (fd_class_initialized) | ||
| 383 | return; | ||
| 390 | 384 | ||
| 391 | fd_class.class | 385 | fd_class.class |
| 392 | = (*env)->FindClass (env, "android/os/ParcelFileDescriptor"); | 386 | = (*env)->FindClass (env, "android/os/ParcelFileDescriptor"); |
| @@ -409,6 +403,8 @@ android_init_fd_class (JNIEnv *env) | |||
| 409 | FIND_METHOD (get_fd, "getFd", "()I"); | 403 | FIND_METHOD (get_fd, "getFd", "()I"); |
| 410 | FIND_METHOD (detach_fd, "detachFd", "()I"); | 404 | FIND_METHOD (detach_fd, "detachFd", "()I"); |
| 411 | #undef FIND_METHOD | 405 | #undef FIND_METHOD |
| 406 | |||
| 407 | fd_class_initialized = true; | ||
| 412 | } | 408 | } |
| 413 | 409 | ||
| 414 | 410 | ||