public LogDataFromSL(BugReportModule br, String chapterName, String id, String infoId) { super(br, null, chapterName, id, infoId); LogLines sl = (LogLines) br.getInfo(SystemLogPlugin.INFO_ID_SYSTEMLOG); Section mKernelLog = null; if (sl != null) { int cnt = sl.size(); for (int i = 0; i < cnt; i++) { LogLine l = sl.get(i); if (l.tag.equals("kernel")) { if (mKernelLog == null) { mKernelLog = new Section(br, Section.KERNEL_LOG_FROM_SYSTEM); br.addSection(mKernelLog); } String line = convertToKrnLogLevel(l.level) + l.msg; mKernelLog.addLine(line); addLine(br, line, l.ts); } } } }
public LogLine(BugReportModule br, String line, int format, LogLine prev) { super(line); level = 'D'; // Validate if (line.startsWith("---------")) return; switch (format) { case FMT_UNKNOWN: if (!parseFmtStd(br, line)) { if (!parseFmtBrat(br, line)) { if (!parseFmtCrash(br, line, prev)) { parseFmtShort(br, line, prev); } } } break; case FMT_STD: parseFmtStd(br, line); break; case FMT_BRAT: parseFmtBrat(br, line); break; case FMT_CRASH: parseFmtCrash(br, line, prev); break; case FMT_SHORT: parseFmtShort(br, line, prev); break; default: throw new RuntimeException("Invalid format: " + format); } if (pid > 0) { mPr = br.getProcessRecord(pid, true, true); } }
@Override public void generate(Module rep) { if (!mLoaded) return; BugReportModule br = (BugReportModule) rep; Chapter ch = br.findOrCreateChapter("Battery info/Kernel wakelocks"); addHelp(ch); long uptime = br.getUptime(); Table tg = new Table(Table.FLAG_SORT, ch); tg.setCSVOutput(rep, "kernel_wakelocks"); tg.setTableName(rep, "kernel_wakelocks"); tg.addColumn("Name", "The name of the wakelock as provided by the driver", 0, "name varchar"); tg.addColumn( "Count", "The number of times that the wakelock has been acquired.", Table.FLAG_ALIGN_RIGHT, "count int"); tg.addColumn( "Expire count", "The number of times that the wakelock has timed out. This indicates that some application has an input device open, but is not reading from it, which is a bug.", Table.FLAG_ALIGN_RIGHT, "expire_count int"); tg.addColumn( "Wake count", "The number of times that the wakelock was the first to be acquired in the resume path.", Table.FLAG_ALIGN_RIGHT, "wake_count int"); tg.addColumn( "Active since (ms)", "Tracks how long a wakelock has been held since it was last acquired, or zero if it is not currently held.", Table.FLAG_ALIGN_RIGHT, "active_since_ms int"); tg.addColumn( "Total time (ms)", "Accumulates the total amount of time that the corresponding wakelock has been held.", Table.FLAG_ALIGN_RIGHT, "total_time_ms int"); if (uptime > 0) { tg.addColumn( "Total time (%)", "Total time as percentage of uptime", Table.FLAG_ALIGN_RIGHT, "total_time_p int"); } tg.addColumn( "Average time (ms)", "Total time divided by Count.", Table.FLAG_ALIGN_RIGHT, "average_time_ms int"); tg.addColumn( "Sleep time (ms)", "The total time that the wakelock was held while the display was powered off.", Table.FLAG_ALIGN_RIGHT, "sleep_time_ms int"); tg.addColumn( "Max time (ms)", "The longest hold time for the wakelock. This allows finding cases where wakelocks are held for too long, but are eventually released. (In contrast, active_since is more useful in the held-forever case.)", Table.FLAG_ALIGN_RIGHT, "max_time_ms int"); tg.addColumn("Last change", "?", Table.FLAG_ALIGN_RIGHT, "last_change int"); tg.begin(); for (KernelWakelock lock : mLocks) { tg.addData(lock.name); tg.addData(lock.count); tg.addData(lock.expire_count); tg.addData(lock.wake_count); long activeSinceMs = lock.active_since / 1000000L; tg.addData(Util.formatTS(activeSinceMs), new ShadedValue(activeSinceMs)); long totalMs = lock.total_time / 1000000L; tg.addData(Util.formatTS(totalMs), new ShadedValue(totalMs)); if (uptime > 0) { tg.addData(lock.total_time / 10000000L / uptime); } long avgMs = (lock.count == 0) ? 0 : (lock.total_time / lock.count / 1000000L); tg.addData(Util.formatTS(avgMs), new ShadedValue(avgMs)); long sleepMs = lock.sleep_time / 1000000L; tg.addData(Util.formatTS(sleepMs), new ShadedValue(sleepMs)); long maxMs = lock.max_time / 1000000L; tg.addData(Util.formatTS(maxMs), new ShadedValue(maxMs)); tg.addData(lock.last_change); } tg.end(); }