aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorPo Lu2023-02-17 16:27:00 +0800
committerPo Lu2023-02-17 16:27:00 +0800
commit88afd96e36e62017c9c1f2229e2748b6dfbdb39a (patch)
tree218845ef248e9ba2131abd22404e3de9dfbf3cbd /java
parent759e6a24ab9690541acc6ece1adebaf524d6e5ae (diff)
downloademacs-88afd96e36e62017c9c1f2229e2748b6dfbdb39a.tar.gz
emacs-88afd96e36e62017c9c1f2229e2748b6dfbdb39a.zip
Fix build and running on Android 2.2
* INSTALL.android: Document that Android 2.2 is now supported, with caveats. * configure.ac (ANDROID_MIN_SDK, ANDROID_SDK_18_OR_EARLIER) (SYSTEM_TYPE, ANDROID_STUBIFY, SIZEOF_LONG): Correctly detect things missing on Android 2.2. * java/Makefile.in (ANDROID_JAR, JARSIGNER_FLAGS): * java/debug.sh (jdb, gdbserver, line): * java/org/gnu/emacs/EmacsApplication.java (findDumpFile): * java/org/gnu/emacs/EmacsService.java (onCreate): * java/org/gnu/emacs/EmacsThread.java (EmacsThread, run): Run parameter initialization on main thread. * src/android-asset.h (struct android_asset_manager) (struct android_asset, AAssetManager_fromJava, AAssetManager_open) (AAsset_close, android_asset_create_stream) (android_asset_read_internal, AAsset_openFileDescriptor) (AAsset_getLength, AAsset_getBuffer, AAsset_read): New file. * src/android.c (android_user_full_name, android_hack_asset_fd) (android_check_compressed_file): Implement for Android 2.2. * src/process.c (Fprocess_send_eof): Don't call tcdrain if unavailable. * src/sfntfont-android.c (system_font_directories): Fix compiler warning. * src/sfntfont.c (sfntfont_read_cmap): Correctly test rc of emacs_open. * src/textconv.c (handle_pending_conversion_events_1): Mark buffer UNINIT.
Diffstat (limited to 'java')
-rw-r--r--java/Makefile.in14
-rwxr-xr-xjava/debug.sh8
-rw-r--r--java/org/gnu/emacs/EmacsApplication.java1
-rw-r--r--java/org/gnu/emacs/EmacsService.java25
-rw-r--r--java/org/gnu/emacs/EmacsThread.java9
5 files changed, 44 insertions, 13 deletions
diff --git a/java/Makefile.in b/java/Makefile.in
index fc0d23980e4..92c03469c69 100644
--- a/java/Makefile.in
+++ b/java/Makefile.in
@@ -39,6 +39,7 @@ JARSIGNER_FLAGS =
39ANDROID_JAR = @ANDROID_JAR@ 39ANDROID_JAR = @ANDROID_JAR@
40ANDROID_ABI = @ANDROID_ABI@ 40ANDROID_ABI = @ANDROID_ABI@
41ANDROID_SDK_18_OR_EARLIER = @ANDROID_SDK_18_OR_EARLIER@ 41ANDROID_SDK_18_OR_EARLIER = @ANDROID_SDK_18_OR_EARLIER@
42ANDROID_SDK_8_OR_EARLIER = @ANDROID_SDK_8_OR_EARLIER@
42 43
43WARN_JAVAFLAGS = -Xlint:deprecation 44WARN_JAVAFLAGS = -Xlint:deprecation
44JAVAFLAGS = -classpath "$(ANDROID_JAR):." -target 1.7 -source 1.7 \ 45JAVAFLAGS = -classpath "$(ANDROID_JAR):." -target 1.7 -source 1.7 \
@@ -53,6 +54,16 @@ else
53JARSIGNER_FLAGS = 54JARSIGNER_FLAGS =
54endif 55endif
55 56
57# When building Emacs for Android 2.2, assets must not be compressed.
58# Otherwise, the asset manager fails to extract files larger than 1
59# MB.
60
61ifneq (,$(ANDROID_SDK_8_OR_EARLIER))
62AAPT_ASSET_ARGS = -0 ""
63else
64AAPT_ASSET_ARGS =
65endif
66
56SIGN_EMACS = -keystore emacs.keystore -storepass emacs1 $(JARSIGNER_FLAGS) 67SIGN_EMACS = -keystore emacs.keystore -storepass emacs1 $(JARSIGNER_FLAGS)
57SIGN_EMACS_V2 = sign --v2-signing-enabled --ks emacs.keystore \ 68SIGN_EMACS_V2 = sign --v2-signing-enabled --ks emacs.keystore \
58 --debuggable-apk-permitted --ks-pass pass:emacs1 69 --debuggable-apk-permitted --ks-pass pass:emacs1
@@ -192,7 +203,8 @@ emacs.apk-in: install_temp install_temp/assets/directory-tree \
192# of Android. Make sure not to generate R.java, as it's already been 203# of Android. Make sure not to generate R.java, as it's already been
193# generated. 204# generated.
194 $(AM_V_AAPT) $(AAPT) p -I "$(ANDROID_JAR)" -F $@ \ 205 $(AM_V_AAPT) $(AAPT) p -I "$(ANDROID_JAR)" -F $@ \
195 -f -M AndroidManifest.xml -A install_temp/assets \ 206 -f -M AndroidManifest.xml $(AAPT_ASSET_ARGS) \
207 -A install_temp/assets \
196 -S res -J install_temp 208 -S res -J install_temp
197 $(AM_V_SILENT) pushd install_temp &> /dev/null; \ 209 $(AM_V_SILENT) pushd install_temp &> /dev/null; \
198 $(AAPT) add ../$@ `find lib -type f`; \ 210 $(AAPT) add ../$@ `find lib -type f`; \
diff --git a/java/debug.sh b/java/debug.sh
index cbef7518984..30e5a94eee5 100755
--- a/java/debug.sh
+++ b/java/debug.sh
@@ -32,6 +32,7 @@ jdb_port=64013
32jdb=no 32jdb=no
33attach_existing=no 33attach_existing=no
34gdbserver= 34gdbserver=
35gdb=gdb
35 36
36while [ $# -gt 0 ]; do 37while [ $# -gt 0 ]; do
37 case "$1" in 38 case "$1" in
@@ -51,6 +52,7 @@ while [ $# -gt 0 ]; do
51 echo " --port PORT run the GDB server on a specific port" 52 echo " --port PORT run the GDB server on a specific port"
52 echo " --jdb-port PORT run the JDB server on a specific port" 53 echo " --jdb-port PORT run the JDB server on a specific port"
53 echo " --jdb run JDB instead of GDB" 54 echo " --jdb run JDB instead of GDB"
55 echo " --gdb use specified GDB binary"
54 echo " --attach-existing attach to an existing process" 56 echo " --attach-existing attach to an existing process"
55 echo " --gdbserver BINARY upload and use the specified gdbserver binary" 57 echo " --gdbserver BINARY upload and use the specified gdbserver binary"
56 echo " --help print this message" 58 echo " --help print this message"
@@ -65,6 +67,10 @@ while [ $# -gt 0 ]; do
65 "--jdb" ) 67 "--jdb" )
66 jdb=yes 68 jdb=yes
67 ;; 69 ;;
70 "--gdb" )
71 shift
72 gdb=$1
73 ;;
68 "--gdbserver" ) 74 "--gdbserver" )
69 shift 75 shift
70 gdbserver=$1 76 gdbserver=$1
@@ -355,4 +361,4 @@ fi
355 361
356# Finally, start gdb with any extra arguments needed. 362# Finally, start gdb with any extra arguments needed.
357cd "$oldpwd" 363cd "$oldpwd"
358gdb --eval-command "target remote localhost:$gdb_port" $gdbargs 364$gdb --eval-command "target remote localhost:$gdb_port" $gdbargs
diff --git a/java/org/gnu/emacs/EmacsApplication.java b/java/org/gnu/emacs/EmacsApplication.java
index 96328b99d1c..6a065165eb1 100644
--- a/java/org/gnu/emacs/EmacsApplication.java
+++ b/java/org/gnu/emacs/EmacsApplication.java
@@ -49,6 +49,7 @@ public class EmacsApplication extends Application
49 for a file named ``emacs-<fingerprint>.pdmp'' and delete the 49 for a file named ``emacs-<fingerprint>.pdmp'' and delete the
50 rest. */ 50 rest. */
51 filesDirectory = context.getFilesDir (); 51 filesDirectory = context.getFilesDir ();
52
52 allFiles = filesDirectory.listFiles (new FileFilter () { 53 allFiles = filesDirectory.listFiles (new FileFilter () {
53 @Override 54 @Override
54 public boolean 55 public boolean
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java
index 2acb3ead086..4d373937ab0 100644
--- a/java/org/gnu/emacs/EmacsService.java
+++ b/java/org/gnu/emacs/EmacsService.java
@@ -180,11 +180,11 @@ public class EmacsService extends Service
180 public void 180 public void
181 onCreate () 181 onCreate ()
182 { 182 {
183 AssetManager manager; 183 final AssetManager manager;
184 Context app_context; 184 Context app_context;
185 String filesDir, libDir, cacheDir, classPath; 185 final String filesDir, libDir, cacheDir, classPath;
186 double pixelDensityX; 186 final double pixelDensityX;
187 double pixelDensityY; 187 final double pixelDensityY;
188 188
189 SERVICE = this; 189 SERVICE = this;
190 handler = new Handler (Looper.getMainLooper ()); 190 handler = new Handler (Looper.getMainLooper ());
@@ -210,13 +210,18 @@ public class EmacsService extends Service
210 Log.d (TAG, "Initializing Emacs, where filesDir = " + filesDir 210 Log.d (TAG, "Initializing Emacs, where filesDir = " + filesDir
211 + ", libDir = " + libDir + ", and classPath = " + classPath); 211 + ", libDir = " + libDir + ", and classPath = " + classPath);
212 212
213 EmacsNative.setEmacsParams (manager, filesDir, libDir,
214 cacheDir, (float) pixelDensityX,
215 (float) pixelDensityY,
216 classPath, this);
217
218 /* Start the thread that runs Emacs. */ 213 /* Start the thread that runs Emacs. */
219 thread = new EmacsThread (this, needDashQ); 214 thread = new EmacsThread (this, new Runnable () {
215 @Override
216 public void
217 run ()
218 {
219 EmacsNative.setEmacsParams (manager, filesDir, libDir,
220 cacheDir, (float) pixelDensityX,
221 (float) pixelDensityY,
222 classPath, EmacsService.this);
223 }
224 }, needDashQ);
220 thread.start (); 225 thread.start ();
221 } 226 }
222 catch (IOException exception) 227 catch (IOException exception)
diff --git a/java/org/gnu/emacs/EmacsThread.java b/java/org/gnu/emacs/EmacsThread.java
index 2724d838d41..30484710651 100644
--- a/java/org/gnu/emacs/EmacsThread.java
+++ b/java/org/gnu/emacs/EmacsThread.java
@@ -28,11 +28,16 @@ public class EmacsThread extends Thread
28 /* Whether or not Emacs should be started -Q. */ 28 /* Whether or not Emacs should be started -Q. */
29 private boolean startDashQ; 29 private boolean startDashQ;
30 30
31 /* Runnable run to initialize Emacs. */
32 private Runnable paramsClosure;
33
31 public 34 public
32 EmacsThread (EmacsService service, boolean startDashQ) 35 EmacsThread (EmacsService service, Runnable paramsClosure,
36 boolean startDashQ)
33 { 37 {
34 super ("Emacs main thread"); 38 super ("Emacs main thread");
35 this.startDashQ = startDashQ; 39 this.startDashQ = startDashQ;
40 this.paramsClosure = paramsClosure;
36 } 41 }
37 42
38 @Override 43 @Override
@@ -46,6 +51,8 @@ public class EmacsThread extends Thread
46 else 51 else
47 args = new String[] { "libandroid-emacs.so", "-Q", }; 52 args = new String[] { "libandroid-emacs.so", "-Q", };
48 53
54 paramsClosure.run ();
55
49 /* Run the native code now. */ 56 /* Run the native code now. */
50 EmacsNative.initEmacs (args, EmacsApplication.dumpFileName, 57 EmacsNative.initEmacs (args, EmacsApplication.dumpFileName,
51 Build.VERSION.SDK_INT); 58 Build.VERSION.SDK_INT);