aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorPo Lu2023-06-09 14:03:50 +0800
committerPo Lu2023-06-09 14:03:50 +0800
commitc321eea5af535d102c5e1d2d7e95029ce6fee427 (patch)
treeefd19f5c11d2bf426c196ab97403aa1d58e223b9 /java
parent7f073df53374bc1b96ac07e949af11b8af06b94b (diff)
downloademacs-c321eea5af535d102c5e1d2d7e95029ce6fee427.tar.gz
emacs-c321eea5af535d102c5e1d2d7e95029ce6fee427.zip
Block profiling signals in the Android UI thread
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): New function `setupSystemThread'. * java/org/gnu/emacs/EmacsService.java (onCreate): Block all signals except for SIGBUS and SIGSEGV in the UI thread. * src/android.c (setupSystemThread): New function.
Diffstat (limited to 'java')
-rw-r--r--java/org/gnu/emacs/EmacsNative.java4
-rw-r--r--java/org/gnu/emacs/EmacsService.java25
2 files changed, 29 insertions, 0 deletions
diff --git a/java/org/gnu/emacs/EmacsNative.java b/java/org/gnu/emacs/EmacsNative.java
index cb89cf6808a..2fcbf8b94ef 100644
--- a/java/org/gnu/emacs/EmacsNative.java
+++ b/java/org/gnu/emacs/EmacsNative.java
@@ -188,6 +188,10 @@ public final class EmacsNative
188 KEYCODE_VOLUME_MUTE should be forwarded to Emacs. */ 188 KEYCODE_VOLUME_MUTE should be forwarded to Emacs. */
189 public static native boolean shouldForwardMultimediaButtons (); 189 public static native boolean shouldForwardMultimediaButtons ();
190 190
191 /* Initialize the current thread, by blocking signals that do not
192 interest it. */
193 public static native void setupSystemThread ();
194
191 195
192 196
193 /* Input connection functions. These mostly correspond to their 197 /* Input connection functions. These mostly correspond to their
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java
index 48e39f8b355..96216e51cf4 100644
--- a/java/org/gnu/emacs/EmacsService.java
+++ b/java/org/gnu/emacs/EmacsService.java
@@ -25,6 +25,7 @@ import java.io.UnsupportedEncodingException;
25 25
26import java.util.List; 26import java.util.List;
27 27
28import java.util.concurrent.Semaphore;
28import java.util.concurrent.atomic.AtomicInteger; 29import java.util.concurrent.atomic.AtomicInteger;
29 30
30import android.graphics.Matrix; 31import android.graphics.Matrix;
@@ -211,6 +212,7 @@ public final class EmacsService extends Service
211 final String filesDir, libDir, cacheDir, classPath; 212 final String filesDir, libDir, cacheDir, classPath;
212 final double pixelDensityX; 213 final double pixelDensityX;
213 final double pixelDensityY; 214 final double pixelDensityY;
215 final Semaphore signalSemaphore;
214 216
215 SERVICE = this; 217 SERVICE = this;
216 handler = new Handler (Looper.getMainLooper ()); 218 handler = new Handler (Looper.getMainLooper ());
@@ -220,6 +222,7 @@ public final class EmacsService extends Service
220 pixelDensityX = metrics.xdpi; 222 pixelDensityX = metrics.xdpi;
221 pixelDensityY = metrics.ydpi; 223 pixelDensityY = metrics.ydpi;
222 resolver = getContentResolver (); 224 resolver = getContentResolver ();
225 signalSemaphore = new Semaphore (0);
223 226
224 try 227 try
225 { 228 {
@@ -248,11 +251,33 @@ public final class EmacsService extends Service
248 cacheDir, (float) pixelDensityX, 251 cacheDir, (float) pixelDensityX,
249 (float) pixelDensityY, 252 (float) pixelDensityY,
250 classPath, EmacsService.this); 253 classPath, EmacsService.this);
254
255 /* Wait for the signal mask to be set up in the UI
256 thread. */
257
258 while (true)
259 {
260 try
261 {
262 signalSemaphore.acquire ();
263 break;
264 }
265 catch (InterruptedException e)
266 {
267 ;;
268 }
269 }
251 } 270 }
252 }, extraStartupArgument, 271 }, extraStartupArgument,
253 /* If any file needs to be opened, open it now. */ 272 /* If any file needs to be opened, open it now. */
254 EmacsOpenActivity.fileToOpen); 273 EmacsOpenActivity.fileToOpen);
255 thread.start (); 274 thread.start ();
275
276 /* Now that the thread has been started, block signals which
277 don't interest the current thread. */
278
279 EmacsNative.setupSystemThread ();
280 signalSemaphore.release ();
256 } 281 }
257 catch (IOException exception) 282 catch (IOException exception)
258 { 283 {