diff options
| author | Po Lu | 2023-01-25 22:07:51 +0800 |
|---|---|---|
| committer | Po Lu | 2023-01-25 22:07:51 +0800 |
| commit | 0b1ef9ea31ce039001546b3ed34494332e5e3629 (patch) | |
| tree | 3b3caec2303410053921aa76c1351349f013cedf /java | |
| parent | d3b29ccc89f2c14754e6b817da45b4c3f80e670f (diff) | |
| download | emacs-0b1ef9ea31ce039001546b3ed34494332e5e3629.tar.gz emacs-0b1ef9ea31ce039001546b3ed34494332e5e3629.zip | |
Update Android port
* java/org/gnu/emacs/EmacsDrawLine.java: Fix this again. Gosh,
how does Android do this.
* java/org/gnu/emacs/EmacsNoninteractive.java (main): Port to
Android 2.3.3.
* java/org/gnu/emacs/EmacsSdk11Clipboard.java
(EmacsSdk11Clipboard): Port to Android 4.0.3.
* java/org/gnu/emacs/EmacsService.java (getClipboardManager):
New function.
* src/alloc.c (find_string_data_in_pure): Fix Android alignment
issue.
* src/android-emacs.c (main): Port to Android 4.4.
* src/android.c (initEmacs): Align stack to 32 bytes, so it ends
up aligned to 16 even though gcc thinks the stack is already
aligned to 16 bytes.
* src/callproc.c (init_callproc): Use /system/bin/sh instead of
/bin/sh by default.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsDrawLine.java | 2 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsNoninteractive.java | 30 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsSdk11Clipboard.java | 8 | ||||
| -rw-r--r-- | java/org/gnu/emacs/EmacsService.java | 46 |
4 files changed, 72 insertions, 14 deletions
diff --git a/java/org/gnu/emacs/EmacsDrawLine.java b/java/org/gnu/emacs/EmacsDrawLine.java index 717e2279a7d..c6e5123bfca 100644 --- a/java/org/gnu/emacs/EmacsDrawLine.java +++ b/java/org/gnu/emacs/EmacsDrawLine.java | |||
| @@ -60,7 +60,7 @@ public class EmacsDrawLine | |||
| 60 | coordinates appropriately. */ | 60 | coordinates appropriately. */ |
| 61 | 61 | ||
| 62 | if (gc.clip_mask == null) | 62 | if (gc.clip_mask == null) |
| 63 | canvas.drawLine ((float) x + 0.5f, (float) y + 0.5f, | 63 | canvas.drawLine ((float) x, (float) y + 0.5f, |
| 64 | (float) x2 + 0.5f, (float) y2 + 0.5f, | 64 | (float) x2 + 0.5f, (float) y2 + 0.5f, |
| 65 | paint); | 65 | paint); |
| 66 | 66 | ||
diff --git a/java/org/gnu/emacs/EmacsNoninteractive.java b/java/org/gnu/emacs/EmacsNoninteractive.java index a3aefee5e0b..b4854d8323f 100644 --- a/java/org/gnu/emacs/EmacsNoninteractive.java +++ b/java/org/gnu/emacs/EmacsNoninteractive.java | |||
| @@ -95,7 +95,7 @@ public class EmacsNoninteractive | |||
| 95 | On Android 2.3.3 and earlier, there is no | 95 | On Android 2.3.3 and earlier, there is no |
| 96 | ``compatibilityInfo'' argument to getPackageInfo. */ | 96 | ``compatibilityInfo'' argument to getPackageInfo. */ |
| 97 | 97 | ||
| 98 | if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD) | 98 | if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) |
| 99 | { | 99 | { |
| 100 | method | 100 | method |
| 101 | = activityThreadClass.getMethod ("getPackageInfo", | 101 | = activityThreadClass.getMethod ("getPackageInfo", |
| @@ -123,11 +123,29 @@ public class EmacsNoninteractive | |||
| 123 | 123 | ||
| 124 | /* Now, get a context. */ | 124 | /* Now, get a context. */ |
| 125 | contextImplClass = Class.forName ("android.app.ContextImpl"); | 125 | contextImplClass = Class.forName ("android.app.ContextImpl"); |
| 126 | method = contextImplClass.getDeclaredMethod ("createAppContext", | 126 | |
| 127 | activityThreadClass, | 127 | try |
| 128 | loadedApkClass); | 128 | { |
| 129 | method.setAccessible (true); | 129 | method = contextImplClass.getDeclaredMethod ("createAppContext", |
| 130 | context = (Context) method.invoke (null, activityThread, loadedApk); | 130 | activityThreadClass, |
| 131 | loadedApkClass); | ||
| 132 | method.setAccessible (true); | ||
| 133 | context = (Context) method.invoke (null, activityThread, loadedApk); | ||
| 134 | } | ||
| 135 | catch (NoSuchMethodException exception) | ||
| 136 | { | ||
| 137 | /* Older Android versions don't have createAppContext, but | ||
| 138 | instead require creating a ContextImpl, and then | ||
| 139 | calling createPackageContext. */ | ||
| 140 | method = activityThreadClass.getDeclaredMethod ("getSystemContext"); | ||
| 141 | context = (Context) method.invoke (activityThread); | ||
| 142 | method = contextImplClass.getDeclaredMethod ("createPackageContext", | ||
| 143 | String.class, | ||
| 144 | int.class); | ||
| 145 | method.setAccessible (true); | ||
| 146 | context = (Context) method.invoke (context, "org.gnu.emacs", | ||
| 147 | 0); | ||
| 148 | } | ||
| 131 | 149 | ||
| 132 | /* Don't actually start the looper or anything. Instead, obtain | 150 | /* Don't actually start the looper or anything. Instead, obtain |
| 133 | an AssetManager. */ | 151 | an AssetManager. */ |
diff --git a/java/org/gnu/emacs/EmacsSdk11Clipboard.java b/java/org/gnu/emacs/EmacsSdk11Clipboard.java index 0a725200723..2df2015c9c1 100644 --- a/java/org/gnu/emacs/EmacsSdk11Clipboard.java +++ b/java/org/gnu/emacs/EmacsSdk11Clipboard.java | |||
| @@ -42,13 +42,7 @@ public class EmacsSdk11Clipboard extends EmacsClipboard | |||
| 42 | public | 42 | public |
| 43 | EmacsSdk11Clipboard () | 43 | EmacsSdk11Clipboard () |
| 44 | { | 44 | { |
| 45 | String what; | 45 | manager = EmacsService.SERVICE.getClipboardManager (); |
| 46 | Context context; | ||
| 47 | |||
| 48 | what = Context.CLIPBOARD_SERVICE; | ||
| 49 | context = EmacsService.SERVICE; | ||
| 50 | manager | ||
| 51 | = (ClipboardManager) context.getSystemService (what); | ||
| 52 | manager.addPrimaryClipChangedListener (this); | 46 | manager.addPrimaryClipChangedListener (this); |
| 53 | } | 47 | } |
| 54 | 48 | ||
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 91db76b08e3..eb9b61dd876 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java | |||
| @@ -39,6 +39,7 @@ import android.app.NotificationChannel; | |||
| 39 | import android.app.PendingIntent; | 39 | import android.app.PendingIntent; |
| 40 | import android.app.Service; | 40 | import android.app.Service; |
| 41 | 41 | ||
| 42 | import android.content.ClipboardManager; | ||
| 42 | import android.content.Context; | 43 | import android.content.Context; |
| 43 | import android.content.Intent; | 44 | import android.content.Intent; |
| 44 | import android.content.pm.ApplicationInfo; | 45 | import android.content.pm.ApplicationInfo; |
| @@ -565,4 +566,49 @@ public class EmacsService extends Service | |||
| 565 | 566 | ||
| 566 | return null; | 567 | return null; |
| 567 | } | 568 | } |
| 569 | |||
| 570 | /* Get a SDK 11 ClipboardManager. | ||
| 571 | |||
| 572 | Android 4.0.x requires that this be called from the main | ||
| 573 | thread. */ | ||
| 574 | |||
| 575 | public ClipboardManager | ||
| 576 | getClipboardManager () | ||
| 577 | { | ||
| 578 | final Holder<ClipboardManager> manager; | ||
| 579 | Runnable runnable; | ||
| 580 | |||
| 581 | manager = new Holder<ClipboardManager> (); | ||
| 582 | |||
| 583 | runnable = new Runnable () { | ||
| 584 | public void | ||
| 585 | run () | ||
| 586 | { | ||
| 587 | Object tem; | ||
| 588 | |||
| 589 | synchronized (this) | ||
| 590 | { | ||
| 591 | tem = getSystemService (Context.CLIPBOARD_SERVICE); | ||
| 592 | manager.thing = (ClipboardManager) tem; | ||
| 593 | notify (); | ||
| 594 | } | ||
| 595 | } | ||
| 596 | }; | ||
| 597 | |||
| 598 | synchronized (runnable) | ||
| 599 | { | ||
| 600 | runOnUiThread (runnable); | ||
| 601 | |||
| 602 | try | ||
| 603 | { | ||
| 604 | runnable.wait (); | ||
| 605 | } | ||
| 606 | catch (InterruptedException e) | ||
| 607 | { | ||
| 608 | EmacsNative.emacsAbort (); | ||
| 609 | } | ||
| 610 | } | ||
| 611 | |||
| 612 | return manager.thing; | ||
| 613 | } | ||
| 568 | }; | 614 | }; |