diff options
author | 2025-03-07 15:41:43 +0000 | |
---|---|---|
committer | 2025-03-11 05:16:19 -0700 | |
commit | 96ef55cc85ffea13e601613fa525501dbafcead0 (patch) | |
tree | 035ffeef4165d9448c59e070c77e851deb929340 | |
parent | 7acbff030c88c60c9a99a114a76d9c2d53478e1d (diff) |
Rate limit BR notifications
To avoid notifications throttling, rate limit the notifications
instead of delaying the final notification. The final delay doesn't
worj in case the service get's killed, which can happen on a busy
device. Note, this is in control of the system and not the
service/client.
Bug: 395488230
Change-Id: I9fb20868e163292c7e12c5cc12c4e79c7683aab9
Test: N/A couldn't repro
Flag: EXEMPT Minor Change
-rw-r--r-- | packages/Shell/src/com/android/shell/BugreportProgressService.java | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java index 61f49db07abc..94dd0703c026 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -257,11 +257,11 @@ 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(); +/** Minimum delay between percentage points before sending an update notification */ + private static final int MIN_NOTIFICATION_GAP = 10; + /** Managed bugreport info (keyed by id) */ @GuardedBy("mLock") private final SparseArray<BugreportInfo> mBugreportInfos = new SparseArray<>(); @@ -1458,17 +1458,6 @@ public class BugreportProgressService extends Service { * Sends a notification indicating the bugreport has finished so use can share it. */ 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); @@ -1521,7 +1510,7 @@ public class BugreportProgressService extends Service { builder.setSubText(info.getName()); } - Log.v(TAG, "Sending 'Share' notification for ID " + info.id + ": " + title); + Log.d(TAG, "Sending 'Share' notification for ID " + info.id + ": " + title); NotificationManager.from(mContext).notify(info.id, builder.build()); } @@ -2751,6 +2740,11 @@ public class BugreportProgressService extends Service { if (progress > CAPPED_PROGRESS) { progress = CAPPED_PROGRESS; } + + if ((progress - info.lastProgress.intValue()) < MIN_NOTIFICATION_GAP) { + return; + } + if (DEBUG) { if (progress != info.progress.intValue()) { Log.v(TAG, "Updating progress for name " + info.getName() + "(id: " + info.id |