Loading cmds/uinput/src/com/android/commands/uinput/EvemuParser.java +9 −5 Original line number Diff line number Diff line Loading @@ -61,17 +61,18 @@ public class EvemuParser implements EventParser { mReader = in; } private @Nullable String findNextLine() throws IOException { private void findNextLine() throws IOException { String line = ""; while (line != null && line.length() == 0) { String unstrippedLine = mReader.readLine(); if (unstrippedLine == null) { mAtEndOfFile = true; return null; mNextLine = null; return; } line = stripComments(unstrippedLine); } return line; mNextLine = line; } private static String stripComments(String line) { Loading @@ -92,7 +93,7 @@ public class EvemuParser implements EventParser { */ public @Nullable String peekLine() throws IOException { if (mNextLine == null && !mAtEndOfFile) { mNextLine = findNextLine(); findNextLine(); } return mNextLine; } Loading @@ -103,7 +104,10 @@ public class EvemuParser implements EventParser { mNextLine = null; } public boolean isAtEndOfFile() { public boolean isAtEndOfFile() throws IOException { if (mNextLine == null && !mAtEndOfFile) { findNextLine(); } return mAtEndOfFile; } Loading cmds/uinput/tests/src/com/android/commands/uinput/tests/EvemuParserTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -216,6 +216,9 @@ public class EvemuParserTest { assertInjectEvent(parser.getNextEvent(), 0x2, 0x0, 1, -1); assertInjectEvent(parser.getNextEvent(), 0x2, 0x1, -2); assertInjectEvent(parser.getNextEvent(), 0x0, 0x0, 0); // Now we should be at the end of the file. assertThat(parser.getNextEvent()).isNull(); } @Test Loading Loading @@ -246,6 +249,8 @@ public class EvemuParserTest { assertInjectEvent(parser.getNextEvent(), 0x1, 0x15, 1, 1_000_000); assertInjectEvent(parser.getNextEvent(), 0x0, 0x0, 0); assertThat(parser.getNextEvent()).isNull(); } @Test Loading Loading
cmds/uinput/src/com/android/commands/uinput/EvemuParser.java +9 −5 Original line number Diff line number Diff line Loading @@ -61,17 +61,18 @@ public class EvemuParser implements EventParser { mReader = in; } private @Nullable String findNextLine() throws IOException { private void findNextLine() throws IOException { String line = ""; while (line != null && line.length() == 0) { String unstrippedLine = mReader.readLine(); if (unstrippedLine == null) { mAtEndOfFile = true; return null; mNextLine = null; return; } line = stripComments(unstrippedLine); } return line; mNextLine = line; } private static String stripComments(String line) { Loading @@ -92,7 +93,7 @@ public class EvemuParser implements EventParser { */ public @Nullable String peekLine() throws IOException { if (mNextLine == null && !mAtEndOfFile) { mNextLine = findNextLine(); findNextLine(); } return mNextLine; } Loading @@ -103,7 +104,10 @@ public class EvemuParser implements EventParser { mNextLine = null; } public boolean isAtEndOfFile() { public boolean isAtEndOfFile() throws IOException { if (mNextLine == null && !mAtEndOfFile) { findNextLine(); } return mAtEndOfFile; } Loading
cmds/uinput/tests/src/com/android/commands/uinput/tests/EvemuParserTest.java +5 −0 Original line number Diff line number Diff line Loading @@ -216,6 +216,9 @@ public class EvemuParserTest { assertInjectEvent(parser.getNextEvent(), 0x2, 0x0, 1, -1); assertInjectEvent(parser.getNextEvent(), 0x2, 0x1, -2); assertInjectEvent(parser.getNextEvent(), 0x0, 0x0, 0); // Now we should be at the end of the file. assertThat(parser.getNextEvent()).isNull(); } @Test Loading Loading @@ -246,6 +249,8 @@ public class EvemuParserTest { assertInjectEvent(parser.getNextEvent(), 0x1, 0x15, 1, 1_000_000); assertInjectEvent(parser.getNextEvent(), 0x0, 0x0, 0); assertThat(parser.getNextEvent()).isNull(); } @Test Loading