diff options
author | Bjorn Bringert <bringert@android.com> | 2009-06-02 16:59:54 +0100 |
---|---|---|
committer | Bjorn Bringert <bringert@android.com> | 2009-06-03 13:01:24 +0100 |
commit | 33a22dc9c84ef12006b0c12f6d169d2a74c15284 (patch) | |
tree | 7be4b1a9ef0f32c327a902dcd5236cdd750830e3 /core | |
parent | c1823701cc76790494fb622fe58f0942236cd7d0 (diff) | |
download | frameworks_base-33a22dc9c84ef12006b0c12f6d169d2a74c15284.zip frameworks_base-33a22dc9c84ef12006b0c12f6d169d2a74c15284.tar.gz frameworks_base-33a22dc9c84ef12006b0c12f6d169d2a74c15284.tar.bz2 |
Close icon input stream in SuggestionsAdapter.
Before, SuggestionsAdapter would not close input streams after
reading icons from them. This leaks file descriptors and,
in the case of MemoryFiles, virtual address space.
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/SuggestionsAdapter.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/core/java/android/app/SuggestionsAdapter.java b/core/java/android/app/SuggestionsAdapter.java index 451697a..747bec9 100644 --- a/core/java/android/app/SuggestionsAdapter.java +++ b/core/java/android/app/SuggestionsAdapter.java @@ -32,12 +32,13 @@ import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.ViewGroup; -import android.widget.CursorAdapter; import android.widget.ImageView; import android.widget.ResourceCursorAdapter; import android.widget.TextView; import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; import java.util.WeakHashMap; /** @@ -376,9 +377,18 @@ class SuggestionsAdapter extends ResourceCursorAdapter { // Let the ContentResolver handle content, android.resource and file URIs. try { Uri uri = Uri.parse(drawableId); - drawable = Drawable.createFromStream( - mProviderContext.getContentResolver().openInputStream(uri), - null); + InputStream stream = mProviderContext.getContentResolver().openInputStream(uri); + if (stream != null) { + try { + drawable = Drawable.createFromStream(stream, null); + } finally { + try { + stream.close(); + } catch (IOException ex) { + Log.e(LOG_TAG, "Error closing icon stream for " + uri, ex); + } + } + } if (DBG) Log.d(LOG_TAG, "Opened icon input stream: " + drawableId); } catch (FileNotFoundException fnfe) { if (DBG) Log.d(LOG_TAG, "Icon stream not found: " + drawableId); |