summaryrefslogtreecommitdiff
path: root/java/org/gnu/emacs/EmacsOpenActivity.java
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-02-06 22:55:42 +0800
committerPo Lu <luangruo@yahoo.com>2023-02-06 22:55:42 +0800
commit9b79f429edd173efd6ecbdcb2f0a5fafa8d6e523 (patch)
tree2238081f61d08370b2e848112ddf5a5e6e8ba33e /java/org/gnu/emacs/EmacsOpenActivity.java
parente1c7b8ad61a213014ae3bf87db197301ab2bac29 (diff)
Port emacsclient wrapper to Android 7.1 and earlier
* java/org/gnu/emacs/EmacsNative.java (EmacsNative): Load every native library on which Emacs depends prior to loading libemacs itself. * java/org/gnu/emacs/EmacsOpenActivity.java (readEmacsClientLog) (EmacsOpenActivity, startEmacsClient): Don't use redirectError on Android 7.1 and earlier.
Diffstat (limited to 'java/org/gnu/emacs/EmacsOpenActivity.java')
-rw-r--r--java/org/gnu/emacs/EmacsOpenActivity.java33
1 files changed, 25 insertions, 8 deletions
diff --git a/java/org/gnu/emacs/EmacsOpenActivity.java b/java/org/gnu/emacs/EmacsOpenActivity.java
index e987e067a73..baf31039ecd 100644
--- a/java/org/gnu/emacs/EmacsOpenActivity.java
+++ b/java/org/gnu/emacs/EmacsOpenActivity.java
@@ -125,6 +125,16 @@ public class EmacsOpenActivity extends Activity
int rc;
String what;
+ /* Because the ProcessBuilder functions necessary to redirect
+ process output are not implemented on Android 7 and earlier,
+ print a generic error message. */
+
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
+ return ("This is likely because the Emacs server"
+ + " is not running, or because you did"
+ + " not grant Emacs permission to access"
+ + " external storage.");
+
cache = getCacheDir ();
file = new File (cache, "emacsclient.log");
what = "";
@@ -199,7 +209,8 @@ public class EmacsOpenActivity extends Activity
Use TITLE as the title of the dialog. If TEXT is non-NULL,
display that text in the dialog. Otherwise, use the contents of
- emacsclient.log in the cache directory instead. */
+ emacsclient.log in the cache directory instead, or describe why
+ that file cannot be read. */
public void
finishFailure (final String title, final String text)
@@ -240,20 +251,26 @@ public class EmacsOpenActivity extends Activity
EmacsClientThread thread;
File file;
- file = new File (getCacheDir (), "emacsclient.log");
-
libDir = getLibraryDirectory ();
builder = new ProcessBuilder (libDir + "/libemacsclient.so",
fileName, "--reuse-frame",
"--timeout=10", "--no-wait");
- /* Redirect standard error to a file so that errors can be
- meaningfully reported. */
+ /* Redirection is unfortunately not possible in Android 7 and
+ earlier. */
- if (file.exists ())
- file.delete ();
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
+ {
+ file = new File (getCacheDir (), "emacsclient.log");
- builder.redirectError (file);
+ /* Redirect standard error to a file so that errors can be
+ meaningfully reported. */
+
+ if (file.exists ())
+ file.delete ();
+
+ builder.redirectError (file);
+ }
/* Track process output in a new thread, since this is the UI
thread and doing so here can cause deadlocks when EmacsService