aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPo Lu2024-05-10 11:42:37 +0800
committerPo Lu2024-05-10 11:42:37 +0800
commitea2b251ab2b2bc9a3d6f52a22408655be20de266 (patch)
tree6e4ceb796066892f68101a45b646c9b1d8b853a3
parentdc5390d06a65f4d481b8bb20da4f6715c2079ea6 (diff)
downloademacs-ea2b251ab2b2bc9a3d6f52a22408655be20de266.tar.gz
emacs-ea2b251ab2b2bc9a3d6f52a22408655be20de266.zip
Remove redundant encoding of strings in androidvfs.c
* 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.
-rw-r--r--java/org/gnu/emacs/EmacsService.java17
-rw-r--r--src/android.c2
-rw-r--r--src/androidvfs.c20
3 files changed, 14 insertions, 25 deletions
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java
index 1e5f72eed37..2dcaad16e50 100644
--- a/java/org/gnu/emacs/EmacsService.java
+++ b/java/org/gnu/emacs/EmacsService.java
@@ -1401,22 +1401,12 @@ public final class EmacsService extends Service
1401 otherwise. */ 1401 otherwise. */
1402 1402
1403 public String[] 1403 public String[]
1404 getDocumentTrees (byte provider[]) 1404 getDocumentTrees (String provider)
1405 { 1405 {
1406 String providerName;
1407 List<String> treeList; 1406 List<String> treeList;
1408 List<UriPermission> permissions; 1407 List<UriPermission> permissions;
1409 Uri uri; 1408 Uri uri;
1410 1409
1411 try
1412 {
1413 providerName = new String (provider, "US-ASCII");
1414 }
1415 catch (UnsupportedEncodingException exception)
1416 {
1417 return null;
1418 }
1419
1420 permissions = resolver.getPersistedUriPermissions (); 1410 permissions = resolver.getPersistedUriPermissions ();
1421 treeList = new ArrayList<String> (); 1411 treeList = new ArrayList<String> ();
1422 1412
@@ -1425,7 +1415,7 @@ public final class EmacsService extends Service
1425 uri = permission.getUri (); 1415 uri = permission.getUri ();
1426 1416
1427 if (DocumentsContract.isTreeUri (uri) 1417 if (DocumentsContract.isTreeUri (uri)
1428 && uri.getAuthority ().equals (providerName) 1418 && uri.getAuthority ().equals (provider)
1429 && permission.isReadPermission ()) 1419 && permission.isReadPermission ())
1430 /* Make sure the tree document ID is encoded. Refrain from 1420 /* Make sure the tree document ID is encoded. Refrain from
1431 encoding characters such as +:&?#, since they don't 1421 encoding characters such as +:&?#, since they don't
@@ -1435,6 +1425,9 @@ public final class EmacsService extends Service
1435 " +:&?#")); 1425 " +:&?#"));
1436 } 1426 }
1437 1427
1428 /* The empty string array that is ostensibly allocated to provide
1429 the first argument provides just the type of the array to be
1430 returned. */
1438 return treeList.toArray (new String[0]); 1431 return treeList.toArray (new String[0]);
1439 } 1432 }
1440 1433
diff --git a/src/android.c b/src/android.c
index 0dd7702b301..d3b0bc21478 100644
--- a/src/android.c
+++ b/src/android.c
@@ -1659,7 +1659,7 @@ android_init_emacs_service (void)
1659 FIND_METHOD (request_directory_access, "requestDirectoryAccess", 1659 FIND_METHOD (request_directory_access, "requestDirectoryAccess",
1660 "()I"); 1660 "()I");
1661 FIND_METHOD (get_document_trees, "getDocumentTrees", 1661 FIND_METHOD (get_document_trees, "getDocumentTrees",
1662 "([B)[Ljava/lang/String;"); 1662 "(Ljava/lang/String;)[Ljava/lang/String;");
1663 FIND_METHOD (document_id_from_name, "documentIdFromName", 1663 FIND_METHOD (document_id_from_name, "documentIdFromName",
1664 "(Ljava/lang/String;Ljava/lang/String;" 1664 "(Ljava/lang/String;Ljava/lang/String;"
1665 "[Ljava/lang/String;)I"); 1665 "[Ljava/lang/String;)I");
diff --git a/src/androidvfs.c b/src/androidvfs.c
index 284b1370549..004abd62518 100644
--- a/src/androidvfs.c
+++ b/src/androidvfs.c
@@ -4033,7 +4033,7 @@ android_saf_root_opendir (struct android_vnode *vnode)
4033 struct android_saf_root_vnode *vp; 4033 struct android_saf_root_vnode *vp;
4034 jobjectArray array; 4034 jobjectArray array;
4035 jmethodID method; 4035 jmethodID method;
4036 jbyteArray authority; 4036 jstring authority;
4037 struct android_saf_root_vdir *dir; 4037 struct android_saf_root_vdir *dir;
4038 size_t length; 4038 size_t length;
4039 4039
@@ -4043,15 +4043,10 @@ android_saf_root_opendir (struct android_vnode *vnode)
4043 { 4043 {
4044 /* Build a string containing the authority. */ 4044 /* Build a string containing the authority. */
4045 length = strlen (vp->authority); 4045 length = strlen (vp->authority);
4046 authority = (*android_java_env)->NewByteArray (android_java_env, 4046 authority = (*android_java_env)->NewStringUTF (android_java_env,
4047 length); 4047 vp->authority);
4048 android_exception_check (); 4048 android_exception_check ();
4049 4049
4050 /* Copy the authority name to that byte array. */
4051 (*android_java_env)->SetByteArrayRegion (android_java_env,
4052 authority, 0, length,
4053 (jbyte *) vp->authority);
4054
4055 /* Acquire a list of every tree provided by this authority. */ 4050 /* Acquire a list of every tree provided by this authority. */
4056 4051
4057 method = service_class.get_document_trees; 4052 method = service_class.get_document_trees;
@@ -6566,10 +6561,11 @@ static struct android_special_vnode special_vnodes[] =
6566 to CODING, and return a Lisp string with the data so produced. 6561 to CODING, and return a Lisp string with the data so produced.
6567 6562
6568 Calling this function creates an implicit assumption that 6563 Calling this function creates an implicit assumption that
6569 file-name-coding-system is compatible with utf-8-emacs, which is not 6564 `file-name-coding-system' is compatible with `utf-8-emacs', which is
6570 unacceptable as users with cause to modify file-name-coding-system 6565 not unacceptable as users with cause to modify
6571 should be aware and prepared for consequences towards files stored on 6566 file-name-coding-system should be aware and prepared for adverse
6572 different filesystems, including virtual ones. */ 6567 consequences affecting files stored on different filesystems,
6568 including virtual ones. */
6573 6569
6574static Lisp_Object 6570static Lisp_Object
6575android_vfs_convert_name (const char *name, Lisp_Object coding) 6571android_vfs_convert_name (const char *name, Lisp_Object coding)