diff options
author | 2014-02-17 16:14:18 +0900 | |
---|---|---|
committer | 2014-02-17 18:49:31 +0900 | |
commit | a149731a6764f259b7d15e05a2f557a3bdd23aab (patch) | |
tree | 9d7c3e538a041e369828e7b24a1e5de491485b3c /java/src/com/android/inputmethod/dictionarypack/DictionaryDownloadProgressBar.java | |
parent | 4197c6f3ab1db7d37bfb5fca05bd7169504f451e (diff) | |
download | latinime-a149731a6764f259b7d15e05a2f557a3bdd23aab.tar.gz latinime-a149731a6764f259b7d15e05a2f557a3bdd23aab.tar.xz latinime-a149731a6764f259b7d15e05a2f557a3bdd23aab.zip |
Catch exceptions we can't do anything about.
This also abstracts away the "package deactivated" case for
simpler and safer code.
Bug: 11072561
Change-Id: Idaaf2ae8d8d5b2c4a15de641bbf2f8c5c7cc9410
Diffstat (limited to 'java/src/com/android/inputmethod/dictionarypack/DictionaryDownloadProgressBar.java')
-rw-r--r-- | java/src/com/android/inputmethod/dictionarypack/DictionaryDownloadProgressBar.java | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/java/src/com/android/inputmethod/dictionarypack/DictionaryDownloadProgressBar.java b/java/src/com/android/inputmethod/dictionarypack/DictionaryDownloadProgressBar.java index 384ee3e07..2623eff56 100644 --- a/java/src/com/android/inputmethod/dictionarypack/DictionaryDownloadProgressBar.java +++ b/java/src/com/android/inputmethod/dictionarypack/DictionaryDownloadProgressBar.java @@ -107,26 +107,22 @@ public class DictionaryDownloadProgressBar extends ProgressBar { private class UpdaterThread extends Thread { private final static int REPORT_PERIOD = 150; // how often to report progress, in ms - final DownloadManager mDownloadManager; + final DownloadManagerWrapper mDownloadManagerWrapper; final int mId; public UpdaterThread(final Context context, final int id) { super(); - mDownloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); + mDownloadManagerWrapper = new DownloadManagerWrapper(context); mId = id; } @Override public void run() { try { - // It's almost impossible that mDownloadManager is null (it would mean it has been - // disabled between pressing the 'install' button and displaying the progress - // bar), but just in case. - if (null == mDownloadManager) return; final UpdateHelper updateHelper = new UpdateHelper(); final Query query = new Query().setFilterById(mId); int lastProgress = 0; setIndeterminate(true); while (!isInterrupted()) { - final Cursor cursor = mDownloadManager.query(query); + final Cursor cursor = mDownloadManagerWrapper.query(query); if (null == cursor) { // Can't contact DownloadManager: this should never happen. return; |