@Test public void readData_alarm_info_start() throws IOException { Mockito.when(filereader.fileExist(traceFolder + Util.FILE_SEPARATOR + "alarm_info_end")).thenReturn(false); Mockito.when(filereader.fileExist(traceFolder + Util.FILE_SEPARATOR + "alarm_info_start")).thenReturn(true); String[] array_alarm_info_start = getMockedFileData(); Mockito.when(filereader.readAllLine(Mockito.anyString())).thenReturn(array_alarm_info_start); AlarmDumpsysTimestamp alarmDumpsysTimestamp = traceDataReader.readData(traceFolder, new Date((long) (1.412361675045E9 * 1000)), 0, "4.0.4", 65524.92); assertEquals(1.412361727E12, alarmDumpsysTimestamp.getDumpsysEpochTimestamp(), 0); assertEquals(6.5577447E7, alarmDumpsysTimestamp.getDumpsysElapsedTimestamp(), 0); }
@Override public AlarmDumpsysTimestamp readData(String directory , Date traceDateTime , double traceDuration , String osVersion , double eventTime0) { String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.ALARM_END_FILE; boolean useStartFile = false; double dumpsysEpochTimestamp = 0.0; double dumpsysElapsedTimestamp = 0.0; if (!filereader.fileExist(filepath)) { useStartFile = true; filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.ALARM_START_FILE; if (!filereader.fileExist(filepath)) { if (traceDateTime == null) { LOGGER.debug("traceDateTime is null"); } else { LOGGER.debug("traceDuration: " + traceDuration); dumpsysEpochTimestamp = traceDateTime.getTime() + traceDuration * 1000; dumpsysElapsedTimestamp = eventTime0 + traceDuration * 1000; } return null; } } dumpsysEpochTimestamp = 0; String[] lines = null; try { lines = filereader.readAllLine(filepath); } catch (IOException e1) { LOGGER.error("failed to open alarm dumpsys timestamp file: " + filepath); return null; } for (String strLineBuf : lines) { if (dumpsysEpochTimestamp <= 0 && strLineBuf.indexOf("Realtime wakeup") > 0) { String realTime[] = strLineBuf.split("="); if (osVersion != null && osVersion.compareTo("2.3") < 0) { dumpsysEpochTimestamp = Double.parseDouble(realTime[1].trim().substring(0, realTime[1].length() - 2)); } else { DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { dumpsysEpochTimestamp = format.parse(realTime[1].trim().substring(0, realTime[1].length() - 2)).getTime(); } catch (ParseException e) { LOGGER.warn("ParseException ", e); } } } if (strLineBuf.indexOf("Elapsed realtime wakeup") > 0) { String strFields[] = strLineBuf.split("="); if (osVersion != null && osVersion.compareTo("2.3") < 0) { dumpsysElapsedTimestamp = Double.parseDouble(strFields[1].trim().substring(0, strFields[1].length() - 2)); } else { dumpsysElapsedTimestamp = Util.convertTime(strFields[1].trim().substring(1, strFields[1].length() - 2)); } break; } } if (useStartFile) { dumpsysEpochTimestamp += traceDuration * 1000; dumpsysElapsedTimestamp += traceDuration * 1000; } if (osVersion != null) { LOGGER.info("Elapsed realtime : " + dumpsysElapsedTimestamp + "\n\tEPOCH: " + dumpsysEpochTimestamp + "\n\tOS: " + osVersion); } AlarmDumpsysTimestamp time = new AlarmDumpsysTimestamp(); time.setDumpsysElapsedTimestamp(dumpsysElapsedTimestamp); time.setDumpsysEpochTimestamp(dumpsysEpochTimestamp); return time; }
AlarmDumpsysTimestampReaderImpl extends PeripheralBase implements IAlarmDumpsysTimestampReader { @Override public AlarmDumpsysTimestamp readData(String directory , Date traceDateTime , double traceDuration , String osVersion , double eventTime0) { String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.ALARM_END_FILE; boolean useStartFile = false; double dumpsysEpochTimestamp = 0.0; double dumpsysElapsedTimestamp = 0.0; if (!filereader.fileExist(filepath)) { useStartFile = true; filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.ALARM_START_FILE; if (!filereader.fileExist(filepath)) { if (traceDateTime == null) { LOGGER.debug("traceDateTime is null"); } else { LOGGER.debug("traceDuration: " + traceDuration); dumpsysEpochTimestamp = traceDateTime.getTime() + traceDuration * 1000; dumpsysElapsedTimestamp = eventTime0 + traceDuration * 1000; } return null; } } dumpsysEpochTimestamp = 0; String[] lines = null; try { lines = filereader.readAllLine(filepath); } catch (IOException e1) { LOGGER.error("failed to open alarm dumpsys timestamp file: " + filepath); return null; } for (String strLineBuf : lines) { if (dumpsysEpochTimestamp <= 0 && strLineBuf.indexOf("Realtime wakeup") > 0) { String realTime[] = strLineBuf.split("="); if (osVersion != null && osVersion.compareTo("2.3") < 0) { dumpsysEpochTimestamp = Double.parseDouble(realTime[1].trim().substring(0, realTime[1].length() - 2)); } else { DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { dumpsysEpochTimestamp = format.parse(realTime[1].trim().substring(0, realTime[1].length() - 2)).getTime(); } catch (ParseException e) { LOGGER.warn("ParseException ", e); } } } if (strLineBuf.indexOf("Elapsed realtime wakeup") > 0) { String strFields[] = strLineBuf.split("="); if (osVersion != null && osVersion.compareTo("2.3") < 0) { dumpsysElapsedTimestamp = Double.parseDouble(strFields[1].trim().substring(0, strFields[1].length() - 2)); } else { dumpsysElapsedTimestamp = Util.convertTime(strFields[1].trim().substring(1, strFields[1].length() - 2)); } break; } } if (useStartFile) { dumpsysEpochTimestamp += traceDuration * 1000; dumpsysElapsedTimestamp += traceDuration * 1000; } if (osVersion != null) { LOGGER.info("Elapsed realtime : " + dumpsysElapsedTimestamp + "\n\tEPOCH: " + dumpsysEpochTimestamp + "\n\tOS: " + osVersion); } AlarmDumpsysTimestamp time = new AlarmDumpsysTimestamp(); time.setDumpsysElapsedTimestamp(dumpsysElapsedTimestamp); time.setDumpsysEpochTimestamp(dumpsysEpochTimestamp); return time; } }
AlarmDumpsysTimestampReaderImpl extends PeripheralBase implements IAlarmDumpsysTimestampReader { @Override public AlarmDumpsysTimestamp readData(String directory , Date traceDateTime , double traceDuration , String osVersion , double eventTime0) { String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.ALARM_END_FILE; boolean useStartFile = false; double dumpsysEpochTimestamp = 0.0; double dumpsysElapsedTimestamp = 0.0; if (!filereader.fileExist(filepath)) { useStartFile = true; filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.ALARM_START_FILE; if (!filereader.fileExist(filepath)) { if (traceDateTime == null) { LOGGER.debug("traceDateTime is null"); } else { LOGGER.debug("traceDuration: " + traceDuration); dumpsysEpochTimestamp = traceDateTime.getTime() + traceDuration * 1000; dumpsysElapsedTimestamp = eventTime0 + traceDuration * 1000; } return null; } } dumpsysEpochTimestamp = 0; String[] lines = null; try { lines = filereader.readAllLine(filepath); } catch (IOException e1) { LOGGER.error("failed to open alarm dumpsys timestamp file: " + filepath); return null; } for (String strLineBuf : lines) { if (dumpsysEpochTimestamp <= 0 && strLineBuf.indexOf("Realtime wakeup") > 0) { String realTime[] = strLineBuf.split("="); if (osVersion != null && osVersion.compareTo("2.3") < 0) { dumpsysEpochTimestamp = Double.parseDouble(realTime[1].trim().substring(0, realTime[1].length() - 2)); } else { DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { dumpsysEpochTimestamp = format.parse(realTime[1].trim().substring(0, realTime[1].length() - 2)).getTime(); } catch (ParseException e) { LOGGER.warn("ParseException ", e); } } } if (strLineBuf.indexOf("Elapsed realtime wakeup") > 0) { String strFields[] = strLineBuf.split("="); if (osVersion != null && osVersion.compareTo("2.3") < 0) { dumpsysElapsedTimestamp = Double.parseDouble(strFields[1].trim().substring(0, strFields[1].length() - 2)); } else { dumpsysElapsedTimestamp = Util.convertTime(strFields[1].trim().substring(1, strFields[1].length() - 2)); } break; } } if (useStartFile) { dumpsysEpochTimestamp += traceDuration * 1000; dumpsysElapsedTimestamp += traceDuration * 1000; } if (osVersion != null) { LOGGER.info("Elapsed realtime : " + dumpsysElapsedTimestamp + "\n\tEPOCH: " + dumpsysEpochTimestamp + "\n\tOS: " + osVersion); } AlarmDumpsysTimestamp time = new AlarmDumpsysTimestamp(); time.setDumpsysElapsedTimestamp(dumpsysElapsedTimestamp); time.setDumpsysEpochTimestamp(dumpsysEpochTimestamp); return time; }  }
AlarmDumpsysTimestampReaderImpl extends PeripheralBase implements IAlarmDumpsysTimestampReader { @Override public AlarmDumpsysTimestamp readData(String directory , Date traceDateTime , double traceDuration , String osVersion , double eventTime0) { String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.ALARM_END_FILE; boolean useStartFile = false; double dumpsysEpochTimestamp = 0.0; double dumpsysElapsedTimestamp = 0.0; if (!filereader.fileExist(filepath)) { useStartFile = true; filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.ALARM_START_FILE; if (!filereader.fileExist(filepath)) { if (traceDateTime == null) { LOGGER.debug("traceDateTime is null"); } else { LOGGER.debug("traceDuration: " + traceDuration); dumpsysEpochTimestamp = traceDateTime.getTime() + traceDuration * 1000; dumpsysElapsedTimestamp = eventTime0 + traceDuration * 1000; } return null; } } dumpsysEpochTimestamp = 0; String[] lines = null; try { lines = filereader.readAllLine(filepath); } catch (IOException e1) { LOGGER.error("failed to open alarm dumpsys timestamp file: " + filepath); return null; } for (String strLineBuf : lines) { if (dumpsysEpochTimestamp <= 0 && strLineBuf.indexOf("Realtime wakeup") > 0) { String realTime[] = strLineBuf.split("="); if (osVersion != null && osVersion.compareTo("2.3") < 0) { dumpsysEpochTimestamp = Double.parseDouble(realTime[1].trim().substring(0, realTime[1].length() - 2)); } else { DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { dumpsysEpochTimestamp = format.parse(realTime[1].trim().substring(0, realTime[1].length() - 2)).getTime(); } catch (ParseException e) { LOGGER.warn("ParseException ", e); } } } if (strLineBuf.indexOf("Elapsed realtime wakeup") > 0) { String strFields[] = strLineBuf.split("="); if (osVersion != null && osVersion.compareTo("2.3") < 0) { dumpsysElapsedTimestamp = Double.parseDouble(strFields[1].trim().substring(0, strFields[1].length() - 2)); } else { dumpsysElapsedTimestamp = Util.convertTime(strFields[1].trim().substring(1, strFields[1].length() - 2)); } break; } } if (useStartFile) { dumpsysEpochTimestamp += traceDuration * 1000; dumpsysElapsedTimestamp += traceDuration * 1000; } if (osVersion != null) { LOGGER.info("Elapsed realtime : " + dumpsysElapsedTimestamp + "\n\tEPOCH: " + dumpsysEpochTimestamp + "\n\tOS: " + osVersion); } AlarmDumpsysTimestamp time = new AlarmDumpsysTimestamp(); time.setDumpsysElapsedTimestamp(dumpsysElapsedTimestamp); time.setDumpsysEpochTimestamp(dumpsysEpochTimestamp); return time; }  @Override AlarmDumpsysTimestamp readData(String directory
										, Date traceDateTime
										, double traceDuration
										, String osVersion
										, double eventTime0); }
AlarmDumpsysTimestampReaderImpl extends PeripheralBase implements IAlarmDumpsysTimestampReader { @Override public AlarmDumpsysTimestamp readData(String directory , Date traceDateTime , double traceDuration , String osVersion , double eventTime0) { String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.ALARM_END_FILE; boolean useStartFile = false; double dumpsysEpochTimestamp = 0.0; double dumpsysElapsedTimestamp = 0.0; if (!filereader.fileExist(filepath)) { useStartFile = true; filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.ALARM_START_FILE; if (!filereader.fileExist(filepath)) { if (traceDateTime == null) { LOGGER.debug("traceDateTime is null"); } else { LOGGER.debug("traceDuration: " + traceDuration); dumpsysEpochTimestamp = traceDateTime.getTime() + traceDuration * 1000; dumpsysElapsedTimestamp = eventTime0 + traceDuration * 1000; } return null; } } dumpsysEpochTimestamp = 0; String[] lines = null; try { lines = filereader.readAllLine(filepath); } catch (IOException e1) { LOGGER.error("failed to open alarm dumpsys timestamp file: " + filepath); return null; } for (String strLineBuf : lines) { if (dumpsysEpochTimestamp <= 0 && strLineBuf.indexOf("Realtime wakeup") > 0) { String realTime[] = strLineBuf.split("="); if (osVersion != null && osVersion.compareTo("2.3") < 0) { dumpsysEpochTimestamp = Double.parseDouble(realTime[1].trim().substring(0, realTime[1].length() - 2)); } else { DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); try { dumpsysEpochTimestamp = format.parse(realTime[1].trim().substring(0, realTime[1].length() - 2)).getTime(); } catch (ParseException e) { LOGGER.warn("ParseException ", e); } } } if (strLineBuf.indexOf("Elapsed realtime wakeup") > 0) { String strFields[] = strLineBuf.split("="); if (osVersion != null && osVersion.compareTo("2.3") < 0) { dumpsysElapsedTimestamp = Double.parseDouble(strFields[1].trim().substring(0, strFields[1].length() - 2)); } else { dumpsysElapsedTimestamp = Util.convertTime(strFields[1].trim().substring(1, strFields[1].length() - 2)); } break; } } if (useStartFile) { dumpsysEpochTimestamp += traceDuration * 1000; dumpsysElapsedTimestamp += traceDuration * 1000; } if (osVersion != null) { LOGGER.info("Elapsed realtime : " + dumpsysElapsedTimestamp + "\n\tEPOCH: " + dumpsysEpochTimestamp + "\n\tOS: " + osVersion); } AlarmDumpsysTimestamp time = new AlarmDumpsysTimestamp(); time.setDumpsysElapsedTimestamp(dumpsysElapsedTimestamp); time.setDumpsysEpochTimestamp(dumpsysEpochTimestamp); return time; }  @Override AlarmDumpsysTimestamp readData(String directory
										, Date traceDateTime
										, double traceDuration
										, String osVersion
										, double eventTime0);  }