]> git.eshelyaron.com Git - emacs.git/commitdiff
Remove redundant encoding of strings in androidvfs.c
authorPo Lu <luangruo@yahoo.com>
Fri, 10 May 2024 03:42:37 +0000 (11:42 +0800)
committerEshel Yaron <me@eshelyaron.com>
Fri, 10 May 2024 13:40:48 +0000 (15:40 +0200)
* java/org/gnu/emacs/EmacsService.java (getDocumentTrees):
Accept PROVIDER as a String.

* src/android.c (android_init_emacs_service):

* src/androidvfs.c (android_saf_root_opendir): Adjust to match.

(cherry picked from commit ea2b251ab2b2bc9a3d6f52a22408655be20de266)

java/org/gnu/emacs/EmacsService.java
src/android.c
src/androidvfs.c

index 1e5f72eed374474acec88c82f01a22f62fb3aa70..2dcaad16e50b1d52c8e3b04a9449cb4bc08f5669 100644 (file)
@@ -1401,22 +1401,12 @@ public final class EmacsService extends Service
      otherwise.  */
 
   public String[]
-  getDocumentTrees (byte provider[])
+  getDocumentTrees (String provider)
   {
-    String providerName;
     List<String> treeList;
     List<UriPermission> permissions;
     Uri uri;
 
-    try
-      {
-       providerName = new String (provider, "US-ASCII");
-      }
-    catch (UnsupportedEncodingException exception)
-      {
-       return null;
-      }
-
     permissions = resolver.getPersistedUriPermissions ();
     treeList = new ArrayList<String> ();
 
@@ -1425,7 +1415,7 @@ public final class EmacsService extends Service
        uri = permission.getUri ();
 
        if (DocumentsContract.isTreeUri (uri)
-           && uri.getAuthority ().equals (providerName)
+           && uri.getAuthority ().equals (provider)
            && permission.isReadPermission ())
          /* Make sure the tree document ID is encoded.  Refrain from
             encoding characters such as +:&?#, since they don't
@@ -1435,6 +1425,9 @@ public final class EmacsService extends Service
                                    " +:&?#"));
       }
 
+    /* The empty string array that is ostensibly allocated to provide
+       the first argument provides just the type of the array to be
+       returned.  */
     return treeList.toArray (new String[0]);
   }
 
index 0dd7702b30129a7bb99be31d517c8a529bdf0f4b..d3b0bc214786b4ae699e32663435cd039b8d0ed3 100644 (file)
@@ -1659,7 +1659,7 @@ android_init_emacs_service (void)
   FIND_METHOD (request_directory_access, "requestDirectoryAccess",
               "()I");
   FIND_METHOD (get_document_trees, "getDocumentTrees",
-              "([B)[Ljava/lang/String;");
+              "(Ljava/lang/String;)[Ljava/lang/String;");
   FIND_METHOD (document_id_from_name, "documentIdFromName",
               "(Ljava/lang/String;Ljava/lang/String;"
               "[Ljava/lang/String;)I");
index 284b137054991d112e0b2a9cb566bf7999bf9bb6..004abd625186512eb0bbf90d63964a6dc98ed753 100644 (file)
@@ -4033,7 +4033,7 @@ android_saf_root_opendir (struct android_vnode *vnode)
   struct android_saf_root_vnode *vp;
   jobjectArray array;
   jmethodID method;
-  jbyteArray authority;
+  jstring authority;
   struct android_saf_root_vdir *dir;
   size_t length;
 
@@ -4043,15 +4043,10 @@ android_saf_root_opendir (struct android_vnode *vnode)
     {
       /* Build a string containing the authority.  */
       length = strlen (vp->authority);
-      authority = (*android_java_env)->NewByteArray (android_java_env,
-                                                    length);
+      authority = (*android_java_env)->NewStringUTF (android_java_env,
+                                                    vp->authority);
       android_exception_check ();
 
-      /* Copy the authority name to that byte array.  */
-      (*android_java_env)->SetByteArrayRegion (android_java_env,
-                                              authority, 0, length,
-                                              (jbyte *) vp->authority);
-
       /* Acquire a list of every tree provided by this authority.  */
 
       method = service_class.get_document_trees;
@@ -6566,10 +6561,11 @@ static struct android_special_vnode special_vnodes[] =
    to CODING, and return a Lisp string with the data so produced.
 
    Calling this function creates an implicit assumption that
-   file-name-coding-system is compatible with utf-8-emacs, which is not
-   unacceptable as users with cause to modify file-name-coding-system
-   should be aware and prepared for consequences towards files stored on
-   different filesystems, including virtual ones.  */
+   `file-name-coding-system' is compatible with `utf-8-emacs', which is
+   not unacceptable as users with cause to modify
+   file-name-coding-system should be aware and prepared for adverse
+   consequences affecting files stored on different filesystems,
+   including virtual ones.  */
 
 static Lisp_Object
 android_vfs_convert_name (const char *name, Lisp_Object coding)