summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkaiyiz <kaiyiz@codeaurora.org>2014-03-25 13:40:07 +0800
committerAdnan <adnan@cyngn.com>2014-08-26 17:06:49 -0700
commit5d1d0f24bae61ad1b5ecf31d340b379a52a423b3 (patch)
tree0742f8cebad77e5f41f1a0e3e3c50f725daf575e
parentf668ad5ed0b6885052118725f360de5c68c96f36 (diff)
downloadandroid_packages_providers_DownloadProvider-5d1d0f24bae61ad1b5ecf31d340b379a52a423b3.tar.gz
android_packages_providers_DownloadProvider-5d1d0f24bae61ad1b5ecf31d340b379a52a423b3.tar.bz2
android_packages_providers_DownloadProvider-5d1d0f24bae61ad1b5ecf31d340b379a52a423b3.zip
DownloadProvider: Still display as downloading after download failed
When the remaining space is less than 10% of the total space, download will fail, but it still display as downloading in status bar after failed in "Downloads" app. Check error status about downloads. If error exists, will update icon , content title and content text in notification. CRs-Fixed: 636489 Change-Id: I5554ef3d1505642c5cd847bd3d2e25a29772dc0d
-rwxr-xr-xsrc/com/android/providers/downloads/DownloadNotifier.java33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/com/android/providers/downloads/DownloadNotifier.java b/src/com/android/providers/downloads/DownloadNotifier.java
index 809347fd..bd4a5334 100755
--- a/src/com/android/providers/downloads/DownloadNotifier.java
+++ b/src/com/android/providers/downloads/DownloadNotifier.java
@@ -163,9 +163,19 @@ public class DownloadNotifier {
}
}
+ // Check error status about downloads. If error exists, will
+ // update icon and content title/content text in notification.
+ boolean hasErrorStatus = false;
+ for (DownloadInfo info : cluster) {
+ if (isErrorStatus(info.mStatus)) {
+ hasErrorStatus = true;
+ break;
+ }
+ }
+
// Show relevant icon
if (type == TYPE_ACTIVE) {
- if (hasPausedStatus) {
+ if (hasPausedStatus || hasErrorStatus) {
builder.setSmallIcon(R.drawable.download_pause);
} else {
builder.setSmallIcon(android.R.drawable.stat_sys_download);
@@ -220,9 +230,9 @@ public class DownloadNotifier {
String remainingText = null;
String percentText = null;
String speedAsSizeText = null;
+ long total = 0;
if (type == TYPE_ACTIVE) {
long current = 0;
- long total = 0;
long speed = 0;
synchronized (mDownloadSpeed) {
for (DownloadInfo info : cluster) {
@@ -283,6 +293,11 @@ public class DownloadNotifier {
} else if (speedAsSizeText != null) {
builder.setContentText(res.getString(R.string.download_speed_text,
remainingText, speedAsSizeText));
+ } else if (hasErrorStatus) {
+ builder.setContentText(res.getText(
+ R.string.notification_download_failed));
+ if (total == 0)
+ builder.setProgress(100, 0, false);
}
builder.setContentInfo(percentText);
@@ -311,6 +326,11 @@ public class DownloadNotifier {
if (type == TYPE_ACTIVE) {
if (hasPausedStatus) {
builder.setContentTitle(res.getString(R.string.download_queued));
+ } else if (hasErrorStatus) {
+ builder.setContentText(res.getText(
+ R.string.notification_download_failed));
+ if (total == 0)
+ builder.setProgress(100, 0, false);
} else {
builder.setContentTitle(res.getQuantityString(
R.plurals.notif_summary_active, cluster.size(), cluster.size()));
@@ -416,4 +436,13 @@ public class DownloadNotifier {
status == Downloads.Impl.STATUS_PAUSED_BY_MANUAL;
}
+ private static boolean isErrorStatus(int status) {
+ boolean isErrorStatus = Downloads.Impl.isStatusError(status)
+ || Downloads.Impl.isStatusClientError(status)
+ || Downloads.Impl.isStatusServerError(status)
+ || status == Downloads.Impl.STATUS_INSUFFICIENT_SPACE_ERROR
+ || status == Downloads.Impl.STATUS_DEVICE_NOT_FOUND_ERROR;
+ return isErrorStatus;
+ }
+
}