Skip to content

Commit

Permalink
Check for a null pressure range for motion events (flutter#7986)
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-simmons authored Feb 27, 2019
1 parent b7d5129 commit 1089b5c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions shell/platform/android/io/flutter/view/FlutterView.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,14 +456,16 @@ private void addPointerForIndex(MotionEvent event, int pointerIndex, int pointer
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
Expand Down

0 comments on commit 1089b5c

Please sign in to comment.