Merge "Record tombstone proto file's timestamp into the dropbox" am: cbcb665dee am: 48a54513c8 am: 0017457118
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1970680 Change-Id: I0941d11e59982e89aeb8f77179b2d45d08dc47ac
This commit is contained in:
@@ -484,7 +484,9 @@ public class BootReceiver extends BroadcastReceiver {
|
|||||||
HashMap<String, Long> timestamps = readTimestamps();
|
HashMap<String, Long> timestamps = readTimestamps();
|
||||||
try {
|
try {
|
||||||
if (proto) {
|
if (proto) {
|
||||||
db.addFile(TAG_TOMBSTONE_PROTO, tombstone, 0);
|
if (recordFileTimestamp(tombstone, timestamps)) {
|
||||||
|
db.addFile(TAG_TOMBSTONE_PROTO, tombstone, 0);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final String headers = getBootHeadersToLogAndUpdate();
|
final String headers = getBootHeadersToLogAndUpdate();
|
||||||
addFileToDropBox(db, timestamps, headers, tombstone.getPath(), LOG_SIZE,
|
addFileToDropBox(db, timestamps, headers, tombstone.getPath(), LOG_SIZE,
|
||||||
@@ -526,16 +528,10 @@ public class BootReceiver extends BroadcastReceiver {
|
|||||||
if (db == null || !db.isTagEnabled(tag)) return; // Logging disabled
|
if (db == null || !db.isTagEnabled(tag)) return; // Logging disabled
|
||||||
|
|
||||||
File file = new File(filename);
|
File file = new File(filename);
|
||||||
long fileTime = file.lastModified();
|
if (!recordFileTimestamp(file, timestamps)) {
|
||||||
if (fileTime <= 0) return; // File does not exist
|
return;
|
||||||
|
|
||||||
if (timestamps.containsKey(filename) && timestamps.get(filename) == fileTime) {
|
|
||||||
return; // Already logged this particular file
|
|
||||||
}
|
}
|
||||||
|
|
||||||
timestamps.put(filename, fileTime);
|
|
||||||
|
|
||||||
|
|
||||||
String fileContents = FileUtils.readTextFile(file, maxSize, TAG_TRUNCATED);
|
String fileContents = FileUtils.readTextFile(file, maxSize, TAG_TRUNCATED);
|
||||||
String text = headers + fileContents + footers;
|
String text = headers + fileContents + footers;
|
||||||
// Create an additional report for system server native crashes, with a special tag.
|
// Create an additional report for system server native crashes, with a special tag.
|
||||||
@@ -548,6 +544,19 @@ public class BootReceiver extends BroadcastReceiver {
|
|||||||
addTextToDropBox(db, tag, text, filename, maxSize);
|
addTextToDropBox(db, tag, text, filename, maxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean recordFileTimestamp(File file, HashMap<String, Long> timestamps) {
|
||||||
|
final long fileTime = file.lastModified();
|
||||||
|
if (fileTime <= 0) return false; // File does not exist
|
||||||
|
|
||||||
|
final String filename = file.getPath();
|
||||||
|
if (timestamps.containsKey(filename) && timestamps.get(filename) == fileTime) {
|
||||||
|
return false; // Already logged this particular file
|
||||||
|
}
|
||||||
|
|
||||||
|
timestamps.put(filename, fileTime);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private static void addTextToDropBox(DropBoxManager db, String tag, String text,
|
private static void addTextToDropBox(DropBoxManager db, String tag, String text,
|
||||||
String filename, int maxSize) {
|
String filename, int maxSize) {
|
||||||
Slog.i(TAG, "Copying " + filename + " to DropBox (" + tag + ")");
|
Slog.i(TAG, "Copying " + filename + " to DropBox (" + tag + ")");
|
||||||
|
|||||||
Reference in New Issue
Block a user