Skip to content

Commit

Permalink
fix(TouchInputHandler.java): fix NullPointerException while obtaining…
Browse files Browse the repository at this point in the history
… device name
  • Loading branch information
twaik committed Nov 27, 2024
1 parent a0543e1 commit 21213c1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/src/main/java/com/termux/x11/input/TouchInputHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ private TouchInputHandler(MainActivity activity, RenderData renderData,
/** @noinspection DataFlowIssue*/
@Override
public void onInputDeviceAdded(int deviceId) {
android.util.Log.d("InputDeviceListener", "added " + InputDevice.getDevice(deviceId).getName());
InputDevice dev = InputDevice.getDevice(deviceId);
String name = dev != null ? dev.getName() : "null";
android.util.Log.d("InputDeviceListener", "added " + name);
refreshInputDevices();
}

Expand All @@ -224,7 +226,9 @@ public void onInputDeviceRemoved(int deviceId) {
/** @noinspection DataFlowIssue*/
@Override
public void onInputDeviceChanged(int deviceId) {
android.util.Log.d("InputDeviceListener", "changed " + InputDevice.getDevice(deviceId).getName());
InputDevice dev = InputDevice.getDevice(deviceId);
String name = dev != null ? dev.getName() : "null";
android.util.Log.d("InputDeviceListener", "changed " + name);
refreshInputDevices();
}
}, null);
Expand Down

0 comments on commit 21213c1

Please sign in to comment.