use of com.att.aro.core.peripheral.pojo.UserEvent.UserEventType in project VideoOptimzer by attdevsupport.
the class UserEventReaderImpl method readUserInputFile.
private List<UserEvent> readUserInputFile(Map<UserEventType, Double> lastEvent, String filepath, double startTime, double eventTime0) {
List<UserEvent> userEventsList = new ArrayList<UserEvent>();
String[] lines = null;
try {
lines = filereader.readAllLine(filepath);
} catch (IOException e) {
LOGGER.error("failed to read user event file: " + filepath);
}
if (lines != null && lines.length > 0) {
for (String lineBuf : lines) {
// Ignore empty line
if (lineBuf.trim().isEmpty()) {
continue;
}
// Parse entry
String[] strFields = lineBuf.split(" ");
// Get timestamp
double dTimeStamp = Double.parseDouble(strFields[0]);
if (dTimeStamp > 1.0e9) {
dTimeStamp = Util.normalizeTime(dTimeStamp, startTime);
} else {
// Old data collector method (backward compatible)
dTimeStamp -= eventTime0;
}
// Get event type
UserEvent.UserEventType actionType = UserEvent.UserEventType.EVENT_UNKNOWN;
String processedEvent;
if (strFields.length == 3 && TraceDataConst.UserEvent.SCREEN.equals(strFields[1])) {
processedEvent = strFields[2];
actionType = UserEventType.SCREEN_TOUCH;
} else if (strFields.length == 4 && TraceDataConst.UserEvent.KEY.equals(strFields[1])) {
processedEvent = strFields[3];
if (TraceDataConst.UserEvent.KEY_KEY.equals(strFields[2])) {
actionType = UserEventType.KEY_KEY;
} else if (TraceDataConst.UserEvent.KEY_POWER.equals(strFields[2])) {
actionType = UserEventType.KEY_POWER;
} else if (TraceDataConst.UserEvent.KEY_VOLUP.equals(strFields[2])) {
actionType = UserEventType.KEY_VOLUP;
} else if (TraceDataConst.UserEvent.KEY_VOLDOWN.equals(strFields[2])) {
actionType = UserEventType.KEY_VOLDOWN;
} else if (TraceDataConst.UserEvent.KEY_BALL.equals(strFields[2])) {
actionType = UserEventType.KEY_BALL;
} else if (TraceDataConst.UserEvent.KEY_HOME.equals(strFields[2])) {
actionType = UserEventType.KEY_HOME;
} else if (TraceDataConst.UserEvent.KEY_MENU.equals(strFields[2])) {
actionType = UserEventType.KEY_MENU;
} else if (TraceDataConst.UserEvent.KEY_BACK.equals(strFields[2])) {
actionType = UserEventType.KEY_BACK;
} else if (TraceDataConst.UserEvent.KEY_SEARCH.equals(strFields[2])) {
actionType = UserEventType.KEY_SEARCH;
} else if (TraceDataConst.UserEvent.KEY_GREEN.equals(strFields[2])) {
actionType = UserEventType.KEY_GREEN;
} else if (TraceDataConst.UserEvent.KEY_RED.equals(strFields[2])) {
actionType = UserEventType.KEY_RED;
}
} else {
LOGGER.warn("Invalid user event type in trace: " + lineBuf);
continue;
}
// Get press or release
boolean bPress = false;
if (TraceDataConst.UserEvent.PRESS.equalsIgnoreCase(processedEvent)) {
bPress = true;
} else if (TraceDataConst.UserEvent.RELEASE.equalsIgnoreCase(processedEvent)) {
bPress = false;
} else {
LOGGER.warn("211 - Key event does not have press/release indication: " + lineBuf);
continue;
}
if (bPress) {
lastEvent.put(actionType, dTimeStamp);
} else {
Double lastTime = lastEvent.remove(actionType);
if (lastTime != null) {
userEventsList.add(new UserEvent(actionType, lastTime, dTimeStamp));
} else {
LOGGER.warn("Found key release event with no associated press event: " + lineBuf);
continue;
}
}
}
}
return userEventsList;
}
Aggregations