diff options
Diffstat (limited to 'packages/Shell/src')
-rw-r--r-- | packages/Shell/src/com/android/shell/BugreportProgressService.java | 71 |
1 files changed, 11 insertions, 60 deletions
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index 0b8bd9784b7d..3fdd8c851733 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -570,6 +570,7 @@ public class BugreportProgressService extends Service { break; case INTENT_BUGREPORT_DONE: maybeShowWarningMessageAndCloseNotification(id); + break; case INTENT_BUGREPORT_CANCEL: cancel(id); break; @@ -840,16 +841,11 @@ public class BugreportProgressService extends Service { PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); } - @GuardedBy("mLock") - private void stopProgressLocked(int id) { - stopProgressLocked(id, /* cancelNotification */ true); - } - /** * Finalizes the progress on a given bugreport and cancel its notification. */ @GuardedBy("mLock") - private void stopProgressLocked(int id, boolean cancelNotification) { + private void stopProgressLocked(int id) { if (mBugreportInfos.indexOfKey(id) < 0) { Log.w(TAG, "ID not watched: " + id); } else { @@ -859,12 +855,10 @@ public class BugreportProgressService extends Service { // Must stop foreground service first, otherwise notif.cancel() will fail below. stopForegroundWhenDoneLocked(id); - if (cancelNotification) { - Log.d(TAG, "stopProgress(" + id + "): cancel notification"); - NotificationManager.from(mContext).cancel(id); - } else { - Log.d(TAG, "stopProgress(" + id + ")"); - } + + Log.d(TAG, "stopProgress(" + id + "): cancel notification"); + NotificationManager.from(mContext).cancel(id); + stopSelfWhenDoneLocked(); } @@ -1109,30 +1103,7 @@ public class BugreportProgressService extends Service { return; } - if (mIsWatch) { - // Wear wants to send the notification directly and not wait for the user to tap on the - // notification. - triggerShareBugreportAndLocalNotification(info); - } else { - triggerLocalNotification(info); - } - } - - /** - * Responsible for starting the bugerport sharing process and posting a notification which - * shows that the bugreport has been taken and that the sharing process has kicked-off. - */ - private void triggerShareBugreportAndLocalNotification(final BugreportInfo info) { - boolean isPlainText = info.bugreportFile.getName().toLowerCase().endsWith(".txt"); - if (!isPlainText) { - // Already zipped, share it right away. - shareBugreport(info.id, info, /* showWarning */ false, - /* cancelNotificationWhenStoppingProgress */ false); - sendBugreportNotification(info, mTakingScreenshot); - } else { - // Asynchronously zip the file first, then share it. - shareAndPostNotificationForZippedBugreport(info, mTakingScreenshot); - } + triggerLocalNotification(info); } /** @@ -1246,16 +1217,14 @@ public class BugreportProgressService extends Service { } private void shareBugreport(int id, BugreportInfo sharedInfo) { - shareBugreport(id, sharedInfo, !hasUserDecidedNotToGetWarningMessage(), - /* cancelNotificationWhenStoppingProgress */ true); + shareBugreport(id, sharedInfo, !hasUserDecidedNotToGetWarningMessage()); } /** * Shares the bugreport upon user's request by issuing a {@link Intent#ACTION_SEND_MULTIPLE} * intent, but issuing a warning dialog the first time. */ - private void shareBugreport(int id, BugreportInfo sharedInfo, boolean showWarning, - boolean cancelNotificationWhenStoppingProgress) { + private void shareBugreport(int id, BugreportInfo sharedInfo, boolean showWarning) { MetricsLogger.action(this, MetricsEvent.ACTION_BUGREPORT_NOTIFICATION_ACTION_SHARE); BugreportInfo info; synchronized (mLock) { @@ -1304,7 +1273,7 @@ public class BugreportProgressService extends Service { } synchronized (mLock) { // ... and stop watching this process. - stopProgressLocked(id, cancelNotificationWhenStoppingProgress); + stopProgressLocked(id); } } @@ -1359,7 +1328,7 @@ public class BugreportProgressService extends Service { PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE)) .setDeleteIntent(newCancelIntent(mContext, info)); } else { - // Device is a watch. + // Device is a watch if (hasUserDecidedNotToGetWarningMessage()) { // No action button needed for the notification. User can swipe to dimiss. builder.setActions(new Action[0]); @@ -1430,24 +1399,6 @@ public class BugreportProgressService extends Service { } /** - * Zips a bugreport, shares it, and sends for it a bugreport notification. - */ - private void shareAndPostNotificationForZippedBugreport(final BugreportInfo info, - final boolean takingScreenshot) { - new AsyncTask<Void, Void, Void>() { - @Override - protected Void doInBackground(Void... params) { - Looper.prepare(); - zipBugreport(info); - shareBugreport(info.id, info, /* showWarning */ false, - /* cancelNotificationWhenStoppingProgress */ false); - sendBugreportNotification(info, mTakingScreenshot); - return null; - } - }.execute(); - } - - /** * Zips a bugreport file, returning the path to the new file (or to the * original in case of failure). */ |