Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Check for a null pressure range for motion events #7986

Merged
merged 1 commit into from
Feb 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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