Update Android port

* java/org/gnu/emacs/EmacsSdk11Clipboard.java
(getClipboardData): Correct typo in comment.

* src/androidvfs.c (android_authority_open)
(android_saf_delete_document): Circumvent JNI dynamic method
dispatch.
This commit is contained in:
Po Lu 2023-09-24 18:19:38 +08:00
parent 81c6569e65
commit 38cd3cb433
2 changed files with 28 additions and 25 deletions

View file

@ -209,7 +209,7 @@ public final class EmacsSdk11Clipboard extends EmacsClipboard
Value is normally an array of three longs: the file descriptor,
the start offset of the data, and its length; length may be
AssetFileDescriptor.UNKOWN_LENGTH, meaning that the data extends
AssetFileDescriptor.UNKNOWN_LENGTH, meaning that the data extends
from that offset to the end of the file.
Do not use this function to open text targets; use `getClipboard'

View file

@ -3033,6 +3033,7 @@ android_authority_open (struct android_vnode *vnode, int flags,
size_t length;
jobject string;
int fd;
JNIEnv *env;
vp = (struct android_authority_vnode *) vnode;
@ -3044,39 +3045,40 @@ android_authority_open (struct android_vnode *vnode, int flags,
return -1;
}
/* Save the JNI environment within `env', to make wrapping
subsequent lines referencing CallNonvirtualIntMethod
feasible. */
env = android_java_env;
/* Allocate a buffer to hold the file name. */
length = strlen (vp->uri);
string = (*android_java_env)->NewByteArray (android_java_env,
length);
string = (*env)->NewByteArray (env, length);
if (!string)
{
(*android_java_env)->ExceptionClear (android_java_env);
(*env)->ExceptionClear (env);
errno = ENOMEM;
return -1;
}
/* Copy the URI into this byte array. */
(*android_java_env)->SetByteArrayRegion (android_java_env,
string, 0, length,
(jbyte *) vp->uri);
(*env)->SetByteArrayRegion (env, string, 0, length,
(jbyte *) vp->uri);
/* Try to open the file descriptor. */
fd
= (*android_java_env)->CallIntMethod (android_java_env,
emacs_service,
service_class.open_content_uri,
string,
(jboolean) ((mode & O_WRONLY
|| mode & O_RDWR)
!= 0),
(jboolean) !(mode & O_WRONLY),
(jboolean) ((mode & O_TRUNC)
!= 0));
if ((*android_java_env)->ExceptionCheck (android_java_env))
fd = (*env)->CallNonvirtualIntMethod (env, emacs_service,
service_class.class,
service_class.open_content_uri,
string,
(jboolean) ((mode & O_WRONLY
|| mode & O_RDWR)
!= 0),
(jboolean) !(mode & O_WRONLY),
(jboolean) ((mode & O_TRUNC)
!= 0));
if ((*env)->ExceptionCheck (env))
{
(*android_java_env)->ExceptionClear (android_java_env);
(*env)->ExceptionClear (env);
errno = ENOMEM;
ANDROID_DELETE_LOCAL_REF (string);
return -1;
@ -4252,10 +4254,11 @@ android_saf_delete_document (const char *tree, const char *doc_id,
/* Now, try to delete the document. */
method = service_class.delete_document;
rc = (*android_java_env)->CallIntMethod (android_java_env,
emacs_service,
method, uri, id,
name);
rc = (*android_java_env)->CallNonvirtualIntMethod (android_java_env,
emacs_service,
service_class.class,
method, uri, id,
name);
if (android_saf_exception_check (3, id, uri, name))
return -1;