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

Commit 766ff01f authored by Harry Cutts's avatar Harry Cutts
Browse files

uinput: pass Commands to Event.Builder.setCommand

Parsing strings into enum values should be done by the parser, not the
builder, and this means that the evemu parser will be able to pass
properly typed values to setCommand rather than "magic" strings.

Bug: 302297266
Test: m uinput
Change-Id: Icac5764a66025412c87c326280d1895f3da78cac
parent 70bb706e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import src.com.android.commands.uinput.InputAbsInfo;
public class Event {
    private static final String TAG = "UinputEvent";

    enum Command {
    public enum Command {
        REGISTER,
        DELAY,
        INJECT,
@@ -188,8 +188,8 @@ public class Event {
            mEvent.mId = id;
        }

        public void setCommand(String command) {
            mEvent.mCommand = Command.valueOf(command.toUpperCase());
        public void setCommand(Command command) {
            mEvent.mCommand = command;
        }

        public void setName(String name) {
+2 −1
Original line number Diff line number Diff line
@@ -57,7 +57,8 @@ public class JsonStyleParser {
                    String name = mReader.nextName();
                    switch (name) {
                        case "id" -> eb.setId(readInt());
                        case "command" -> eb.setCommand(mReader.nextString());
                        case "command" -> eb.setCommand(
                                Event.Command.valueOf(mReader.nextString().toUpperCase()));
                        case "name" -> eb.setName(mReader.nextString());
                        case "vid" -> eb.setVid(readInt());
                        case "pid" -> eb.setPid(readInt());