mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-08 03:31:29 +03:00
fix: android 7.1, input, crash (#12129)
Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -70,7 +70,7 @@ class InputService : AccessibilityService() {
|
|||||||
|
|
||||||
private val logTag = "input service"
|
private val logTag = "input service"
|
||||||
private var leftIsDown = false
|
private var leftIsDown = false
|
||||||
private val touchPath = Path()
|
private var touchPath = Path()
|
||||||
private var stroke: GestureDescription.StrokeDescription? = null
|
private var stroke: GestureDescription.StrokeDescription? = null
|
||||||
private var lastTouchGestureStartTime = 0L
|
private var lastTouchGestureStartTime = 0L
|
||||||
private var mouseX = 0
|
private var mouseX = 0
|
||||||
@@ -278,7 +278,11 @@ class InputService : AccessibilityService() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun startGesture(x: Int, y: Int) {
|
private fun startGesture(x: Int, y: Int) {
|
||||||
touchPath.reset()
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
touchPath.reset()
|
||||||
|
} else {
|
||||||
|
touchPath = Path()
|
||||||
|
}
|
||||||
touchPath.moveTo(x.toFloat(), y.toFloat())
|
touchPath.moveTo(x.toFloat(), y.toFloat())
|
||||||
lastTouchGestureStartTime = System.currentTimeMillis()
|
lastTouchGestureStartTime = System.currentTimeMillis()
|
||||||
lastX = x
|
lastX = x
|
||||||
@@ -333,19 +337,49 @@ class InputService : AccessibilityService() {
|
|||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.N)
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
private fun continueGesture(x: Int, y: Int) {
|
private fun continueGesture(x: Int, y: Int) {
|
||||||
doDispatchGesture(x, y, true)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
touchPath.reset()
|
doDispatchGesture(x, y, true)
|
||||||
touchPath.moveTo(x.toFloat(), y.toFloat())
|
touchPath.reset()
|
||||||
lastTouchGestureStartTime = System.currentTimeMillis()
|
touchPath.moveTo(x.toFloat(), y.toFloat())
|
||||||
lastX = x
|
lastTouchGestureStartTime = System.currentTimeMillis()
|
||||||
lastY = y
|
lastX = x
|
||||||
|
lastY = y
|
||||||
|
} else {
|
||||||
|
touchPath.lineTo(x.toFloat(), y.toFloat())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
|
private fun endGestureBelowO(x: Int, y: Int) {
|
||||||
|
try {
|
||||||
|
touchPath.lineTo(x.toFloat(), y.toFloat())
|
||||||
|
var duration = System.currentTimeMillis() - lastTouchGestureStartTime
|
||||||
|
if (duration <= 0) {
|
||||||
|
duration = 1
|
||||||
|
}
|
||||||
|
val stroke = GestureDescription.StrokeDescription(
|
||||||
|
touchPath,
|
||||||
|
0,
|
||||||
|
duration
|
||||||
|
)
|
||||||
|
val builder = GestureDescription.Builder()
|
||||||
|
builder.addStroke(stroke)
|
||||||
|
Log.d(logTag, "end gesture x:$x y:$y time:$duration")
|
||||||
|
dispatchGesture(builder.build(), null, null)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e(logTag, "endGesture error:$e")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.N)
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
private fun endGesture(x: Int, y: Int) {
|
private fun endGesture(x: Int, y: Int) {
|
||||||
doDispatchGesture(x, y, false)
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
touchPath.reset()
|
doDispatchGesture(x, y, false)
|
||||||
stroke = null
|
touchPath.reset()
|
||||||
|
stroke = null
|
||||||
|
} else {
|
||||||
|
endGestureBelowO(x, y)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.N)
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ class MainActivity : FlutterActivity() {
|
|||||||
codecObject.put("mime_type", mime_type)
|
codecObject.put("mime_type", mime_type)
|
||||||
val caps = codec.getCapabilitiesForType(mime_type)
|
val caps = codec.getCapabilitiesForType(mime_type)
|
||||||
if (codec.isEncoder) {
|
if (codec.isEncoder) {
|
||||||
// Encoder‘s max_height and max_width are interchangeable
|
// Encoder's max_height and max_width are interchangeable
|
||||||
if (!caps.videoCapabilities.isSizeSupported(w,h) && !caps.videoCapabilities.isSizeSupported(h,w)) {
|
if (!caps.videoCapabilities.isSizeSupported(w,h) && !caps.videoCapabilities.isSizeSupported(h,w)) {
|
||||||
return@forEach
|
return@forEach
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user