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

Commit 1089b5c

Browse files
Check for a null pressure range for motion events (#7986)
Fixes flutter/flutter#28490
1 parent b7d5129 commit 1089b5c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

shell/platform/android/io/flutter/view/FlutterView.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,14 +456,16 @@ private void addPointerForIndex(MotionEvent event, int pointerIndex, int pointer
456456
packet.putLong(0); // obscured
457457

458458
packet.putDouble(event.getPressure(pointerIndex)); // pressure
459+
double pressureMin = 0.0, pressureMax = 1.0;
459460
if (event.getDevice() != null) {
460461
InputDevice.MotionRange pressureRange = event.getDevice().getMotionRange(MotionEvent.AXIS_PRESSURE);
461-
packet.putDouble(pressureRange.getMin()); // pressure_min
462-
packet.putDouble(pressureRange.getMax()); // pressure_max
463-
} else {
464-
packet.putDouble(0.0); // pressure_min
465-
packet.putDouble(1.0); // pressure_max
462+
if (pressureRange != null) {
463+
pressureMin = pressureRange.getMin();
464+
pressureMax = pressureRange.getMax();
465+
}
466466
}
467+
packet.putDouble(pressureMin); // pressure_min
468+
packet.putDouble(pressureMax); // pressure_max
467469

468470
if (pointerKind == kPointerDeviceKindStylus) {
469471
packet.putDouble(event.getAxisValue(MotionEvent.AXIS_DISTANCE, pointerIndex)); // distance

0 commit comments

Comments
 (0)