summaryrefslogtreecommitdiff
path: root/cmds
diff options
context:
space:
mode:
authorHarry Cutts <hcutts@google.com>2023-11-14 15:54:21 +0000
committerHarry Cutts <hcutts@google.com>2023-11-16 15:25:34 +0000
commite28db5f173d12eea51ee72242a656fb1b08aa285 (patch)
tree30b817c23e4aa8ecb3a83ee1dc393e5afc6256fe /cmds
parent70bb706e1c70ed45aebef5d0e8288399e3eca9b3 (diff)
downloadbase-e28db5f173d12eea51ee72242a656fb1b08aa285.tar.gz
uinput: crash if device creation fails
Previously the tool just carried on, with event injections being silently dropped, which isn't very obvious behaviour. Bug: 302297266 Test: cause device creation to fail somehow, check the tool exits Change-Id: I94e931729339bff0f6fc7ab5b591f062043a1d7a
Diffstat (limited to 'cmds')
-rw-r--r--cmds/uinput/src/com/android/commands/uinput/Device.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/cmds/uinput/src/com/android/commands/uinput/Device.java b/cmds/uinput/src/com/android/commands/uinput/Device.java
index ad5e70f4ff0c..b0fa34c68092 100644
--- a/cmds/uinput/src/com/android/commands/uinput/Device.java
+++ b/cmds/uinput/src/com/android/commands/uinput/Device.java
@@ -160,9 +160,16 @@ public class Device {
switch (msg.what) {
case MSG_OPEN_UINPUT_DEVICE:
SomeArgs args = (SomeArgs) msg.obj;
- mPtr = nativeOpenUinputDevice((String) args.arg1, args.argi1, args.argi2,
+ String name = (String) args.arg1;
+ mPtr = nativeOpenUinputDevice(name, args.argi1, args.argi2,
args.argi3, args.argi4, args.argi5, (String) args.arg2,
new DeviceCallback());
+ if (mPtr == 0) {
+ RuntimeException ex = new RuntimeException(
+ "Could not create uinput device \"" + name + "\"");
+ Log.e(TAG, "Couldn't create uinput device, exiting.", ex);
+ throw ex;
+ }
break;
case MSG_INJECT_EVENT:
if (mPtr != 0) {