From f05913aaa0cc96eab32be3431de1a80d405527a1 Mon Sep 17 00:00:00 2001 From: Takeshi Aimi Date: Tue, 30 Nov 2010 16:27:42 +0900 Subject: DRM Framework bug fixes. - Make sure to clean-up obsolete listeners. - Close cursor after using it. - Add virtual destructor to the base class of OnInfoListener. Changes are made by SEMC and Sony. Change-Id: Ibb6dd625ef48e3597188f0d7c90f9d4c780b6139 --- drm/java/android/drm/DrmManagerClient.java | 46 ++++++++++++++++++------------ 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'drm/java') diff --git a/drm/java/android/drm/DrmManagerClient.java b/drm/java/android/drm/DrmManagerClient.java index 2f54b3393df9..6caf678d8558 100644 --- a/drm/java/android/drm/DrmManagerClient.java +++ b/drm/java/android/drm/DrmManagerClient.java @@ -738,26 +738,34 @@ public class DrmManagerClient { */ private String convertUriToPath(Uri uri) { String path = null; - String scheme = uri.getScheme(); - if (null == scheme || scheme.equals("") || scheme.equals(ContentResolver.SCHEME_FILE)) { - path = uri.getPath(); - } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { - String[] projection = new String[] {MediaStore.MediaColumns.DATA}; - Cursor cursor = null; - try { - cursor = mContext.getContentResolver().query(uri, projection, null, null, null); - } catch (SQLiteException e) { - throw new IllegalArgumentException("Given Uri is not formatted in a way " + - "so that it can be found in media store."); - } - if (null == cursor || 0 == cursor.getCount() || !cursor.moveToFirst()) { - throw new IllegalArgumentException("Given Uri could not be found in media store"); + if (null != uri) { + String scheme = uri.getScheme(); + if (null == scheme || scheme.equals("") || + scheme.equals(ContentResolver.SCHEME_FILE)) { + path = uri.getPath(); + } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { + String[] projection = new String[] {MediaStore.MediaColumns.DATA}; + Cursor cursor = null; + try { + cursor = mContext.getContentResolver().query(uri, projection, null, + null, null); + if (null == cursor || 0 == cursor.getCount() || !cursor.moveToFirst()) { + throw new IllegalArgumentException("Given Uri could not be found" + + " in media store"); + } + int pathIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA); + path = cursor.getString(pathIndex); + } catch (SQLiteException e) { + throw new IllegalArgumentException("Given Uri is not formatted in a way " + + "so that it can be found in media store."); + } finally { + if (null != cursor) { + cursor.close(); + } + } + } else { + throw new IllegalArgumentException("Given Uri scheme is not supported"); } - int pathIndex = cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA); - path = cursor.getString(pathIndex); - cursor.close(); - } else { - throw new IllegalArgumentException("Given Uri scheme is not supported"); } return path; } -- cgit v1.2.3-59-g8ed1b