aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorPo Lu2023-01-24 17:31:16 +0800
committerPo Lu2023-01-24 17:31:16 +0800
commit56e55a80080f78754db6f385d574d17c3631ee30 (patch)
tree58abd71c77cb2e95b93c39c69dc76bb0ea90adac /java
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 'java')
-rw-r--r--java/Makefile.in3
-rw-r--r--java/README8
-rw-r--r--java/org/gnu/emacs/EmacsApplication.java54
-rw-r--r--java/org/gnu/emacs/EmacsNative.java4
-rw-r--r--java/org/gnu/emacs/EmacsPreferencesActivity.java27
-rw-r--r--java/org/gnu/emacs/EmacsService.java25
-rw-r--r--java/org/gnu/emacs/EmacsThread.java19
7 files changed, 132 insertions, 8 deletions
diff --git a/java/Makefile.in b/java/Makefile.in
index d27775ea3db..b5e0cd7bb56 100644
--- a/java/Makefile.in
+++ b/java/Makefile.in
@@ -148,8 +148,7 @@ emacs.apk-in: $(CROSS_BINS) $(CROSS_LIBS) $(libsrc)/asset-directory-tool \
148 cp -f $$file install_temp/lib/$(ANDROID_ABI); \ 148 cp -f $$file install_temp/lib/$(ANDROID_ABI); \
149 fi \ 149 fi \
150 done 150 done
151 $(foreach module,$(NDK_BUILD_SHARED), \ 151 cp -f $(NDK_BUILD_SHARED) install_temp/lib/$(ANDROID_ABI)
152 cp -f $(module) install_temp/lib/$(ANDROID_ABI))
153# Package everything. Specifying the assets on this command line is 152# Package everything. Specifying the assets on this command line is
154# necessary for AAssetManager_getNextFileName to work on old versions 153# necessary for AAssetManager_getNextFileName to work on old versions
155# of Android. 154# of Android.
diff --git a/java/README b/java/README
index 50c2332ce95..05edf7744de 100644
--- a/java/README
+++ b/java/README
@@ -1,5 +1,11 @@
1This directory holds the Java sources of the port of GNU Emacs to 1This directory holds the Java sources of the port of GNU Emacs to
2Android-like systems. 2Android-like systems, along with files needed to create an application
3package out of them.
4
5`emacs.keystore' is the signing key used to build Emacs. It is kept
6here, and we encourage all people redistributing Emacs to use this
7key. It holds no security value, and otherwise it will be impossible
8to install different builds of Emacs on top of each other.
3 9
4Please keep the Java code indented with tabs and formatted according 10Please keep the Java code indented with tabs and formatted according
5to the rules for C code in the GNU coding standards. Always use 11to the rules for C code in the GNU coding standards. Always use
diff --git a/java/org/gnu/emacs/EmacsApplication.java b/java/org/gnu/emacs/EmacsApplication.java
index 125da05cfd4..87085c32d62 100644
--- a/java/org/gnu/emacs/EmacsApplication.java
+++ b/java/org/gnu/emacs/EmacsApplication.java
@@ -19,9 +19,59 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
19 19
20package org.gnu.emacs; 20package org.gnu.emacs;
21 21
22import java.io.File;
23import java.io.FileFilter;
24
22import android.app.Application; 25import android.app.Application;
26import android.util.Log;
23 27
24public class EmacsApplication extends Application 28public class EmacsApplication extends Application implements FileFilter
25{ 29{
26 /* This class currently does nothing. */ 30 private static final String TAG = "EmacsApplication";
31
32 /* The name of the dump file to use. */
33 public static String dumpFileName;
34
35 @Override
36 public boolean
37 accept (File file)
38 {
39 return (!file.isDirectory ()
40 && file.getName ().endsWith (".pdmp"));
41 }
42
43 @Override
44 public void
45 onCreate ()
46 {
47 File filesDirectory;
48 File[] allFiles;
49 String wantedDumpFile;
50 int i;
51
52 wantedDumpFile = ("emacs-" + EmacsNative.getFingerprint ()
53 + ".pdmp");
54
55 Log.d (TAG, "onCreate: looking for " + wantedDumpFile);
56
57 /* Obtain a list of all files ending with ``.pdmp''. Then, look
58 for a file named ``emacs-<fingerprint>.pdmp'' and delete the
59 rest. */
60 filesDirectory = getFilesDir ();
61 allFiles = filesDirectory.listFiles (this);
62
63 /* Now try to find the right dump file. */
64 for (i = 0; i < allFiles.length; ++i)
65 {
66 if (allFiles[i].getName ().equals (wantedDumpFile))
67 dumpFileName = allFiles[i].getAbsolutePath ();
68 else
69 /* Delete this outdated dump file. */
70 allFiles[i].delete ();
71 }
72
73 Log.d (TAG, "onCreate: found " + dumpFileName);
74
75 super.onCreate ();
76 }
27}; 77};
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java
index 962538bef7b..9636561a524 100644
--- a/java/org/gnu/emacs/EmacsNative.java
+++ b/java/org/gnu/emacs/EmacsNative.java
@@ -25,6 +25,10 @@ import android.content.res.AssetManager;
25 25
26public class EmacsNative 26public class EmacsNative
27{ 27{
28 /* Obtain the fingerprint of this build of Emacs. The fingerprint
29 can be used to determine the dump file name. */
30 public static native String getFingerprint ();
31
28 /* Set certain parameters before initializing Emacs. This proves 32 /* Set certain parameters before initializing Emacs. This proves
29 that libemacs.so is being loaded from Java code. 33 that libemacs.so is being loaded from Java code.
30 34
diff --git a/java/org/gnu/emacs/EmacsPreferencesActivity.java b/java/org/gnu/emacs/EmacsPreferencesActivity.java
index 0db983984fd..ed1db68f732 100644
--- a/java/org/gnu/emacs/EmacsPreferencesActivity.java
+++ b/java/org/gnu/emacs/EmacsPreferencesActivity.java
@@ -19,6 +19,8 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
19 19
20package org.gnu.emacs; 20package org.gnu.emacs;
21 21
22import java.io.File;
23
22import android.app.Activity; 24import android.app.Activity;
23import android.content.Intent; 25import android.content.Intent;
24import android.os.Bundle; 26import android.os.Bundle;
@@ -93,6 +95,31 @@ public class EmacsPreferencesActivity extends Activity
93 }); 95 });
94 layout.addView (textView); 96 layout.addView (textView);
95 97
98 textView = new TextView (this);
99 textView.setPadding (8, 20, 20, 8);
100
101 params = new LinearLayout.LayoutParams (LayoutParams.MATCH_PARENT,
102 LayoutParams.WRAP_CONTENT);
103 textView.setLayoutParams (params);
104 textView.setText ("Erase dump file");
105 textView.setOnClickListener (new View.OnClickListener () {
106 @Override
107 public void
108 onClick (View view)
109 {
110 String wantedDumpFile;
111 File file;
112
113 wantedDumpFile = ("emacs-" + EmacsNative.getFingerprint ()
114 + ".pdmp");
115 file = new File (getFilesDir (), wantedDumpFile);
116
117 if (file.exists ())
118 file.delete ();
119 }
120 });
121 layout.addView (textView);
122
96 super.onCreate (savedInstanceState); 123 super.onCreate (savedInstanceState);
97 } 124 }
98}; 125};
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java
index 95f21b211a3..4db1ea5359f 100644
--- a/java/org/gnu/emacs/EmacsService.java
+++ b/java/org/gnu/emacs/EmacsService.java
@@ -43,6 +43,8 @@ import android.content.Context;
43import android.content.Intent; 43import android.content.Intent;
44import android.content.res.AssetManager; 44import android.content.res.AssetManager;
45 45
46import android.net.Uri;
47
46import android.os.Build; 48import android.os.Build;
47import android.os.Looper; 49import android.os.Looper;
48import android.os.IBinder; 50import android.os.IBinder;
@@ -504,4 +506,27 @@ public class EmacsService extends Service
504 EmacsService.class)); 506 EmacsService.class));
505 } 507 }
506 } 508 }
509
510 /* Ask the system to open the specified URL.
511 Value is NULL upon success, or a string describing the error
512 upon failure. */
513
514 public String
515 browseUrl (String url)
516 {
517 Intent intent;
518
519 try
520 {
521 intent = new Intent (Intent.ACTION_VIEW, Uri.parse (url));
522 intent.setFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
523 startActivity (intent);
524 }
525 catch (Exception e)
526 {
527 return e.toString ();
528 }
529
530 return null;
531 }
507}; 532};
diff --git a/java/org/gnu/emacs/EmacsThread.java b/java/org/gnu/emacs/EmacsThread.java
index 21d8612703a..5b76d11db4b 100644
--- a/java/org/gnu/emacs/EmacsThread.java
+++ b/java/org/gnu/emacs/EmacsThread.java
@@ -38,10 +38,23 @@ public class EmacsThread extends Thread
38 { 38 {
39 String args[]; 39 String args[];
40 40
41 if (!startDashQ) 41 if (EmacsApplication.dumpFileName == null)
42 args = new String[] { "libandroid-emacs.so", }; 42 {
43 if (!startDashQ)
44 args = new String[] { "libandroid-emacs.so", };
45 else
46 args = new String[] { "libandroid-emacs.so", "-Q", };
47 }
43 else 48 else
44 args = new String[] { "libandroid-emacs.so", "-Q", }; 49 {
50 if (!startDashQ)
51 args = new String[] { "libandroid-emacs.so", "--dump-file",
52 EmacsApplication.dumpFileName, };
53 else
54 args = new String[] { "libandroid-emacs.so", "-Q",
55 "--dump-file",
56 EmacsApplication.dumpFileName, };
57 }
45 58
46 /* Run the native code now. */ 59 /* Run the native code now. */
47 EmacsNative.initEmacs (args); 60 EmacsNative.initEmacs (args);