diff options
| author | Po Lu | 2023-02-04 23:32:07 +0800 |
|---|---|---|
| committer | Po Lu | 2023-02-04 23:32:07 +0800 |
| commit | 420533a8f9b345699dad9eeafeb3ccecfed516b2 (patch) | |
| tree | 3dba030a6c91eedfd82866aade5cc3200e865e60 /src | |
| parent | bfce0ce57fe0de11a6cbe3ff878a59dd2a0853d4 (diff) | |
| download | emacs-420533a8f9b345699dad9eeafeb3ccecfed516b2.tar.gz emacs-420533a8f9b345699dad9eeafeb3ccecfed516b2.zip | |
Add emacsclient desktop file equivalent on Android
* doc/emacs/android.texi (Android File System):
* java/AndroidManifest.xml.in: Update with new activity. Remove
Android 10 restrictions through a special flag.
* java/org/gnu/emacs/EmacsNative.java (getProcName): New
function.
* java/org/gnu/emacs/EmacsOpenActivity.java (EmacsOpenActivity):
New file.
* java/org/gnu/emacs/EmacsService.java (getLibraryDirection):
Remove unused annotation.
* lib-src/emacsclient.c (decode_options): Set alt_display on
Android.
* src/android.c (android_proc_name): New function.
(NATIVE_NAME): Export via JNI.
Diffstat (limited to 'src')
| -rw-r--r-- | src/android.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/android.c b/src/android.c index 57a95bcd4f9..a0e64471a05 100644 --- a/src/android.c +++ b/src/android.c | |||
| @@ -1369,6 +1369,27 @@ android_get_home_directory (void) | |||
| 1369 | return android_files_dir; | 1369 | return android_files_dir; |
| 1370 | } | 1370 | } |
| 1371 | 1371 | ||
| 1372 | /* Return the name of the file behind a file descriptor FD by reading | ||
| 1373 | /proc/self/fd/. Place the name in BUFFER, which should be able to | ||
| 1374 | hold size bytes. Value is 0 upon success, and 1 upon failure. */ | ||
| 1375 | |||
| 1376 | static int | ||
| 1377 | android_proc_name (int fd, char *buffer, size_t size) | ||
| 1378 | { | ||
| 1379 | char format[sizeof "/proc/self/fd/" | ||
| 1380 | + INT_STRLEN_BOUND (int)]; | ||
| 1381 | ssize_t read; | ||
| 1382 | |||
| 1383 | sprintf (format, "/proc/self/fd/%d", fd); | ||
| 1384 | read = readlink (format, buffer, size - 1); | ||
| 1385 | |||
| 1386 | if (read == -1) | ||
| 1387 | return 1; | ||
| 1388 | |||
| 1389 | buffer[read] = '\0'; | ||
| 1390 | return 0; | ||
| 1391 | } | ||
| 1392 | |||
| 1372 | 1393 | ||
| 1373 | 1394 | ||
| 1374 | /* JNI functions called by Java. */ | 1395 | /* JNI functions called by Java. */ |
| @@ -1598,6 +1619,29 @@ NATIVE_NAME (setEmacsParams) (JNIEnv *env, jobject object, | |||
| 1598 | now. */ | 1619 | now. */ |
| 1599 | } | 1620 | } |
| 1600 | 1621 | ||
| 1622 | JNIEXPORT jobject JNICALL | ||
| 1623 | NATIVE_NAME (getProcName) (JNIEnv *env, jobject object, jint fd) | ||
| 1624 | { | ||
| 1625 | char buffer[PATH_MAX + 1]; | ||
| 1626 | size_t length; | ||
| 1627 | jbyteArray array; | ||
| 1628 | |||
| 1629 | if (android_proc_name (fd, buffer, PATH_MAX + 1)) | ||
| 1630 | return NULL; | ||
| 1631 | |||
| 1632 | /* Return a byte array, as Java strings cannot always encode file | ||
| 1633 | names. */ | ||
| 1634 | length = strlen (buffer); | ||
| 1635 | array = (*env)->NewByteArray (env, length); | ||
| 1636 | if (!array) | ||
| 1637 | return NULL; | ||
| 1638 | |||
| 1639 | (*env)->SetByteArrayRegion (env, array, 0, length, | ||
| 1640 | (jbyte *) buffer); | ||
| 1641 | |||
| 1642 | return array; | ||
| 1643 | } | ||
| 1644 | |||
| 1601 | /* Initialize service_class, aborting if something goes wrong. */ | 1645 | /* Initialize service_class, aborting if something goes wrong. */ |
| 1602 | 1646 | ||
| 1603 | static void | 1647 | static void |