From 51a4ede593b1bba96d7cc14fca54e8e5f02850e0 Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Wed, 20 Apr 2016 10:20:00 -0700 Subject: Only try to add details to zip once. When the user enters details (title or description) to the bugreport, Shell tries to add a title.txt (and/or description.txt) to the zip and uses 2 instance variables (addedDetailsToZip and addingDetailsToZip) to control its state. The problem with the current approach is that if there is a failure adding the entries (for example, if the entries already exist), these variables are not updated and hence when the user taps Share, it will try to add the entries again, which most likely would fail. BUG: 28291423 Change-Id: I56a71256be4f8de15f8126b815334277319e8e8a --- packages/Shell/src/com/android/shell/BugreportProgressService.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'packages/Shell/src') diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index 346ae201cdb6..c541bbce5b7f 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -1075,16 +1075,17 @@ public class BugreportProgressService extends Service { addEntry(zos, "title.txt", info.title); addEntry(zos, "description.txt", info.description); } catch (IOException e) { - info.addingDetailsToZip = false; Log.e(TAG, "exception zipping file " + tmpZip, e); return; + } finally { + // Make sure it only tries to add details once, even it fails the first time. + info.addedDetailsToZip = true; + info.addingDetailsToZip = false; } if (!tmpZip.renameTo(info.bugreportFile)) { Log.e(TAG, "Could not rename " + tmpZip + " to " + info.bugreportFile); } - info.addedDetailsToZip = true; - info.addingDetailsToZip = false; } private static void addEntry(ZipOutputStream zos, String entry, String text) -- cgit v1.2.3-59-g8ed1b