Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e28db5f1 authored by Harry Cutts's avatar Harry Cutts
Browse files

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
parent 70bb706e
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -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) {