]> git.eshelyaron.com Git - emacs.git/commitdiff
Update Android port
authorPo Lu <luangruo@yahoo.com>
Sun, 24 Sep 2023 10:19:38 +0000 (18:19 +0800)
committerPo Lu <luangruo@yahoo.com>
Sun, 24 Sep 2023 10:19:54 +0000 (18:19 +0800)
* 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.

java/org/gnu/emacs/EmacsSdk11Clipboard.java
src/androidvfs.c

index b34753922b8619fb04476df2ef33971386b711c4..b8a43496b6d6ea15681e5433bb5de538f2881f2f 100644 (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'
index 858816908f8c7edcf20d8202af7c37bd8fcde60c..d099e4d636cc0098fa6e03abed54f400306bf340 100644 (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;