()
| 218 | boolean success); |
| 219 | |
| 220 | void checkComplete() { |
| 221 | DownloadManager.Query query = new DownloadManager.Query(); |
| 222 | query.setFilterByStatus(DownloadManager.STATUS_FAILED | |
| 223 | DownloadManager.STATUS_SUCCESSFUL); |
| 224 | Cursor c; |
| 225 | |
| 226 | try { |
| 227 | c = dm.query(query); |
| 228 | } catch (Exception e) { |
| 229 | /* should not happen, but an SQLiteException has crashed XCSoar |
| 230 | on a Wiko Robby with Android 6.0 */ |
| 231 | return; |
| 232 | } |
| 233 | |
| 234 | if (c == null) |
| 235 | /* should not happen, but has been observed on Android 2.3 */ |
| 236 | return; |
| 237 | |
| 238 | if (!c.moveToFirst()) |
| 239 | return; |
| 240 | |
| 241 | final int columnLocalURI = |
| 242 | c.getColumnIndexOrThrow(DownloadManager.COLUMN_LOCAL_URI); |
| 243 | final int columnId = c.getColumnIndexOrThrow(DownloadManager.COLUMN_ID); |
| 244 | final int columnStatus = |
| 245 | c.getColumnIndexOrThrow(DownloadManager.COLUMN_STATUS); |
| 246 | |
| 247 | do { |
| 248 | final String uri = c.getString(columnLocalURI); |
| 249 | final String tmpPath = matchPath(uri); |
| 250 | if (tmpPath == null) |
| 251 | continue; |
| 252 | |
| 253 | final int status = c.getInt(columnStatus); |
| 254 | final boolean success = status == DownloadManager.STATUS_SUCCESSFUL; |
| 255 | onDownloadComplete(ptr, tmpPath, toFinalPath(tmpPath), success); |
| 256 | |
| 257 | final long id = c.getLong(columnId); |
| 258 | dm.remove(id); |
| 259 | } while (c.moveToNext()); |
| 260 | } |
| 261 | |
| 262 | @Override public void onReceive(Context context, Intent intent) { |
| 263 | if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(intent.getAction())) { |
no test coverage detected