From c6cf2b807281c82d9cf7d018b703b2f21388f7a5 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Fri, 21 Apr 2017 09:43:16 -0700 Subject: Only show progress log every 10% Bug: 37501913 Test: manual Change-Id: Ib7d14da0af33d39aa29b0b58c63c51e1059e0ada --- .../src/com/android/shell/BugreportProgressService.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (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 d37e6a0ebd78..415bf9a0470b 100644 --- a/packages/Shell/src/com/android/shell/BugreportProgressService.java +++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java @@ -172,6 +172,9 @@ public class BugreportProgressService extends Service { private static final int CAPPED_PROGRESS = 9900; private static final int CAPPED_MAX = 10000; + /** Show the progress log every this percent. */ + private static final int LOG_PROGRESS_STEP = 10; + /** * Delay before a screenshot is taken. *

@@ -226,6 +229,8 @@ public class BugreportProgressService extends Service { private boolean mIsWatch; + private int mLastProgressPercent; + @Override public void onCreate() { mContext = getApplicationContext(); @@ -512,8 +517,15 @@ public class BugreportProgressService extends Service { builder.setContentIntent(infoPendingIntent) .setActions(infoAction, screenshotAction, cancelAction); } + // Show a debug log, every LOG_PROGRESS_STEP percent. + final int progress = (info.progress * 100) / info.max; + + if ((info.progress == 0) || (info.progress >= 100) || + ((progress / LOG_PROGRESS_STEP) != (mLastProgressPercent / LOG_PROGRESS_STEP))) { + Log.d(TAG, "Progress #" + info.id + ": " + percentageText); + } + mLastProgressPercent = progress; - Log.d(TAG, "Sending 'Progress' notification for id " + info.id + ": " + percentageText); sendForegroundabledNotification(info.id, builder.build()); } -- cgit v1.2.3-59-g8ed1b