未验证 提交 1089b5c9 编写于 作者: J Jason Simmons 提交者: GitHub

Check for a null pressure range for motion events (#7986)

Fixes https://github.com/flutter/flutter/issues/28490
上级 b7d51294
......@@ -456,14 +456,16 @@ public class FlutterView extends SurfaceView
packet.putLong(0); // obscured
packet.putDouble(event.getPressure(pointerIndex)); // pressure
double pressureMin = 0.0, pressureMax = 1.0;
if (event.getDevice() != null) {
InputDevice.MotionRange pressureRange = event.getDevice().getMotionRange(MotionEvent.AXIS_PRESSURE);
packet.putDouble(pressureRange.getMin()); // pressure_min
packet.putDouble(pressureRange.getMax()); // pressure_max
} else {
packet.putDouble(0.0); // pressure_min
packet.putDouble(1.0); // pressure_max
if (pressureRange != null) {
pressureMin = pressureRange.getMin();
pressureMax = pressureRange.getMax();
}
}
packet.putDouble(pressureMin); // pressure_min
packet.putDouble(pressureMax); // pressure_max
if (pointerKind == kPointerDeviceKindStylus) {
packet.putDouble(event.getAxisValue(MotionEvent.AXIS_DISTANCE, pointerIndex)); // distance
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册