diff options
author | 2024-12-12 08:10:48 -0800 | |
---|---|---|
committer | 2024-12-12 08:10:48 -0800 | |
commit | e04c12bd1d83c08b66076f7f3092be6d92deed66 (patch) | |
tree | e3726760e2c65f391395c403e0e1731d3afbccd3 /packages/Shell/src | |
parent | dab4a553078f2fc8adff9e123763db551493e6ed (diff) | |
parent | cff62d9350d2ee32c475a27980164b519f58d403 (diff) |
Merge "Delay final notification for bugreport generation" into main
Diffstat (limited to 'packages/Shell/src')
-rw-r--r-- | packages/Shell/src/com/android/shell/BugreportProgressService.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index bcfd8f620f9c..75156bac3dc4 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -236,6 +236,9 @@ public class BugreportProgressService extends Service { /** Always keep remote bugreport files created in the last day. */ private static final long REMOTE_MIN_KEEP_AGE = DateUtils.DAY_IN_MILLIS; + /** Minimum delay for sending last update notification */ + private static final int DELAY_NOTIFICATION_MS = 250; + private final Object mLock = new Object(); /** Managed bugreport info (keyed by id) */ @@ -849,6 +852,7 @@ public class BugreportProgressService extends Service { Log.d(TAG, "Progress #" + info.id + ": " + percentageText); } info.lastProgress.set(progress); + info.lastUpdate.set(System.currentTimeMillis()); sendForegroundabledNotification(info.id, builder.build()); } @@ -1368,6 +1372,16 @@ public class BugreportProgressService extends Service { */ private void sendBugreportNotification(BugreportInfo info, boolean takingScreenshot) { + final long lastUpdate = System.currentTimeMillis() - info.lastUpdate.longValue(); + if (lastUpdate < DELAY_NOTIFICATION_MS) { + Log.d(TAG, "Delaying final notification for " + + (DELAY_NOTIFICATION_MS - lastUpdate) + " ms "); + mMainThreadHandler.postDelayed(() -> { + sendBugreportNotification(info, takingScreenshot); + }, DELAY_NOTIFICATION_MS - lastUpdate); + return; + } + // Since adding the details can take a while, do it before notifying user. addDetailsToZipFile(info); @@ -1388,6 +1402,7 @@ public class BugreportProgressService extends Service { final Notification.Builder builder = newBaseNotification(mContext) .setContentTitle(title) .setTicker(title) + .setProgress(100 /* max value of progress percentage */, 100, false) .setOnlyAlertOnce(false) .setContentText(content); @@ -2426,7 +2441,6 @@ public class BugreportProgressService extends Service { } } info.progress.set(progress); - info.lastUpdate.set(System.currentTimeMillis()); updateProgress(info); } |