in my app i'm starting download via DownloadManager:
val downloadId: Long = downloadManager.enqueue(dr)
If user reopenning application, i'm checking downloading status via:
fun isDownloadInProgress(): Boolean {
val dq: DownloadManager.Query = DownloadManager.Query()
dq.setFilterById(downloadId)
val cursor: Cursor? = downloadManager.query(dq)
if (cursor == null || !cursor.moveToFirst()) {
return false
}
val status: Int = cursor.getInt(cursor.getColumnIndex(DownloadManager.COLUMN_STATUS))
if (status == DownloadManager.STATUS_RUNNING || status == DownloadManager.STATUS_PENDING) {
return true
}
return false
}
With this code I have some crashes in my Crashlytics dash on Xiaomi with 11 and 12 Android versions:
Caused by java.lang.IllegalArgumentException: column local_filename is not allowed in queries
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:172)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:142)
at android.content.ContentProviderProxy.query(ContentProviderProxy.java:481)
at android.content.ContentResolver.query(ContentResolver.java:1219)
at android.content.ContentResolver.query(ContentResolver.java:1151)
at android.content.ContentResolver.query(ContentResolver.java:1107)
at android.app.DownloadManager$Query.runQuery(DownloadManager.java:1506)
at android.app.DownloadManager.query(DownloadManager.java:1736)
at android.app.DownloadManager.query(DownloadManager.java:1718)
It throw when i call val cursor: Cursor? = downloadManager.query(dq)
because under the hood query()
method of DownloadManager
calls query(query, UNDERLYING_COLUMNS);
and UNDERLYING_COLUMS
contains DownloadManager.COLUMN_LOCAL_FILENAME
column.
This column is deprecated after API 24, but DownloadManager
is still using this column under the hood.
My questions is:
- If am i using
DownloadManager
incorrect and there is another way for check download status, can someone suggest how to do this? - If is this a bug on Xiaomi ROM, can someone give me the link on issue?
Thanks.