diff options
| author | Po Lu | 2024-04-20 20:44:30 +0800 |
|---|---|---|
| committer | Po Lu | 2024-04-20 20:46:17 +0800 |
| commit | 571fd42d48a0d99b7b210bd218836bd2f6ce2ccf (patch) | |
| tree | b69f859170af2f803c8677b94d440979c1c37336 /java/org/gnu | |
| parent | 9ea415cde3c602f5f13e4425ca508700b8118ffb (diff) | |
| download | emacs-571fd42d48a0d99b7b210bd218836bd2f6ce2ccf.tar.gz emacs-571fd42d48a0d99b7b210bd218836bd2f6ce2ccf.zip | |
Eliminate minor wart in EmacsService.java
* java/org/gnu/emacs/EmacsService.java (openContentUri): Replace
arg BYTES with URI and change its type to String.
* src/android.c (android_init_emacs_service):
* src/androidvfs.c (android_authority_name)
(android_authority_open): Adjust commentary and code to match.
Diffstat (limited to 'java/org/gnu')
| -rw-r--r-- | java/org/gnu/emacs/EmacsService.java | 45 |
1 files changed, 12 insertions, 33 deletions
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index b1ec397bc41..2d4079c11b0 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java | |||
| @@ -962,11 +962,13 @@ public final class EmacsService extends Service | |||
| 962 | string; make it writable if WRITABLE, and readable if READABLE. | 962 | string; make it writable if WRITABLE, and readable if READABLE. |
| 963 | Truncate the file if TRUNCATE. | 963 | Truncate the file if TRUNCATE. |
| 964 | 964 | ||
| 965 | Value is the resulting file descriptor or -1 upon failure. */ | 965 | Value is the resulting file descriptor or an exception will be |
| 966 | raised. */ | ||
| 966 | 967 | ||
| 967 | public int | 968 | public int |
| 968 | openContentUri (byte[] bytes, boolean writable, boolean readable, | 969 | openContentUri (String uri, boolean writable, boolean readable, |
| 969 | boolean truncate) | 970 | boolean truncate) |
| 971 | throws FileNotFoundException, IOException | ||
| 970 | { | 972 | { |
| 971 | String name, mode; | 973 | String name, mode; |
| 972 | ParcelFileDescriptor fd; | 974 | ParcelFileDescriptor fd; |
| @@ -985,39 +987,16 @@ public final class EmacsService extends Service | |||
| 985 | if (truncate) | 987 | if (truncate) |
| 986 | mode += "t"; | 988 | mode += "t"; |
| 987 | 989 | ||
| 988 | /* Try to open an associated ParcelFileDescriptor. */ | 990 | /* Try to open a corresponding ParcelFileDescriptor. Though |
| 991 | `fd.detachFd' is exclusive to Honeycomb and up, this function is | ||
| 992 | never called on systems older than KitKat, which is Emacs's | ||
| 993 | minimum requirement for access to /content/by-authority. */ | ||
| 989 | 994 | ||
| 990 | try | 995 | fd = resolver.openFileDescriptor (Uri.parse (uri), mode); |
| 991 | { | 996 | i = fd.detachFd (); |
| 992 | /* The usual file name encoding question rears its ugly head | 997 | fd.close (); |
| 993 | again. */ | ||
| 994 | |||
| 995 | name = new String (bytes, "UTF-8"); | ||
| 996 | fd = resolver.openFileDescriptor (Uri.parse (name), mode); | ||
| 997 | |||
| 998 | /* Use detachFd on newer versions of Android or plain old | ||
| 999 | dup. */ | ||
| 1000 | |||
| 1001 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) | ||
| 1002 | { | ||
| 1003 | i = fd.detachFd (); | ||
| 1004 | fd.close (); | ||
| 1005 | |||
| 1006 | return i; | ||
| 1007 | } | ||
| 1008 | else | ||
| 1009 | { | ||
| 1010 | i = EmacsNative.dup (fd.getFd ()); | ||
| 1011 | fd.close (); | ||
| 1012 | 998 | ||
| 1013 | return i; | 999 | return i; |
| 1014 | } | ||
| 1015 | } | ||
| 1016 | catch (Exception exception) | ||
| 1017 | { | ||
| 1018 | exception.printStackTrace (); | ||
| 1019 | return -1; | ||
| 1020 | } | ||
| 1021 | } | 1000 | } |
| 1022 | 1001 | ||
| 1023 | /* Return whether Emacs is directly permitted to access the | 1002 | /* Return whether Emacs is directly permitted to access the |