diff options
| author | Po Lu | 2023-03-13 13:25:02 +0800 |
|---|---|---|
| committer | Po Lu | 2023-03-13 13:25:02 +0800 |
| commit | b776feb7f2737fb6b3fca05ae3b786dc67a2a9ae (patch) | |
| tree | bd584cbbcfb65de14c1f612c6bac42731c7d6cb9 /java | |
| parent | c3524b15aa77b309f325fcb806fe9e9c91c4e99e (diff) | |
| download | emacs-b776feb7f2737fb6b3fca05ae3b786dc67a2a9ae.tar.gz emacs-b776feb7f2737fb6b3fca05ae3b786dc67a2a9ae.zip | |
Update Android port
* doc/emacs/android.texi (Android Startup): Document changes to
emacsclient wrapper.
* java/org/gnu/emacs/EmacsOpenActivity.java (EmacsOpenActivity)
(startEmacsClient): Open EmacsActivity if the service is not
running.
* java/org/gnu/emacs/EmacsService.java (onCreate):
* java/org/gnu/emacs/EmacsThread.java (EmacsThread, run): Pass
any file to open to Emacs.
* lisp/term/android-win.el (handle-args-function): Implement.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsOpenActivity.java | 15 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsService.java | 7 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsThread.java | 29 |
3 files changed, 45 insertions, 6 deletions
diff --git a/java/org/gnu/emacs/EmacsOpenActivity.java b/java/org/gnu/emacs/EmacsOpenActivity.java index e8fb24d53d8..f402e25c7fb 100644 --- a/java/org/gnu/emacs/EmacsOpenActivity.java +++ b/java/org/gnu/emacs/EmacsOpenActivity.java | |||
| @@ -72,6 +72,7 @@ public final class EmacsOpenActivity extends Activity | |||
| 72 | DialogInterface.OnCancelListener | 72 | DialogInterface.OnCancelListener |
| 73 | { | 73 | { |
| 74 | private static final String TAG = "EmacsOpenActivity"; | 74 | private static final String TAG = "EmacsOpenActivity"; |
| 75 | public static String fileToOpen; | ||
| 75 | 76 | ||
| 76 | private class EmacsClientThread extends Thread | 77 | private class EmacsClientThread extends Thread |
| 77 | { | 78 | { |
| @@ -317,6 +318,20 @@ public final class EmacsOpenActivity extends Activity | |||
| 317 | Process process; | 318 | Process process; |
| 318 | EmacsClientThread thread; | 319 | EmacsClientThread thread; |
| 319 | File file; | 320 | File file; |
| 321 | Intent intent; | ||
| 322 | |||
| 323 | /* If the Emacs service is not running, then start Emacs and make | ||
| 324 | it open this file. */ | ||
| 325 | |||
| 326 | if (EmacsService.SERVICE == null) | ||
| 327 | { | ||
| 328 | fileToOpen = fileName; | ||
| 329 | intent = new Intent (EmacsOpenActivity.this, | ||
| 330 | EmacsActivity.class); | ||
| 331 | finish (); | ||
| 332 | startActivity (intent); | ||
| 333 | return; | ||
| 334 | } | ||
| 320 | 335 | ||
| 321 | libDir = EmacsService.getLibraryDirectory (this); | 336 | libDir = EmacsService.getLibraryDirectory (this); |
| 322 | builder = new ProcessBuilder (libDir + "/libemacsclient.so", | 337 | builder = new ProcessBuilder (libDir + "/libemacsclient.so", |
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 9c48c56ca26..33436892caa 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java | |||
| @@ -215,7 +215,8 @@ public final class EmacsService extends Service | |||
| 215 | classPath = getApkFile (); | 215 | classPath = getApkFile (); |
| 216 | 216 | ||
| 217 | Log.d (TAG, "Initializing Emacs, where filesDir = " + filesDir | 217 | Log.d (TAG, "Initializing Emacs, where filesDir = " + filesDir |
| 218 | + ", libDir = " + libDir + ", and classPath = " + classPath); | 218 | + ", libDir = " + libDir + ", and classPath = " + classPath |
| 219 | + "; fileToOpen = " + EmacsOpenActivity.fileToOpen); | ||
| 219 | 220 | ||
| 220 | /* Start the thread that runs Emacs. */ | 221 | /* Start the thread that runs Emacs. */ |
| 221 | thread = new EmacsThread (this, new Runnable () { | 222 | thread = new EmacsThread (this, new Runnable () { |
| @@ -228,7 +229,9 @@ public final class EmacsService extends Service | |||
| 228 | (float) pixelDensityY, | 229 | (float) pixelDensityY, |
| 229 | classPath, EmacsService.this); | 230 | classPath, EmacsService.this); |
| 230 | } | 231 | } |
| 231 | }, needDashQ); | 232 | }, needDashQ, |
| 233 | /* If any file needs to be opened, open it now. */ | ||
| 234 | EmacsOpenActivity.fileToOpen); | ||
| 232 | thread.start (); | 235 | thread.start (); |
| 233 | } | 236 | } |
| 234 | catch (IOException exception) | 237 | catch (IOException exception) |
diff --git a/java/org/gnu/emacs/EmacsThread.java b/java/org/gnu/emacs/EmacsThread.java index 30484710651..d175fe332b5 100644 --- a/java/org/gnu/emacs/EmacsThread.java +++ b/java/org/gnu/emacs/EmacsThread.java | |||
| @@ -20,24 +20,32 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ | |||
| 20 | package org.gnu.emacs; | 20 | package org.gnu.emacs; |
| 21 | 21 | ||
| 22 | import java.lang.Thread; | 22 | import java.lang.Thread; |
| 23 | import java.util.Arrays; | ||
| 23 | 24 | ||
| 24 | import android.os.Build; | 25 | import android.os.Build; |
| 26 | import android.util.Log; | ||
| 25 | 27 | ||
| 26 | public class EmacsThread extends Thread | 28 | public class EmacsThread extends Thread |
| 27 | { | 29 | { |
| 30 | private static final String TAG = "EmacsThread"; | ||
| 31 | |||
| 28 | /* Whether or not Emacs should be started -Q. */ | 32 | /* Whether or not Emacs should be started -Q. */ |
| 29 | private boolean startDashQ; | 33 | private boolean startDashQ; |
| 30 | 34 | ||
| 31 | /* Runnable run to initialize Emacs. */ | 35 | /* Runnable run to initialize Emacs. */ |
| 32 | private Runnable paramsClosure; | 36 | private Runnable paramsClosure; |
| 33 | 37 | ||
| 38 | /* Whether or not to open a file after starting Emacs. */ | ||
| 39 | private String fileToOpen; | ||
| 40 | |||
| 34 | public | 41 | public |
| 35 | EmacsThread (EmacsService service, Runnable paramsClosure, | 42 | EmacsThread (EmacsService service, Runnable paramsClosure, |
| 36 | boolean startDashQ) | 43 | boolean startDashQ, String fileToOpen) |
| 37 | { | 44 | { |
| 38 | super ("Emacs main thread"); | 45 | super ("Emacs main thread"); |
| 39 | this.startDashQ = startDashQ; | 46 | this.startDashQ = startDashQ; |
| 40 | this.paramsClosure = paramsClosure; | 47 | this.paramsClosure = paramsClosure; |
| 48 | this.fileToOpen = fileToOpen; | ||
| 41 | } | 49 | } |
| 42 | 50 | ||
| 43 | @Override | 51 | @Override |
| @@ -46,14 +54,27 @@ public class EmacsThread extends Thread | |||
| 46 | { | 54 | { |
| 47 | String args[]; | 55 | String args[]; |
| 48 | 56 | ||
| 49 | if (!startDashQ) | 57 | if (fileToOpen == null) |
| 50 | args = new String[] { "libandroid-emacs.so", }; | 58 | { |
| 59 | if (!startDashQ) | ||
| 60 | args = new String[] { "libandroid-emacs.so", }; | ||
| 61 | else | ||
| 62 | args = new String[] { "libandroid-emacs.so", "-Q", }; | ||
| 63 | } | ||
| 51 | else | 64 | else |
| 52 | args = new String[] { "libandroid-emacs.so", "-Q", }; | 65 | { |
| 66 | if (!startDashQ) | ||
| 67 | args = new String[] { "libandroid-emacs.so", | ||
| 68 | fileToOpen, }; | ||
| 69 | else | ||
| 70 | args = new String[] { "libandroid-emacs.so", "-Q", | ||
| 71 | fileToOpen, }; | ||
| 72 | } | ||
| 53 | 73 | ||
| 54 | paramsClosure.run (); | 74 | paramsClosure.run (); |
| 55 | 75 | ||
| 56 | /* Run the native code now. */ | 76 | /* Run the native code now. */ |
| 77 | Log.d (TAG, "run: " + Arrays.toString (args)); | ||
| 57 | EmacsNative.initEmacs (args, EmacsApplication.dumpFileName, | 78 | EmacsNative.initEmacs (args, EmacsApplication.dumpFileName, |
| 58 | Build.VERSION.SDK_INT); | 79 | Build.VERSION.SDK_INT); |
| 59 | } | 80 | } |