From 3a709976b247219eafd7078e2b5b45b50c28ec11 Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Mon, 11 Feb 2019 09:29:07 -0800 Subject: [PATCH] Provide a default pressure range if a MotionEvent does not have a device (flutter/engine#7737) Fixes https://github.com/flutter/flutter/issues/27641 --- .../platform/android/io/flutter/view/FlutterView.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java b/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java index 49c2c8d6d6..04abba458a 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/view/FlutterView.java @@ -472,10 +472,15 @@ public class FlutterView extends SurfaceView packet.putLong(0); // obscured - InputDevice.MotionRange pressureRange = event.getDevice().getMotionRange(MotionEvent.AXIS_PRESSURE); packet.putDouble(event.getPressure(pointerIndex)); // pressure - packet.putDouble(pressureRange.getMin()); // pressure_min - packet.putDouble(pressureRange.getMax()); // pressure_max + 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 (pointerKind == kPointerDeviceKindStylus) { packet.putDouble(event.getAxisValue(MotionEvent.AXIS_DISTANCE, pointerIndex)); // distance