summaryrefslogtreecommitdiff
path: root/packages/Shell/src
diff options
context:
space:
mode:
authorAbhijeet Kaur <abkaur@google.com>2019-07-29 09:50:55 +0100
committerAbhijeet Kaur <abkaur@google.com>2019-08-05 15:24:16 +0100
commit1b1d614e63950a2acff33f19615889f81b967542 (patch)
treee054fd2a58e4f11075e4123c86bc13302b2a3a91 /packages/Shell/src
parent7bdc19bacb177ba5fbfd6bb5db6fe4543fe2f220 (diff)
Add logic to handle screenshot file creation failure
Delete the bugreport file to free the space before returning. Delete unnecessary if blocks as the File constructor would never return null Bug:123617758 Test: Force code to execute the if (screenshotFd == null) block. Bugreport file gets deleted successfully Change-Id: Ib88278a8a56799ef562b8b06e5e530a8e31e85d5
Diffstat (limited to 'packages/Shell/src')
-rw-r--r--packages/Shell/src/com/android/shell/BugreportProgressService.java14
1 files changed, 2 insertions, 12 deletions
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java
index a7b44443fc9c..fc3778d40a05 100644
--- a/packages/Shell/src/com/android/shell/BugreportProgressService.java
+++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java
@@ -580,9 +580,9 @@ public class BugreportProgressService extends Service {
ParcelFileDescriptor screenshotFd = createReadWriteFile(BUGREPORT_DIR,
bugreportName + ".png");
if (screenshotFd == null) {
- Log.e(TAG, "Screenshot parcel file descriptor is null.");
- // TODO(b/123617758): Delete bugreport file created above
+ Log.e(TAG, "Screenshot parcel file descriptor is null. Deleting bugreport file");
FileUtils.closeQuietly(bugreportFd);
+ new File(BUGREPORT_DIR, String.format("%s.zip", bugreportName)).delete();
return;
}
mBugreportManager = (BugreportManager) mContext.getSystemService(
@@ -970,18 +970,8 @@ public class BugreportProgressService extends Service {
private void onBugreportFinished(int id) {
BugreportInfo info = getInfo(id);
final File bugreportFile = new File(BUGREPORT_DIR, info.name + ".zip");
- if (bugreportFile == null) {
- // Should never happen, an id always has a file linked to it.
- Log.wtf(TAG, "Missing file " + bugreportFile.getPath() + " does not exist.");
- return;
- }
final int max = -1; // this is to log metrics for dumpstate duration.
File screenshotFile = new File(BUGREPORT_DIR, info.name + ".png");
- if (screenshotFile == null) {
- // Should never happen, an id always has a file linked to it.
- Log.wtf(TAG, "Missing file " + screenshotFile.getPath() + " does not exist.");
- return;
- }
// If the screenshot file did not get populated implies this type of bugreport does not
// need the screenshot file; setting the file to null so that empty file doesnt get shared
if (screenshotFile.length() == 0) {