SDL: SDLActivity.java: Compatibility fix for debugSource

From 68beedde9274ea25d7f8b3b565ec141f54a21c8e Mon Sep 17 00:00:00 2001
From: Wohlstand <[EMAIL REDACTED]>
Date: Thu, 16 Jun 2022 22:16:11 +0300
Subject: [PATCH] SDLActivity.java: Compatibility fix for debugSource

I did these fixes a while ago while debuggin my application, however, forgot to send them back.
---
 .../main/java/org/libsdl/app/SDLActivity.java | 26 ++++++++++++-------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
index 28f3c6776e1..d2873ff6cd5 100644
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
@@ -84,7 +84,7 @@ public static void debugSource(int sources, String prefix) {
 
 
         int s2 = s_copy & ~InputDevice.SOURCE_ANY; // keep class bits
-        s2 &= ~(  InputDevice.SOURCE_CLASS_BUTTON 
+        s2 &= ~(  InputDevice.SOURCE_CLASS_BUTTON
                 | InputDevice.SOURCE_CLASS_JOYSTICK
                 | InputDevice.SOURCE_CLASS_POINTER
                 | InputDevice.SOURCE_CLASS_POSITION
@@ -94,9 +94,11 @@ public static void debugSource(int sources, String prefix) {
 
         s2 = s_copy & InputDevice.SOURCE_ANY; // keep source only, no class;
 
-        tst = InputDevice.SOURCE_BLUETOOTH_STYLUS;
-        if ((s & tst) == tst) src += " BLUETOOTH_STYLUS";
-        s2 &= ~tst;
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
+            tst = InputDevice.SOURCE_BLUETOOTH_STYLUS;
+            if ((s & tst) == tst) src += " BLUETOOTH_STYLUS";
+            s2 &= ~tst;
+        }
 
         tst = InputDevice.SOURCE_DPAD;
         if ((s & tst) == tst) src += " DPAD";
@@ -106,9 +108,11 @@ public static void debugSource(int sources, String prefix) {
         if ((s & tst) == tst) src += " GAMEPAD";
         s2 &= ~tst;
 
-        tst = InputDevice.SOURCE_HDMI;
-        if ((s & tst) == tst) src += " HDMI";
-        s2 &= ~tst;
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
+            tst = InputDevice.SOURCE_HDMI;
+            if ((s & tst) == tst) src += " HDMI";
+            s2 &= ~tst;
+        }
 
         tst = InputDevice.SOURCE_JOYSTICK;
         if ((s & tst) == tst) src += " JOYSTICK";
@@ -143,9 +147,11 @@ public static void debugSource(int sources, String prefix) {
         if ((s & tst) == tst) src += " TOUCHSCREEN";
         s2 &= ~tst;
 
-        tst = InputDevice.SOURCE_TOUCH_NAVIGATION;
-        if ((s & tst) == tst) src += " TOUCH_NAVIGATION";
-        s2 &= ~tst;
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+            tst = InputDevice.SOURCE_TOUCH_NAVIGATION;
+            if ((s & tst) == tst) src += " TOUCH_NAVIGATION";
+            s2 &= ~tst;
+        }
 
         tst = InputDevice.SOURCE_TRACKBALL;
         if ((s & tst) == tst) src += " TRACKBALL";