summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVasu Nori <vnori@google.com>2010-11-11 15:26:07 -0800
committerVasu Nori <vnori@google.com>2010-11-11 16:29:49 -0800
commit9d27069a5453574824860ad3db179599d044e7bd (patch)
treea6cef66dd8abfda3b55d0231e555c38bd2b05b0e /src
parentce3bb8c2995ecf69741b69369346f2a4f827eaea (diff)
downloadandroid_packages_providers_DownloadProvider-9d27069a5453574824860ad3db179599d044e7bd.tar.gz
android_packages_providers_DownloadProvider-9d27069a5453574824860ad3db179599d044e7bd.tar.bz2
android_packages_providers_DownloadProvider-9d27069a5453574824860ad3db179599d044e7bd.zip
when a download fails, store the error msg in db
useful for debugging for bugs like bug:3187299 without this error message, one doesn't know WHY downloads fail. to prevent PII info in database, there is a STOPSHIP comment around storage of this error message in database. Change-Id: I612e383aef8483b68b772f70dff722a5daea2ef5
Diffstat (limited to 'src')
-rw-r--r--src/com/android/providers/downloads/DownloadProvider.java6
-rw-r--r--src/com/android/providers/downloads/DownloadThread.java25
2 files changed, 22 insertions, 9 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java
index 1aa9a0b1..79544675 100644
--- a/src/com/android/providers/downloads/DownloadProvider.java
+++ b/src/com/android/providers/downloads/DownloadProvider.java
@@ -58,7 +58,7 @@ public final class DownloadProvider extends ContentProvider {
/** Database filename */
private static final String DB_NAME = "downloads.db";
/** Current database version */
- private static final int DB_VERSION = 106;
+ private static final int DB_VERSION = 107;
/** Name of table in the database */
private static final String DB_TABLE = "downloads";
@@ -286,6 +286,10 @@ public final class DownloadProvider extends ContentProvider {
"BOOLEAN NOT NULL DEFAULT 0");
break;
+ case 107:
+ addColumn(db, DB_TABLE, Downloads.Impl.COLUMN_ERROR_MSG, "TEXT");
+ break;
+
default:
throw new IllegalStateException("Don't know how to upgrade to " + version);
}
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java
index f6f511e9..0eea6c70 100644
--- a/src/com/android/providers/downloads/DownloadThread.java
+++ b/src/com/android/providers/downloads/DownloadThread.java
@@ -29,6 +29,7 @@ import android.os.PowerManager;
import android.os.Process;
import android.provider.Downloads;
import android.provider.DrmStore;
+import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
@@ -148,6 +149,7 @@ public class DownloadThread extends Thread {
AndroidHttpClient client = null;
PowerManager.WakeLock wakeLock = null;
int finalStatus = Downloads.Impl.STATUS_UNKNOWN_ERROR;
+ String errorMsg = null;
try {
PowerManager pm = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
@@ -187,11 +189,12 @@ public class DownloadThread extends Thread {
finalStatus = Downloads.Impl.STATUS_SUCCESS;
} catch (StopRequest error) {
// remove the cause before printing, in case it contains PII
- Log.w(Constants.TAG,
- "Aborting request for download " + mInfo.mId + ": " + error.getMessage());
+ errorMsg = "Aborting request for download " + mInfo.mId + ": " + error.getMessage();
+ Log.w(Constants.TAG, errorMsg);
finalStatus = error.mFinalStatus;
// fall through to finally block
} catch (Throwable ex) { //sometimes the socket code throws unchecked exceptions
+ errorMsg = "Exception for id " + mInfo.mId + ": " + ex.getMessage();
Log.w(Constants.TAG, "Exception for id " + mInfo.mId + ": " + ex);
finalStatus = Downloads.Impl.STATUS_UNKNOWN_ERROR;
// falls through to the code that reports an error
@@ -207,7 +210,7 @@ public class DownloadThread extends Thread {
cleanupDestination(state, finalStatus);
notifyDownloadCompleted(finalStatus, state.mCountRetry, state.mRetryAfter,
state.mRedirectCount, state.mGotData, state.mFilename,
- state.mNewUri, state.mMimeType);
+ state.mNewUri, state.mMimeType, errorMsg);
mInfo.mHasActiveThread = false;
}
}
@@ -686,7 +689,8 @@ public class DownloadThread extends Thread {
} else {
finalStatus = Downloads.Impl.STATUS_UNHANDLED_HTTP_CODE;
}
- throw new StopRequest(finalStatus, "http error " + statusCode);
+ throw new StopRequest(finalStatus, "http error " + statusCode + ", mContinuingDownload: " +
+ innerState.mContinuingDownload);
}
/**
@@ -861,9 +865,10 @@ public class DownloadThread extends Thread {
*/
private void notifyDownloadCompleted(
int status, boolean countRetry, int retryAfter, int redirectCount, boolean gotData,
- String filename, String uri, String mimeType) {
+ String filename, String uri, String mimeType, String errorMsg) {
notifyThroughDatabase(
- status, countRetry, retryAfter, redirectCount, gotData, filename, uri, mimeType);
+ status, countRetry, retryAfter, redirectCount, gotData, filename, uri, mimeType,
+ errorMsg);
if (Downloads.Impl.isStatusCompleted(status)) {
mInfo.sendIntentIfRequested();
}
@@ -871,7 +876,7 @@ public class DownloadThread extends Thread {
private void notifyThroughDatabase(
int status, boolean countRetry, int retryAfter, int redirectCount, boolean gotData,
- String filename, String uri, String mimeType) {
+ String filename, String uri, String mimeType, String errorMsg) {
ContentValues values = new ContentValues();
values.put(Downloads.Impl.COLUMN_STATUS, status);
values.put(Downloads.Impl._DATA, filename);
@@ -888,7 +893,11 @@ public class DownloadThread extends Thread {
} else {
values.put(Constants.FAILED_CONNECTIONS, mInfo.mNumFailed + 1);
}
-
+ // STOPSHIP begin delete the following lines
+ if (!TextUtils.isEmpty(errorMsg)) {
+ values.put(Downloads.Impl.COLUMN_ERROR_MSG, errorMsg);
+ }
+ // STOPSHIP end
mContext.getContentResolver().update(mInfo.getAllDownloadsUri(), values, null, null);
}