diff options
author | Abhijeet Kaur <abkaur@google.com> | 2020-04-01 12:22:55 +0100 |
---|---|---|
committer | Abhijeet Kaur <abkaur@google.com> | 2020-04-06 12:35:19 +0100 |
commit | 1a5687df2c1601d2cd23f26c07307fcbc3fcc438 (patch) | |
tree | 2728a242306b82c248eb3fd46704c0b377c6f2c3 /packages/Shell/src | |
parent | 80849883c61d327457fd310b12b80d719415c469 (diff) |
Delete empty bugreport files onError
Bug: 152839953
Test: Take another bugreport, while one is in progress.
Without this change: bugreport files for the second bugreport can be
seen in /bugreports
With this change: no file for the second bugreport can be seen. This
is the expected behavior.
Change-Id: I45c1f66f3a52ba9a31413cf9748bc5504eaa65d0
Diffstat (limited to 'packages/Shell/src')
-rw-r--r-- | packages/Shell/src/com/android/shell/BugreportProgressService.java | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index 68bd4071de05..c2015ed41b00 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -363,6 +363,7 @@ public class BugreportProgressService extends Service { public void onError(@BugreportErrorCode int errorCode) { synchronized (mLock) { stopProgressLocked(mInfo.id); + mInfo.deleteEmptyFiles(); } Log.e(TAG, "Bugreport API callback onError() errorCode = " + errorCode); return; @@ -1980,6 +1981,22 @@ public class BugreportProgressService extends Service { } /** + * Deletes empty files for a given bugreport. + */ + private void deleteEmptyFiles() { + if (bugreportFile.length() == 0) { + Log.i(TAG, "Deleting empty bugreport file: " + bugreportFile); + bugreportFile.delete(); + } + for (File file : screenshotFiles) { + if (file.length() == 0) { + Log.i(TAG, "Deleting empty screenshot file: " + file); + file.delete(); + } + } + } + + /** * Rename all screenshots files so that they contain the new {@code name} instead of the * {@code initialName} if user has changed it. */ |