diff options
author | Po Lu <luangruo@yahoo.com> | 2023-01-25 22:07:51 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2023-01-25 22:07:51 +0800 |
commit | 0b1ef9ea31ce039001546b3ed34494332e5e3629 (patch) | |
tree | 3b3caec2303410053921aa76c1351349f013cedf /src/android-emacs.c | |
parent | d3b29ccc89f2c14754e6b817da45b4c3f80e670f (diff) | |
download | emacs-0b1ef9ea31ce039001546b3ed34494332e5e3629.tar.gz emacs-0b1ef9ea31ce039001546b3ed34494332e5e3629.tar.bz2 emacs-0b1ef9ea31ce039001546b3ed34494332e5e3629.zip |
Update Android port
* java/org/gnu/emacs/EmacsDrawLine.java: Fix this again. Gosh,
how does Android do this.
* java/org/gnu/emacs/EmacsNoninteractive.java (main): Port to
Android 2.3.3.
* java/org/gnu/emacs/EmacsSdk11Clipboard.java
(EmacsSdk11Clipboard): Port to Android 4.0.3.
* java/org/gnu/emacs/EmacsService.java (getClipboardManager):
New function.
* src/alloc.c (find_string_data_in_pure): Fix Android alignment
issue.
* src/android-emacs.c (main): Port to Android 4.4.
* src/android.c (initEmacs): Align stack to 32 bytes, so it ends
up aligned to 16 even though gcc thinks the stack is already
aligned to 16 bytes.
* src/callproc.c (init_callproc): Use /system/bin/sh instead of
/bin/sh by default.
Diffstat (limited to 'src/android-emacs.c')
-rw-r--r-- | src/android-emacs.c | 94 |
1 files changed, 79 insertions, 15 deletions
diff --git a/src/android-emacs.c b/src/android-emacs.c index c1f2a6f43bb..e64caf9a9d4 100644 --- a/src/android-emacs.c +++ b/src/android-emacs.c @@ -52,12 +52,37 @@ main (int argc, char **argv) args[0] = (char *) "/system/bin/app_process"; #endif + /* Machines with ART require the boot classpath to be manually + specified. Machines with Dalvik however refuse to do so, as they + open the jars inside the BOOTCLASSPATH environment variable at + startup, resulting in the following crash: + + W/dalvikvm( 1608): Refusing to reopen boot DEX + '/system/framework/core.jar' + W/dalvikvm( 1608): Refusing to reopen boot DEX + '/system/framework/bouncycastle.jar' + E/dalvikvm( 1608): Too many exceptions during init (failed on + 'Ljava/io/IOException;' 'Re-opening BOOTCLASSPATH DEX files is + not allowed') + E/dalvikvm( 1608): VM aborting */ + +#if HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL + if (android_get_device_api_level () < 21) + { + bootclasspath = NULL; + goto skip_setup; + } +#else + if (__ANDROID_API__ < 21) + { + bootclasspath = NULL; + goto skip_setup; + } +#endif + /* Next, obtain the boot class path. */ bootclasspath = getenv ("BOOTCLASSPATH"); - /* And the Emacs class path. */ - emacs_class_path = getenv ("EMACS_CLASS_PATH"); - if (!bootclasspath) { fprintf (stderr, "The BOOTCLASSPATH environment variable" @@ -68,6 +93,11 @@ main (int argc, char **argv) return 1; } + skip_setup: + + /* And the Emacs class path. */ + emacs_class_path = getenv ("EMACS_CLASS_PATH"); + if (!emacs_class_path) { fprintf (stderr, "EMACS_CLASS_PATH not set." @@ -76,25 +106,59 @@ main (int argc, char **argv) return 1; } - if (asprintf (&bootclasspath, "-Djava.class.path=%s:%s", - bootclasspath, emacs_class_path) < 0) + if (bootclasspath) { - perror ("asprintf"); - return 1; + if (asprintf (&bootclasspath, "-Djava.class.path=%s:%s", + bootclasspath, emacs_class_path) < 0) + { + perror ("asprintf"); + return 1; + } + } + else + { + if (asprintf (&bootclasspath, "-Djava.class.path=%s", + emacs_class_path) < 0) + { + perror ("asprintf"); + return 1; + } } args[1] = bootclasspath; args[2] = (char *) "/system/bin"; - args[3] = (char *) "--nice-name=emacs"; - args[4] = (char *) "org.gnu.emacs.EmacsNoninteractive"; - /* Arguments from here on are passed to main in - EmacsNoninteractive.java. */ - args[5] = argv[0]; +#if HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL + /* I don't know exactly when --nice-name was introduced; this is + just a guess. */ + if (android_get_device_api_level () >= 26) + { + args[3] = (char *) "--nice-name=emacs"; + args[4] = (char *) "org.gnu.emacs.EmacsNoninteractive"; + + /* Arguments from here on are passed to main in + EmacsNoninteractive.java. */ + args[5] = argv[0]; - /* Now copy the rest of the arguments over. */ - for (i = 1; i < argc; ++i) - args[5 + i] = argv[i]; + /* Now copy the rest of the arguments over. */ + for (i = 1; i < argc; ++i) + args[5 + i] = argv[i]; + } + else + { +#endif + args[3] = (char *) "org.gnu.emacs.EmacsNoninteractive"; + + /* Arguments from here on are passed to main in + EmacsNoninteractive.java. */ + args[4] = argv[0]; + + /* Now copy the rest of the arguments over. */ + for (i = 1; i < argc; ++i) + args[4 + i] = argv[i]; +#if HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL + } +#endif /* Finally, try to start the app_process. */ execvp (args[0], args); |