Check that InputDevice isn't null and add annotations

The API 'getDevice' can return null. Let's make sure null isn't
dereferenced. Also, add nullability annotations to make it easier to
follow.

Bug: 227733127
Test: build only
Change-Id: Ice514f27d4347528d009969174f09078dfa2afac
This commit is contained in:
Siarhei Vishniakou
2022-04-01 13:38:21 -07:00
parent d0923a2197
commit 8970010a5e

View File

@@ -98,7 +98,7 @@ public class InputDeviceSensorManager implements InputManager.InputDeviceListene
*/
private void updateInputDeviceSensorInfoLocked(int deviceId) {
final InputDevice inputDevice = InputDevice.getDevice(deviceId);
if (inputDevice.hasSensor()) {
if (inputDevice != null && inputDevice.hasSensor()) {
final InputSensorInfo[] sensorInfos =
mInputManager.getSensorList(deviceId);
populateSensorsForInputDeviceLocked(deviceId, sensorInfos);