BraveNewPipeLegacy: (Kitkat) fix missing supportsSource() method in DeviceUtils

This commit is contained in:
evermind 2024-03-01 22:39:40 +01:00
parent 228c1d3681
commit ff9a10d4e3
2 changed files with 19 additions and 5 deletions

View file

@ -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)
}
}

View file

@ -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;
}
}