Loading core/java/android/os/RecoverySystem.java +29 −13 Original line number Original line Diff line number Diff line Loading @@ -687,12 +687,13 @@ public class RecoverySystem { } } } } // Read last_install; then report time for update and I/O to tron. // Read last_install; then report time (in seconds) and I/O (in MiB) for // this update to tron. // Only report on the reboots immediately after an OTA update. // Only report on the reboots immediately after an OTA update. private static void parseLastInstallLog(Context context) { private static void parseLastInstallLog(Context context) { try (BufferedReader in = new BufferedReader(new FileReader(LAST_INSTALL_FILE))) { try (BufferedReader in = new BufferedReader(new FileReader(LAST_INSTALL_FILE))) { String line = null; String line = null; int bytesWritten = -1, bytesStashed = -1; int bytesWrittenInMiB = -1, bytesStashedInMiB = -1; int timeTotal = -1; int timeTotal = -1; while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) { // Here is an example of lines in last_install: // Here is an example of lines in last_install: Loading @@ -705,20 +706,35 @@ public class RecoverySystem { continue; continue; } } String numString = line.substring(numIndex + 1).trim(); String numString = line.substring(numIndex + 1).trim(); int parsedNum; long parsedNum; try { try { parsedNum = Integer.parseInt(numString); parsedNum = Long.parseLong(numString); } catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) { Log.e(TAG, "Failed to parse numbers in " + line); Log.e(TAG, "Failed to parse numbers in " + line); continue; continue; } } final int MiB = 1024 * 1024; int scaled; try { if (line.startsWith("bytes")) { scaled = Math.toIntExact(parsedNum / MiB); } else { scaled = Math.toIntExact(parsedNum); } } catch (ArithmeticException ignored) { Log.e(TAG, "Number overflows in " + line); continue; } if (line.startsWith("time")) { if (line.startsWith("time")) { timeTotal = parsedNum; timeTotal = scaled; } else if (line.startsWith("bytes_written")) { } else if (line.startsWith("bytes_written")) { bytesWritten = (bytesWritten == -1) ? parsedNum : bytesWritten + parsedNum; bytesWrittenInMiB = (bytesWrittenInMiB == -1) ? scaled : bytesWrittenInMiB + scaled; } else if (line.startsWith("bytes_stashed")) { } else if (line.startsWith("bytes_stashed")) { bytesStashed = (bytesStashed == -1) ? parsedNum : bytesStashed + parsedNum; bytesStashedInMiB = (bytesStashedInMiB == -1) ? scaled : bytesStashedInMiB + scaled; } } } } Loading @@ -726,15 +742,15 @@ public class RecoverySystem { if (timeTotal != -1) { if (timeTotal != -1) { MetricsLogger.histogram(context, "ota_time_total", timeTotal); MetricsLogger.histogram(context, "ota_time_total", timeTotal); } } if (bytesWritten != -1) { if (bytesWrittenInMiB != -1) { MetricsLogger.histogram(context, "ota_bytes_written", bytesWritten); MetricsLogger.histogram(context, "ota_written_in_MiBs", bytesWrittenInMiB); } } if (bytesStashed != -1) { if (bytesStashedInMiB != -1) { MetricsLogger.histogram(context, "ota_bytes_stashed", bytesStashed); MetricsLogger.histogram(context, "ota_stashed_in_MiBs", bytesStashedInMiB); } } } catch (IOException ignored) { } catch (IOException e) { Log.e(TAG, "Failed to read lines in last_install", ignored); Log.e(TAG, "Failed to read lines in last_install", e); } } } } Loading Loading
core/java/android/os/RecoverySystem.java +29 −13 Original line number Original line Diff line number Diff line Loading @@ -687,12 +687,13 @@ public class RecoverySystem { } } } } // Read last_install; then report time for update and I/O to tron. // Read last_install; then report time (in seconds) and I/O (in MiB) for // this update to tron. // Only report on the reboots immediately after an OTA update. // Only report on the reboots immediately after an OTA update. private static void parseLastInstallLog(Context context) { private static void parseLastInstallLog(Context context) { try (BufferedReader in = new BufferedReader(new FileReader(LAST_INSTALL_FILE))) { try (BufferedReader in = new BufferedReader(new FileReader(LAST_INSTALL_FILE))) { String line = null; String line = null; int bytesWritten = -1, bytesStashed = -1; int bytesWrittenInMiB = -1, bytesStashedInMiB = -1; int timeTotal = -1; int timeTotal = -1; while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) { // Here is an example of lines in last_install: // Here is an example of lines in last_install: Loading @@ -705,20 +706,35 @@ public class RecoverySystem { continue; continue; } } String numString = line.substring(numIndex + 1).trim(); String numString = line.substring(numIndex + 1).trim(); int parsedNum; long parsedNum; try { try { parsedNum = Integer.parseInt(numString); parsedNum = Long.parseLong(numString); } catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) { Log.e(TAG, "Failed to parse numbers in " + line); Log.e(TAG, "Failed to parse numbers in " + line); continue; continue; } } final int MiB = 1024 * 1024; int scaled; try { if (line.startsWith("bytes")) { scaled = Math.toIntExact(parsedNum / MiB); } else { scaled = Math.toIntExact(parsedNum); } } catch (ArithmeticException ignored) { Log.e(TAG, "Number overflows in " + line); continue; } if (line.startsWith("time")) { if (line.startsWith("time")) { timeTotal = parsedNum; timeTotal = scaled; } else if (line.startsWith("bytes_written")) { } else if (line.startsWith("bytes_written")) { bytesWritten = (bytesWritten == -1) ? parsedNum : bytesWritten + parsedNum; bytesWrittenInMiB = (bytesWrittenInMiB == -1) ? scaled : bytesWrittenInMiB + scaled; } else if (line.startsWith("bytes_stashed")) { } else if (line.startsWith("bytes_stashed")) { bytesStashed = (bytesStashed == -1) ? parsedNum : bytesStashed + parsedNum; bytesStashedInMiB = (bytesStashedInMiB == -1) ? scaled : bytesStashedInMiB + scaled; } } } } Loading @@ -726,15 +742,15 @@ public class RecoverySystem { if (timeTotal != -1) { if (timeTotal != -1) { MetricsLogger.histogram(context, "ota_time_total", timeTotal); MetricsLogger.histogram(context, "ota_time_total", timeTotal); } } if (bytesWritten != -1) { if (bytesWrittenInMiB != -1) { MetricsLogger.histogram(context, "ota_bytes_written", bytesWritten); MetricsLogger.histogram(context, "ota_written_in_MiBs", bytesWrittenInMiB); } } if (bytesStashed != -1) { if (bytesStashedInMiB != -1) { MetricsLogger.histogram(context, "ota_bytes_stashed", bytesStashed); MetricsLogger.histogram(context, "ota_stashed_in_MiBs", bytesStashedInMiB); } } } catch (IOException ignored) { } catch (IOException e) { Log.e(TAG, "Failed to read lines in last_install", ignored); Log.e(TAG, "Failed to read lines in last_install", e); } } } } Loading