diff options
Diffstat (limited to 'src/com/android/providers/downloads/DownloadInfo.java')
-rw-r--r-- | src/com/android/providers/downloads/DownloadInfo.java | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/com/android/providers/downloads/DownloadInfo.java b/src/com/android/providers/downloads/DownloadInfo.java index b6d57a05..5172b696 100644 --- a/src/com/android/providers/downloads/DownloadInfo.java +++ b/src/com/android/providers/downloads/DownloadInfo.java @@ -36,7 +36,6 @@ import android.util.Pair; import com.android.internal.util.IndentingPrintWriter; -import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -576,4 +575,24 @@ public class DownloadInfo { StorageManager.getInstance(mContext)); mSystemFacade.startThread(downloader); } + + /** + * Query and return status of requested download. + */ + public static int queryDownloadStatus(ContentResolver resolver, long id) { + final Cursor cursor = resolver.query( + ContentUris.withAppendedId(Downloads.Impl.ALL_DOWNLOADS_CONTENT_URI, id), + new String[] { Downloads.Impl.COLUMN_STATUS }, null, null, null); + try { + if (cursor.moveToFirst()) { + return cursor.getInt(0); + } else { + // TODO: increase strictness of value returned for unknown + // downloads; this is safe default for now. + return Downloads.Impl.STATUS_PENDING; + } + } finally { + cursor.close(); + } + } } |