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

Commit 8177d7fa authored by Prabir Pradhan's avatar Prabir Pradhan
Browse files

Uinput command: allow duplicate configuration entries for a type

Make the uinput command more robust by allowing multiple configuration
entries for the same "type" by concatenating the "data".

With this change, the following configuration:

  "configuration": [
    {"type": 100, "data": [1, 3]}  // UI_SET_EVBIT : EV_KEY, EV_ABS
  ]

can also be written as:

  "configuration": [
    {"type": 100, "data": [1]},  // UI_SET_EVBIT : EV_KEY
    {"type": 100, "data": [3]}   // UI_SET_EVBIT : EV_ABS
  ]

Bug: 240493155
Test: atest TouchScreenTest
Change-Id: Id18d42ceba28ac68b02ef12525cd2384c948f9a8
parent ff3ab034
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.IntStream;

import src.com.android.commands.uinput.InputAbsInfo;

@@ -338,7 +339,7 @@ public class Event {
                mReader.beginArray();
                while (mReader.hasNext()) {
                    int type = 0;
                    int[] data = null;
                    IntStream data = null;
                    mReader.beginObject();
                    while (mReader.hasNext()) {
                        String name = mReader.nextName();
@@ -347,8 +348,7 @@ public class Event {
                                type = readInt();
                                break;
                            case "data":
                                data = readIntList().stream()
                                            .mapToInt(Integer::intValue).toArray();
                                data = readIntList().stream().mapToInt(Integer::intValue);
                                break;
                            default:
                                consumeRemainingElements();
@@ -359,7 +359,9 @@ public class Event {
                    }
                    mReader.endObject();
                    if (data != null) {
                        configuration.put(type, data);
                        final int[] existing = configuration.get(type);
                        configuration.put(type, existing == null ? data.toArray()
                                : IntStream.concat(IntStream.of(existing), data).toArray());
                    }
                }
                mReader.endArray();