Merge "Guard against null input device in StylusDeviceUpdater" into udc-dev
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user