summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/DownloadNotifier.java
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2013-03-25 13:54:29 -0700
committerJeff Sharkey <jsharkey@android.com>2013-03-25 13:54:29 -0700
commit703bc3a83056a878a83e263b992fb5331b84535f (patch)
tree314689a9bc53b284bacb1d257849d84de3ce7ff8 /src/com/android/providers/downloads/DownloadNotifier.java
parent2c462097d100646ec7491b5fd5fa00ae7ff49200 (diff)
downloadandroid_packages_providers_DownloadProvider-703bc3a83056a878a83e263b992fb5331b84535f.tar.gz
android_packages_providers_DownloadProvider-703bc3a83056a878a83e263b992fb5331b84535f.tar.bz2
android_packages_providers_DownloadProvider-703bc3a83056a878a83e263b992fb5331b84535f.zip
Reduce logging, dump stacks before wtf().
Most wtf() are looking like network timeouts, not threading bugs, so disable verbose debugging and add more targeted thread logging before calling wtf(). Bug: 8233041 Change-Id: I8e276bffd7880cfe13b65e7e81f5507cab627692
Diffstat (limited to 'src/com/android/providers/downloads/DownloadNotifier.java')
-rw-r--r--src/com/android/providers/downloads/DownloadNotifier.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/com/android/providers/downloads/DownloadNotifier.java b/src/com/android/providers/downloads/DownloadNotifier.java
index 0af9cb86..f832eae3 100644
--- a/src/com/android/providers/downloads/DownloadNotifier.java
+++ b/src/com/android/providers/downloads/DownloadNotifier.java
@@ -20,6 +20,7 @@ import static android.app.DownloadManager.Request.VISIBILITY_VISIBLE;
import static android.app.DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED;
import static android.app.DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_ONLY_COMPLETION;
import static android.provider.Downloads.Impl.STATUS_RUNNING;
+import static com.android.providers.downloads.Constants.TAG;
import android.app.DownloadManager;
import android.app.Notification;
@@ -30,9 +31,11 @@ import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
+import android.os.SystemClock;
import android.provider.Downloads;
import android.text.TextUtils;
import android.text.format.DateUtils;
+import android.util.Log;
import android.util.LongSparseLongArray;
import com.google.common.collect.ArrayListMultimap;
@@ -75,6 +78,13 @@ public class DownloadNotifier {
@GuardedBy("mDownloadSpeed")
private final LongSparseLongArray mDownloadSpeed = new LongSparseLongArray();
+ /**
+ * Last time speed was reproted, mapped from {@link DownloadInfo#mId} to
+ * {@link SystemClock#elapsedRealtime()}.
+ */
+ @GuardedBy("mDownloadSpeed")
+ private final LongSparseLongArray mDownloadTouch = new LongSparseLongArray();
+
public DownloadNotifier(Context context) {
mContext = context;
mNotifManager = (NotificationManager) context.getSystemService(
@@ -86,15 +96,17 @@ public class DownloadNotifier {
}
/**
- * Notify the current speed of an active download, used for calcuating
+ * Notify the current speed of an active download, used for calculating
* estimated remaining time.
*/
public void notifyDownloadSpeed(long id, long bytesPerSecond) {
synchronized (mDownloadSpeed) {
if (bytesPerSecond != 0) {
mDownloadSpeed.put(id, bytesPerSecond);
+ mDownloadTouch.put(id, SystemClock.elapsedRealtime());
} else {
mDownloadSpeed.delete(id);
+ mDownloadTouch.delete(id);
}
}
}
@@ -302,6 +314,17 @@ public class DownloadNotifier {
return ids;
}
+ public void dumpSpeeds() {
+ synchronized (mDownloadSpeed) {
+ for (int i = 0; i < mDownloadSpeed.size(); i++) {
+ final long id = mDownloadSpeed.keyAt(i);
+ final long delta = SystemClock.elapsedRealtime() - mDownloadTouch.get(id);
+ Log.d(TAG, "Download " + id + " speed " + mDownloadSpeed.valueAt(i) + "bps, "
+ + delta + "ms ago");
+ }
+ }
+ }
+
/**
* Build tag used for collapsing several {@link DownloadInfo} into a single
* {@link Notification}.