diff options
| author | Po Lu | 2023-07-05 14:57:15 +0800 |
|---|---|---|
| committer | Po Lu | 2023-07-05 14:57:15 +0800 |
| commit | 257e49ff0d333cd5b9967613cb14051d54dd054b (patch) | |
| tree | 8c46c7143679ba70bf3ad70e3bb7f0330951ba06 /java | |
| parent | 9e9142249725b4785a01734a8c0f50301fccdea7 (diff) | |
| download | emacs-257e49ff0d333cd5b9967613cb14051d54dd054b.tar.gz emacs-257e49ff0d333cd5b9967613cb14051d54dd054b.zip | |
Fix crash between Android 4.0 and Android 5.1
* java/org/gnu/emacs/EmacsService.java (detectMouse): Don't use
function that is not present on Android 4.0.
Diffstat (limited to 'java')
| -rw-r--r-- | java/org/gnu/emacs/EmacsService.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 820befb52d2..e1fd2dbffda 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java | |||
| @@ -491,6 +491,8 @@ public final class EmacsService extends Service | |||
| 491 | int i; | 491 | int i; |
| 492 | 492 | ||
| 493 | if (Build.VERSION.SDK_INT | 493 | if (Build.VERSION.SDK_INT |
| 494 | /* Android 4.0 and earlier don't support mouse input events at | ||
| 495 | all. */ | ||
| 494 | < Build.VERSION_CODES.JELLY_BEAN) | 496 | < Build.VERSION_CODES.JELLY_BEAN) |
| 495 | return false; | 497 | return false; |
| 496 | 498 | ||
| @@ -504,8 +506,20 @@ public final class EmacsService extends Service | |||
| 504 | if (device == null) | 506 | if (device == null) |
| 505 | continue; | 507 | continue; |
| 506 | 508 | ||
| 507 | if (device.supportsSource (InputDevice.SOURCE_MOUSE)) | 509 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) |
| 508 | return true; | 510 | { |
| 511 | if (device.supportsSource (InputDevice.SOURCE_MOUSE)) | ||
| 512 | return true; | ||
| 513 | } | ||
| 514 | else | ||
| 515 | { | ||
| 516 | /* `supportsSource' is only present on API level 21 and | ||
| 517 | later, but earlier versions provide a bit mask | ||
| 518 | containing each supported source. */ | ||
| 519 | |||
| 520 | if ((device.getSources () & InputDevice.SOURCE_MOUSE) != 0) | ||
| 521 | return true; | ||
| 522 | } | ||
| 509 | } | 523 | } |
| 510 | 524 | ||
| 511 | return false; | 525 | return false; |