Ensure dropbox could copy tombstone files to special folder.

Process of tombstoned have changed the generation flow for
tombstone, and dropbox could not be notified when generating new
tombstone file any more, so dropbox could not copy and compress
tombstone file to /data/system/dropbox. We need to modify
observer events from CLOSE_WRITE to CREATE, and it could
work normally.

Bug: http://b/111608961
Test: 1 After tombstone is triggered, we could see the tombstone
      file in the data/system/dropbox directory.

Signed-off-by: Haoran Li <lihaoran5@huawei.com>

Change-Id: I9d6a31773e4a58658ffab214b1e337f27e9f3ae6
(cherry picked from commit fe8d2c9a8c)
This commit is contained in:
Jinguang Dong
2018-07-17 11:53:18 +08:00
committed by Josh Gao
parent 3d3c6531e1
commit 56bb0b7219

View File

@@ -258,13 +258,13 @@ public class BootReceiver extends BroadcastReceiver {
// Start watching for new tombstone files; will record them as they occur. // Start watching for new tombstone files; will record them as they occur.
// This gets registered with the singleton file observer thread. // This gets registered with the singleton file observer thread.
sTombstoneObserver = new FileObserver(TOMBSTONE_DIR.getPath(), FileObserver.CLOSE_WRITE) { sTombstoneObserver = new FileObserver(TOMBSTONE_DIR.getPath(), FileObserver.CREATE) {
@Override @Override
public void onEvent(int event, String path) { public void onEvent(int event, String path) {
HashMap<String, Long> timestamps = readTimestamps(); HashMap<String, Long> timestamps = readTimestamps();
try { try {
File file = new File(TOMBSTONE_DIR, path); File file = new File(TOMBSTONE_DIR, path);
if (file.isFile()) { if (file.isFile() && file.getName().startsWith("tombstone_")) {
addFileToDropBox(db, timestamps, headers, file.getPath(), LOG_SIZE, addFileToDropBox(db, timestamps, headers, file.getPath(), LOG_SIZE,
TAG_TOMBSTONE); TAG_TOMBSTONE);
} }