Merge "Guard against null input device in StylusDeviceUpdater" into udc-dev am: e78b1f377e am: e686a77ec9

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/22894945

Change-Id: Ia3ead3945813be4aca3e91e83f853fa35138c800
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Vania Januar
2023-05-03 10:13:59 +00:00
committed by Automerger Merge Worker
2 changed files with 27 additions and 1 deletions

View File

@@ -100,6 +100,8 @@ public class StylusDeviceUpdater implements InputManager.InputDeviceListener,
@Override
public void onInputDeviceAdded(int deviceId) {
InputDevice inputDevice = mInputManager.getInputDevice(deviceId);
if (inputDevice == null) return;
if (inputDevice.supportsSource(InputDevice.SOURCE_STYLUS)
&& !inputDevice.isExternal()) {
try {
@@ -121,7 +123,10 @@ public class StylusDeviceUpdater implements InputManager.InputDeviceListener,
@Override
public void onInputDeviceChanged(int deviceId) {
if (mInputManager.getInputDevice(deviceId).supportsSource(InputDevice.SOURCE_STYLUS)) {
InputDevice inputDevice = mInputManager.getInputDevice(deviceId);
if (inputDevice == null) return;
if (inputDevice.supportsSource(InputDevice.SOURCE_STYLUS)) {
forceUpdate();
}
}
@@ -189,6 +194,8 @@ public class StylusDeviceUpdater implements InputManager.InputDeviceListener,
boolean hasConnectedBluetoothStylusDevice() {
for (int deviceId : mInputManager.getInputDeviceIds()) {
InputDevice device = mInputManager.getInputDevice(deviceId);
if (device == null) continue;
if (device.supportsSource(InputDevice.SOURCE_STYLUS)
&& mInputManager.getInputDeviceBluetoothAddress(deviceId) != null) {
return true;