1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

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.
This commit is contained in:
Po Lu 2024-05-10 11:42:37 +08:00
parent dc5390d06a
commit ea2b251ab2
3 changed files with 14 additions and 25 deletions

View 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]);
}

View 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");

View 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)