diff options
author | 2014-02-17 03:35:58 -0800 | |
---|---|---|
committer | 2014-02-17 03:35:58 -0800 | |
commit | daf28b45a4367b6877e895e8e8e43c6df1187074 (patch) | |
tree | 41048913ed2cd3c48ede7eb73dd6b0b9382c3adc /java/src/com/android/inputmethod/dictionarypack/ActionBatch.java | |
parent | 8a045cd6c3c25aaf419697a8510ee996b77f6bcb (diff) | |
parent | d91cd9919e309e72f912f5cb135792351d7081ac (diff) | |
download | latinime-daf28b45a4367b6877e895e8e8e43c6df1187074.tar.gz latinime-daf28b45a4367b6877e895e8e8e43c6df1187074.tar.xz latinime-daf28b45a4367b6877e895e8e8e43c6df1187074.zip |
am d91cd991: Merge "Catch exceptions we can\'t do anything about."
* commit 'd91cd9919e309e72f912f5cb135792351d7081ac':
Catch exceptions we can't do anything about.
Diffstat (limited to 'java/src/com/android/inputmethod/dictionarypack/ActionBatch.java')
-rw-r--r-- | java/src/com/android/inputmethod/dictionarypack/ActionBatch.java | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/java/src/com/android/inputmethod/dictionarypack/ActionBatch.java b/java/src/com/android/inputmethod/dictionarypack/ActionBatch.java index d5e638e7e..706bdea8e 100644 --- a/java/src/com/android/inputmethod/dictionarypack/ActionBatch.java +++ b/java/src/com/android/inputmethod/dictionarypack/ActionBatch.java @@ -117,16 +117,11 @@ public final class ActionBatch { final ContentValues values = MetadataDbHelper.getContentValuesByWordListId(db, mWordList.mId, mWordList.mVersion); final int status = values.getAsInteger(MetadataDbHelper.STATUS_COLUMN); - final DownloadManager manager = - (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); + final DownloadManagerWrapper manager = new DownloadManagerWrapper(context); if (MetadataDbHelper.STATUS_DOWNLOADING == status) { // The word list is still downloading. Cancel the download and revert the // word list status to "available". - if (null != manager) { - // DownloadManager is disabled (or not installed?). We can't cancel - there - // is nothing we can do. We still need to mark the entry as available. - manager.remove(values.getAsLong(MetadataDbHelper.PENDINGID_COLUMN)); - } + manager.remove(values.getAsLong(MetadataDbHelper.PENDINGID_COLUMN)); MetadataDbHelper.markEntryAsAvailable(db, mWordList.mId, mWordList.mVersion); } else if (MetadataDbHelper.STATUS_AVAILABLE != status) { // Should never happen @@ -136,9 +131,6 @@ public final class ActionBatch { // Download it. DebugLogUtils.l("Upgrade word list, downloading", mWordList.mRemoteFilename); - // TODO: if DownloadManager is disabled or not installed, download by ourselves - if (null == manager) return; - // This is an upgraded word list: we should download it. // Adding a disambiguator to circumvent a bug in older versions of DownloadManager. // DownloadManager also stupidly cuts the extension to replace with its own that it @@ -293,13 +285,8 @@ public final class ActionBatch { } // The word list is still downloading. Cancel the download and revert the // word list status to "available". - final DownloadManager manager = - (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); - if (null != manager) { - // If we can't cancel the download because DownloadManager is not available, - // we still need to mark the entry as available. - manager.remove(values.getAsLong(MetadataDbHelper.PENDINGID_COLUMN)); - } + final DownloadManagerWrapper manager = new DownloadManagerWrapper(context); + manager.remove(values.getAsLong(MetadataDbHelper.PENDINGID_COLUMN)); MetadataDbHelper.markEntryAsAvailable(db, mWordList.mId, mWordList.mVersion); } } |