aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2023-01-24 17:31:16 +0800
committerPo Lu2023-01-24 17:31:16 +0800
commit56e55a80080f78754db6f385d574d17c3631ee30 (patch)
tree58abd71c77cb2e95b93c39c69dc76bb0ea90adac /src
parent3267a2d6d2b1f5b62f12f849712ead7016e71976 (diff)
downloademacs-56e55a80080f78754db6f385d574d17c3631ee30.tar.gz
emacs-56e55a80080f78754db6f385d574d17c3631ee30.zip
Update Android port
* INSTALL.android: Update. * build-aux/ndk-build-helper-1.mk: Fix typo. * configure.ac: Enable --with-json on Android. * cross/ndk-build/ndk-build-shared-library.mk: (NDK_CFLAGS_$(LOCAL_MODULE)): (LOCAL_MODULE_FILENAME): * cross/ndk-build/ndk-build-static-library.mk: (ALL_OBJECT_FILES$(LOCAL_MODULE)): (LOCAL_MODULE_FILENAME): Recursively resolve dependencies. * cross/ndk-build/ndk-resolve.mk: New function. * doc/emacs/android.texi (Android Startup): Document how Emacs is dumped during initial startup. * java/Makefile.in (filename): Fix build with multiple shared libraries. * java/README: Improve commentary. * java/org/gnu/emacs/EmacsApplication.java (onCreate): Look and set dump file. * java/org/gnu/emacs/EmacsNative.java (EmacsNative): New function getFingerprint. * java/org/gnu/emacs/EmacsPreferencesActivity.java (onCreate): Add option to erase the dump file. * java/org/gnu/emacs/EmacsService.java (browseUrl): New function. * java/org/gnu/emacs/EmacsThread.java (run): Specify dump file if found. * lisp/loadup.el: Always dump during loadup on Android. * lisp/net/browse-url.el (browse-url--browser-defcustom-type): (browse-url-default-browser): (browse-url-default-android-browser): New browse url type. * m4/ndk-build.m4 (ndk_package_map): Map jansson to libjansson. * src/android.c (struct android_emacs_service): New method `browse_url'. (getFingerprint): New function. (android_init_emacs_service): Initialize new method. (android_browse_url): New function. * src/android.h: Update prototypes. * src/androidselect.c (Fandroid_browse_url): New function. (syms_of_androidselect): Define it. * src/emacs.c (load_pdump): Don't look in fancy places on Android. * src/pdumper.c (Fdump_emacs_portable): Allow dumping while interactive on Android. (syms_of_pdumper): New variable `pdumper-fingerprint'. * src/sfntfont-android.c (sfntfont_android_composite_bitmap): Fix unused variables.
Diffstat (limited to 'src')
-rw-r--r--src/android.c61
-rw-r--r--src/android.h4
-rw-r--r--src/androidselect.c20
-rw-r--r--src/emacs.c29
-rw-r--r--src/pdumper.c18
-rw-r--r--src/sfntfont-android.c7
6 files changed, 137 insertions, 2 deletions
diff --git a/src/android.c b/src/android.c
index d788c6f19b4..c186b462360 100644
--- a/src/android.c
+++ b/src/android.c
@@ -33,6 +33,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
33#include <sys/param.h> 33#include <sys/param.h>
34 34
35#include <assert.h> 35#include <assert.h>
36#include <fingerprint.h>
36 37
37#include "android.h" 38#include "android.h"
38#include "androidgui.h" 39#include "androidgui.h"
@@ -95,6 +96,7 @@ struct android_emacs_service
95 jmethodID detect_mouse; 96 jmethodID detect_mouse;
96 jmethodID name_keysym; 97 jmethodID name_keysym;
97 jmethodID sync; 98 jmethodID sync;
99 jmethodID browse_url;
98}; 100};
99 101
100struct android_emacs_pixmap 102struct android_emacs_pixmap
@@ -1294,6 +1296,18 @@ android_get_home_directory (void)
1294#pragma GCC diagnostic ignored "-Wmissing-prototypes" 1296#pragma GCC diagnostic ignored "-Wmissing-prototypes"
1295#endif 1297#endif
1296 1298
1299JNIEXPORT jstring JNICALL
1300NATIVE_NAME (getFingerprint) (JNIEnv *env, jobject object)
1301{
1302 char buffer[sizeof fingerprint * 2 + 1];
1303
1304 memset (buffer, 0, sizeof buffer);
1305 hexbuf_digest (buffer, (char *) fingerprint,
1306 sizeof fingerprint);
1307
1308 return (*env)->NewStringUTF (env, buffer);
1309}
1310
1297JNIEXPORT void JNICALL 1311JNIEXPORT void JNICALL
1298NATIVE_NAME (setEmacsParams) (JNIEnv *env, jobject object, 1312NATIVE_NAME (setEmacsParams) (JNIEnv *env, jobject object,
1299 jobject local_asset_manager, 1313 jobject local_asset_manager,
@@ -1514,6 +1528,8 @@ android_init_emacs_service (void)
1514 FIND_METHOD (detect_mouse, "detectMouse", "()Z"); 1528 FIND_METHOD (detect_mouse, "detectMouse", "()Z");
1515 FIND_METHOD (name_keysym, "nameKeysym", "(I)Ljava/lang/String;"); 1529 FIND_METHOD (name_keysym, "nameKeysym", "(I)Ljava/lang/String;");
1516 FIND_METHOD (sync, "sync", "()V"); 1530 FIND_METHOD (sync, "sync", "()V");
1531 FIND_METHOD (browse_url, "browseUrl", "(Ljava/lang/String;)"
1532 "Ljava/lang/String;");
1517#undef FIND_METHOD 1533#undef FIND_METHOD
1518} 1534}
1519 1535
@@ -4735,6 +4751,51 @@ android_project_image_nearest (struct android_image *image,
4735 4751
4736 4752
4737 4753
4754/* Other miscellaneous functions. */
4755
4756/* Ask the system to start browsing the specified encoded URL. Upon
4757 failure, return a string describing the error. Else, value is
4758 nil. */
4759
4760Lisp_Object
4761android_browse_url (Lisp_Object url)
4762{
4763 jobject value, string;
4764 Lisp_Object tem;
4765 const char *buffer;
4766
4767 string = android_build_string (url);
4768 value = (*android_java_env)->CallObjectMethod (android_java_env,
4769 emacs_service,
4770 service_class.browse_url,
4771 string);
4772 android_exception_check ();
4773
4774 ANDROID_DELETE_LOCAL_REF (string);
4775
4776 /* If no string was returned, return Qnil. */
4777 if (!value)
4778 return Qnil;
4779
4780 buffer = (*android_java_env)->GetStringUTFChars (android_java_env,
4781 (jstring) value,
4782 NULL);
4783 android_exception_check ();
4784
4785 /* Otherwise, build the string describing the error. */
4786 tem = build_string_from_utf8 (buffer);
4787
4788 (*android_java_env)->ReleaseStringUTFChars (android_java_env,
4789 (jstring) value,
4790 buffer);
4791
4792 /* And return it. */
4793 ANDROID_DELETE_LOCAL_REF (value);
4794 return tem;
4795}
4796
4797
4798
4738#else /* ANDROID_STUBIFY */ 4799#else /* ANDROID_STUBIFY */
4739 4800
4740/* X emulation functions for Android. */ 4801/* X emulation functions for Android. */
diff --git a/src/android.h b/src/android.h
index eee3a7a6498..ce0ccfc4338 100644
--- a/src/android.h
+++ b/src/android.h
@@ -107,6 +107,10 @@ extern void android_closedir (struct android_dir *);
107 107
108 108
109 109
110/* Very miscellaneous functions. */
111
112extern Lisp_Object android_browse_url (Lisp_Object);
113
110#endif 114#endif
111 115
112/* JNI functions should not be built when Emacs is stubbed out for the 116/* JNI functions should not be built when Emacs is stubbed out for the
diff --git a/src/androidselect.c b/src/androidselect.c
index 4a71b376e28..2e2f2d7e483 100644
--- a/src/androidselect.c
+++ b/src/androidselect.c
@@ -213,6 +213,25 @@ DEFUN ("android-clipboard-exists-p", Fandroid_clipboard_exists_p,
213 return rc ? Qt : Qnil; 213 return rc ? Qt : Qnil;
214} 214}
215 215
216DEFUN ("android-browse-url", Fandroid_browse_url,
217 Sandroid_browse_url, 1, 1, 0,
218 doc: /* Start the system web browser.
219Then, point the web browser to URL, which should be a URL-encoded
220URL with a scheme specified. Signal an error upon failure. */)
221 (Lisp_Object url)
222{
223 Lisp_Object value;
224
225 CHECK_STRING (url);
226 value = android_browse_url (url);
227
228 /* Signal an error upon failure. */
229 if (!NILP (value))
230 signal_error ("Error browsing URL", value);
231
232 return Qnil;
233}
234
216 235
217 236
218void 237void
@@ -246,4 +265,5 @@ syms_of_androidselect (void)
246 defsubr (&Sandroid_set_clipboard); 265 defsubr (&Sandroid_set_clipboard);
247 defsubr (&Sandroid_get_clipboard); 266 defsubr (&Sandroid_get_clipboard);
248 defsubr (&Sandroid_clipboard_exists_p); 267 defsubr (&Sandroid_clipboard_exists_p);
268 defsubr (&Sandroid_browse_url);
249} 269}
diff --git a/src/emacs.c b/src/emacs.c
index 02016e53c45..b0c19fe0070 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -744,6 +744,8 @@ argmatch (char **argv, int argc, const char *sstr, const char *lstr,
744 } 744 }
745} 745}
746 746
747#if !defined HAVE_ANDROID || defined ANDROID_STUBIFY
748
747/* Find a name (absolute or relative) of the Emacs executable whose 749/* Find a name (absolute or relative) of the Emacs executable whose
748 name (as passed into this program) is ARGV0. Called early in 750 name (as passed into this program) is ARGV0. Called early in
749 initialization by portable dumper loading code, so avoid Lisp and 751 initialization by portable dumper loading code, so avoid Lisp and
@@ -843,6 +845,8 @@ find_emacs_executable (char const *argv0, ptrdiff_t *candidate_size)
843#endif /* !WINDOWSNT */ 845#endif /* !WINDOWSNT */
844} 846}
845 847
848#endif
849
846#ifdef HAVE_PDUMPER 850#ifdef HAVE_PDUMPER
847 851
848static const char * 852static const char *
@@ -875,6 +879,30 @@ dump_error_to_string (int result)
875static char * 879static char *
876load_pdump (int argc, char **argv) 880load_pdump (int argc, char **argv)
877{ 881{
882#if defined HAVE_ANDROID && !defined ANDROID_STUBIFY
883 char *dump_file = NULL;
884 int skip_args = 0, result;
885
886 while (skip_args < argc - 1)
887 {
888 if (argmatch (argv, argc, "-dump-file", "--dump-file", 6,
889 &dump_file, &skip_args)
890 || argmatch (argv, argc, "--", NULL, 2, NULL, &skip_args))
891 break;
892 skip_args++;
893 }
894
895 if (!dump_file)
896 return argv[0];
897
898 result = pdumper_load (dump_file, argv[0]);
899
900 if (result != PDUMPER_LOAD_SUCCESS)
901 fatal ("could not load dump file \"%s\": %s",
902 dump_file, dump_error_to_string (result));
903 return argv[0];
904#else
905
878 const char *const suffix = ".pdmp"; 906 const char *const suffix = ".pdmp";
879 int result; 907 int result;
880 char *emacs_executable = argv[0]; 908 char *emacs_executable = argv[0];
@@ -1067,6 +1095,7 @@ load_pdump (int argc, char **argv)
1067 xfree (dump_file); 1095 xfree (dump_file);
1068 1096
1069 return emacs_executable; 1097 return emacs_executable;
1098#endif
1070} 1099}
1071#endif /* HAVE_PDUMPER */ 1100#endif /* HAVE_PDUMPER */
1072 1101
diff --git a/src/pdumper.c b/src/pdumper.c
index eca64725211..dbdeae9a799 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -4072,10 +4072,12 @@ types. */)
4072{ 4072{
4073 eassert (initialized); 4073 eassert (initialized);
4074 4074
4075#ifndef HAVE_ANDROID
4075 if (! noninteractive) 4076 if (! noninteractive)
4076 error ("Dumping Emacs currently works only in batch mode. " 4077 error ("Dumping Emacs currently works only in batch mode. "
4077 "If you'd like it to work interactively, please consider " 4078 "If you'd like it to work interactively, please consider "
4078 "contributing a patch to Emacs."); 4079 "contributing a patch to Emacs.");
4080#endif
4079 4081
4080 if (will_dump_with_unexec_p ()) 4082 if (will_dump_with_unexec_p ())
4081 error ("This Emacs instance was started under the assumption " 4083 error ("This Emacs instance was started under the assumption "
@@ -5842,6 +5844,10 @@ void
5842syms_of_pdumper (void) 5844syms_of_pdumper (void)
5843{ 5845{
5844#ifdef HAVE_PDUMPER 5846#ifdef HAVE_PDUMPER
5847 unsigned char desired[sizeof fingerprint];
5848 int i;
5849 char hexbuf[2 * sizeof fingerprint];
5850
5845 defsubr (&Sdump_emacs_portable); 5851 defsubr (&Sdump_emacs_portable);
5846 defsubr (&Sdump_emacs_portable__sort_predicate); 5852 defsubr (&Sdump_emacs_portable__sort_predicate);
5847 defsubr (&Sdump_emacs_portable__sort_predicate_copied); 5853 defsubr (&Sdump_emacs_portable__sort_predicate_copied);
@@ -5854,5 +5860,17 @@ syms_of_pdumper (void)
5854 DEFSYM (Qdump_file_name, "dump-file-name"); 5860 DEFSYM (Qdump_file_name, "dump-file-name");
5855 DEFSYM (Qafter_pdump_load_hook, "after-pdump-load-hook"); 5861 DEFSYM (Qafter_pdump_load_hook, "after-pdump-load-hook");
5856 defsubr (&Spdumper_stats); 5862 defsubr (&Spdumper_stats);
5863
5864 for (i = 0; i < sizeof fingerprint; i++)
5865 desired[i] = fingerprint[i];
5866
5867 hexbuf_digest (hexbuf, desired, sizeof desired);
5868
5869 DEFVAR_LISP ("pdumper-fingerprint", Vpdumper_fingerprint,
5870 doc: /* The fingerprint of this Emacs binary.
5871It is a string that is supposed to be unique to each build of
5872Emacs. */);
5873 Vpdumper_fingerprint = make_unibyte_string ((char *) hexbuf,
5874 sizeof hexbuf);
5857#endif /* HAVE_PDUMPER */ 5875#endif /* HAVE_PDUMPER */
5858} 5876}
diff --git a/src/sfntfont-android.c b/src/sfntfont-android.c
index 5c9835fb13e..bc8f1b35b84 100644
--- a/src/sfntfont-android.c
+++ b/src/sfntfont-android.c
@@ -320,7 +320,10 @@ sfntfont_android_composite_bitmap (unsigned char *restrict buffer,
320{ 320{
321 unsigned int *src_row; 321 unsigned int *src_row;
322 unsigned int *dst_row; 322 unsigned int *dst_row;
323 unsigned int i, src_y, x, src_x, max_x, dst_x, lim_x; 323 unsigned int i, src_y, x, src_x, max_x, dst_x;
324#ifdef __aarch64__
325 unsigned int lim_x;
326#endif
324 327
325 if ((intptr_t) dest & 3 || bitmap_info->stride & 3) 328 if ((intptr_t) dest & 3 || bitmap_info->stride & 3)
326 /* This shouldn't be possible as Android is supposed to align the 329 /* This shouldn't be possible as Android is supposed to align the
@@ -353,10 +356,10 @@ sfntfont_android_composite_bitmap (unsigned char *restrict buffer,
353 src_x = x + (rect->x - text_rectangle->x); 356 src_x = x + (rect->x - text_rectangle->x);
354 dst_x = x + rect->x; 357 dst_x = x + rect->x;
355 358
359#ifdef __aarch64__
356 /* This is the largest value of src_x. */ 360 /* This is the largest value of src_x. */
357 lim_x = max_x + (rect->x - text_rectangle->x); 361 lim_x = max_x + (rect->x - text_rectangle->x);
358 362
359#ifdef __aarch64__
360 if (!sfntfont_android_over_8888 (src_row + src_x, 363 if (!sfntfont_android_over_8888 (src_row + src_x,
361 dst_row + dst_x, 364 dst_row + dst_x,
362 src_row + lim_x, 365 src_row + lim_x,