summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2010-03-22 10:56:37 -0400
committerCary Clark <cary@android.com>2010-03-22 11:12:46 -0400
commitac96fa575f17d4a65e65eddebe805c904fb29c19 (patch)
tree54c2482cfb7f3f96681622c927ed0b175bbf49f7
parentfb0de34a47a435b57075d7a72cbc40a2daf5ee6c (diff)
downloadframeworks_base-ac96fa575f17d4a65e65eddebe805c904fb29c19.zip
frameworks_base-ac96fa575f17d4a65e65eddebe805c904fb29c19.tar.gz
frameworks_base-ac96fa575f17d4a65e65eddebe805c904fb29c19.tar.bz2
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
-rw-r--r--core/java/android/webkit/BrowserFrame.java20
1 files changed, 6 insertions, 14 deletions
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index dae9187..344b390 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -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;
}