aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorPo Lu2023-11-09 10:12:24 +0800
committerPo Lu2023-11-09 10:12:24 +0800
commit21f36705266934d5a351d4d7f360734540132139 (patch)
treec67ff837f417bec1663df6700fe9b2b5ce330cc9 /java
parent06e4ebc81a44c709b08ce72c746629c6c77e6f6e (diff)
downloademacs-21f36705266934d5a351d4d7f360734540132139.tar.gz
emacs-21f36705266934d5a351d4d7f360734540132139.zip
Guarantee files are auto-saved when Emacs is terminated by Android
* java/org/gnu/emacs/EmacsNative.java (shutDownEmacs): * java/org/gnu/emacs/EmacsService.java (onDestroy): New function. When invoked, call shut_down_emacs and await its completion. * src/android.c (android_shut_down_emacs, shutDownEmacs): New functions.
Diffstat (limited to 'java')
-rw-r--r--java/org/gnu/emacs/EmacsNative.java4
-rw-r--r--java/org/gnu/emacs/EmacsService.java12
2 files changed, 16 insertions, 0 deletions
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java
index f15927bb3a7..946a38f7f84 100644
--- a/java/org/gnu/emacs/EmacsNative.java
+++ b/java/org/gnu/emacs/EmacsNative.java
@@ -92,6 +92,10 @@ public final class EmacsNative
92 loadup.el itself. */ 92 loadup.el itself. */
93 public static native void initEmacs (String argv[], String dumpFile); 93 public static native void initEmacs (String argv[], String dumpFile);
94 94
95 /* Call shut_down_emacs to auto-save and unlock files in the main
96 thread, then return. */
97 public static native void shutDownEmacs ();
98
95 /* Abort and generate a native core dump. */ 99 /* Abort and generate a native core dump. */
96 public static native void emacsAbort (); 100 public static native void emacsAbort ();
97 101
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java
index 1325cd85e9b..ab6d57b9c4f 100644
--- a/java/org/gnu/emacs/EmacsService.java
+++ b/java/org/gnu/emacs/EmacsService.java
@@ -321,6 +321,18 @@ public final class EmacsService extends Service
321 } 321 }
322 } 322 }
323 323
324 @Override
325 public void
326 onDestroy ()
327 {
328 /* This function is called immediately before the system kills
329 Emacs. In this respect, it is rather akin to a SIGDANGER
330 signal, so force an auto-save accordingly. */
331
332 EmacsNative.shutDownEmacs ();
333 super.onDestroy ();
334 }
335
324 336
325 337
326 /* Functions from here on must only be called from the Emacs 338 /* Functions from here on must only be called from the Emacs