diff --git a/app/src/braveLegacy/java/org/schabi/newpipe/util/BraveDeviceUtils.kt b/app/src/braveLegacy/java/org/schabi/newpipe/util/BraveDeviceUtils.kt new file mode 100644 index 000000000..06762382d --- /dev/null +++ b/app/src/braveLegacy/java/org/schabi/newpipe/util/BraveDeviceUtils.kt @@ -0,0 +1,12 @@ +package org.schabi.newpipe.util + +import android.os.Build +import android.view.InputDevice + +fun supportsSource(inputDevice: InputDevice, source: Int): Boolean { + return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + (inputDevice.sources and source) == source + } else { + inputDevice.supportsSource(source) + } +} diff --git a/app/src/braveLegacy/java/org/schabi/newpipe/util/DeviceUtils.java b/app/src/braveLegacy/java/org/schabi/newpipe/util/DeviceUtils.java index 658e43885..06c0dd50d 100644 --- a/app/src/braveLegacy/java/org/schabi/newpipe/util/DeviceUtils.java +++ b/app/src/braveLegacy/java/org/schabi/newpipe/util/DeviceUtils.java @@ -178,11 +178,13 @@ public final class DeviceUtils { final InputManager im = (InputManager) context.getSystemService(INPUT_SERVICE); for (final int id : im.getInputDeviceIds()) { final InputDevice inputDevice = im.getInputDevice(id); - if (inputDevice.supportsSource(InputDevice.SOURCE_BLUETOOTH_STYLUS) - || inputDevice.supportsSource(InputDevice.SOURCE_MOUSE) - || inputDevice.supportsSource(InputDevice.SOURCE_STYLUS) - || inputDevice.supportsSource(InputDevice.SOURCE_TOUCHPAD) - || inputDevice.supportsSource(InputDevice.SOURCE_TRACKBALL)) { + + if (BraveDeviceUtilsKt.supportsSource(inputDevice, InputDevice.SOURCE_BLUETOOTH_STYLUS) + || BraveDeviceUtilsKt.supportsSource(inputDevice, InputDevice.SOURCE_MOUSE) + || BraveDeviceUtilsKt.supportsSource(inputDevice, InputDevice.SOURCE_STYLUS) + || BraveDeviceUtilsKt.supportsSource(inputDevice, InputDevice.SOURCE_TOUCHPAD) + || BraveDeviceUtilsKt.supportsSource(inputDevice, + InputDevice.SOURCE_TRACKBALL)) { return true; } }