From c2282c011f3ddb478f8cdb04186b094043b0eb67 Mon Sep 17 00:00:00 2001 From: Vaibhav Devmurari Date: Mon, 24 Mar 2025 08:28:55 -0700 Subject: Fix NPE in TouchpadDebugViewController Test: manual Bug: 405820713 Flag: EXEMPT bugfix (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:3556310b7917f0ed940cdc0643b38d893d5060b0) Merged-In: I4dc7de5fcc05fe20cc17c1540bbef2b1d78c6465 Change-Id: I4dc7de5fcc05fe20cc17c1540bbef2b1d78c6465 --- .../server/input/debug/TouchpadDebugViewController.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'services') diff --git a/services/core/java/com/android/server/input/debug/TouchpadDebugViewController.java b/services/core/java/com/android/server/input/debug/TouchpadDebugViewController.java index 9cfbfa649e1c..e36bcd8858df 100644 --- a/services/core/java/com/android/server/input/debug/TouchpadDebugViewController.java +++ b/services/core/java/com/android/server/input/debug/TouchpadDebugViewController.java @@ -55,15 +55,17 @@ public class TouchpadDebugViewController implements InputManager.InputDeviceList @Override public void onInputDeviceAdded(int deviceId) { + if (!mTouchpadVisualizerEnabled) { + return; + } final InputManager inputManager = Objects.requireNonNull( mContext.getSystemService(InputManager.class)); InputDevice inputDevice = inputManager.getInputDevice(deviceId); - - if (Objects.requireNonNull(inputDevice).supportsSource( - InputDevice.SOURCE_TOUCHPAD | InputDevice.SOURCE_MOUSE) - && mTouchpadVisualizerEnabled) { - showDebugView(deviceId); + if (inputDevice == null || !inputDevice.supportsSource( + InputDevice.SOURCE_TOUCHPAD | InputDevice.SOURCE_MOUSE)) { + return; } + showDebugView(deviceId); } @Override -- cgit v1.2.3-59-g8ed1b