use the stream instead of the cursor data to return its size
Most content providers set up the data size in the cursor that provides the file name, but sound recorder does not. Use the stream size instead, which will work with all sources and probably is no slower. fixes http://b/2529352 http://b/2524574 Change-Id: I32d101d07ca1d0fa2ff17c3c68393356902096d3
This commit is contained in:
@@ -527,20 +527,12 @@ class BrowserFrame extends Handler {
|
||||
*/
|
||||
private int getFileSize(String uri) {
|
||||
int size = 0;
|
||||
Cursor cursor = mContext.getContentResolver().query(Uri.parse(uri),
|
||||
new String[] { OpenableColumns.SIZE },
|
||||
null,
|
||||
null,
|
||||
null);
|
||||
if (cursor != null) {
|
||||
try {
|
||||
if (cursor.moveToNext()) {
|
||||
size = cursor.getInt(0);
|
||||
}
|
||||
} finally {
|
||||
cursor.close();
|
||||
}
|
||||
}
|
||||
try {
|
||||
InputStream stream = mContext.getContentResolver()
|
||||
.openInputStream(Uri.parse(uri));
|
||||
size = stream.available();
|
||||
stream.close();
|
||||
} catch (Exception e) {}
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user