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.
This commit is contained in:
Po Lu 2023-07-05 14:57:15 +08:00
parent 9e91422497
commit 257e49ff0d

View file

@ -491,6 +491,8 @@ invocation of app_process (through android-emacs) can
int i;
if (Build.VERSION.SDK_INT
/* Android 4.0 and earlier don't support mouse input events at
all. */
< Build.VERSION_CODES.JELLY_BEAN)
return false;
@ -504,8 +506,20 @@ invocation of app_process (through android-emacs) can
if (device == null)
continue;
if (device.supportsSource (InputDevice.SOURCE_MOUSE))
return true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
{
if (device.supportsSource (InputDevice.SOURCE_MOUSE))
return true;
}
else
{
/* `supportsSource' is only present on API level 21 and
later, but earlier versions provide a bit mask
containing each supported source. */
if ((device.getSources () & InputDevice.SOURCE_MOUSE) != 0)
return true;
}
}
return false;