From 2758d5d93970f26867d778c944605371e55b751e Mon Sep 17 00:00:00 2001 From: Felipe Leme Date: Tue, 19 Jan 2016 10:30:56 -0800 Subject: [PATCH] Updates notification while bugreport zip is being changed. BUG: 26616935 Change-Id: I3bcbaf30621c23541f2c568355948b6faa578e06 --- packages/Shell/res/values/strings.xml | 4 ++++ .../android/shell/BugreportProgressService.java | 27 ++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/packages/Shell/res/values/strings.xml b/packages/Shell/res/values/strings.xml index dcd5f0478b2f..ffdf480fe091 100644 --- a/packages/Shell/res/values/strings.xml +++ b/packages/Shell/res/values/strings.xml @@ -21,6 +21,10 @@ Bug report is being generated Bug report captured + + Adding details to the bug report + + Please wait\u2026 Swipe left to share your bug report diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index 874a946dae23..5b83796bf1af 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -464,6 +464,7 @@ public class BugreportProgressService extends Service { + info + ")"); return; } + Log.v(TAG, "Sending 'Progress' notification for pid " + info.pid + ": " + percentText); NotificationManager.from(mContext).notify(TAG, info.pid, notification); } @@ -852,7 +853,7 @@ public class BugreportProgressService extends Service { } /** - * Sends a notitication indicating the bugreport has finished so use can share it. + * Sends a notification indicating the bugreport has finished so use can share it. */ private static void sendBugreportNotification(Context context, BugreportInfo info) { final Intent shareIntent = new Intent(INTENT_BUGREPORT_SHARE); @@ -878,10 +879,30 @@ public class BugreportProgressService extends Service { builder.setContentInfo(info.name); } + Log.v(TAG, "Sending 'Share' notification for pid " + info.pid + ": " + title); NotificationManager.from(context).notify(TAG, info.pid, builder.build()); } /** + * Sends a notification indicating the bugreport is being updated so the user can wait until it + * finishes - at this point there is nothing to be done other than waiting, hence it has no + * pending action. + */ + private static void sendBugreportBeingUpdatedNotification(Context context, int pid) { + final String title = context.getString(R.string.bugreport_updating_title); + final Notification.Builder builder = new Notification.Builder(context) + .setSmallIcon(com.android.internal.R.drawable.stat_sys_adb) + .setContentTitle(title) + .setTicker(title) + .setContentText(context.getString(R.string.bugreport_updating_wait)) + .setLocalOnly(true) + .setColor(context.getColor( + com.android.internal.R.color.system_notification_accent_color)); + Log.v(TAG, "Sending 'Updating zip' notification for pid " + pid + ": " + title); + NotificationManager.from(context).notify(TAG, pid, builder.build()); + } + + /** * Sends a zipped bugreport notification. */ private static void sendZippedBugreportNotification(final Context context, @@ -938,11 +959,13 @@ public class BugreportProgressService extends Service { Log.d(TAG, "Not touching zip file since neither title nor description are set"); return; } + // It's not possible to add a new entry into an existing file, so we need to create a new // zip, copy all entries, then rename it. + sendBugreportBeingUpdatedNotification(mContext, info.pid); // ...and that takes time final File dir = info.bugreportFile.getParentFile(); final File tmpZip = new File(dir, "tmp-" + info.bugreportFile.getName()); - Log.d(TAG, "Writing temporary zip file (" + tmpZip + ")"); + Log.d(TAG, "Writing temporary zip file (" + tmpZip + ") with title and/or description"); try (ZipFile oldZip = new ZipFile(info.bugreportFile); ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tmpZip))) { -- 2.11.0