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
This commit is contained in:
@ -117,7 +117,11 @@ status_t DrmManager::unloadPlugIns() {
|
||||
status_t DrmManager::setDrmServiceListener(
|
||||
int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) {
|
||||
Mutex::Autolock _l(mLock);
|
||||
mServiceListeners.add(uniqueId, drmServiceListener);
|
||||
if (NULL != drmServiceListener.get()) {
|
||||
mServiceListeners.add(uniqueId, drmServiceListener);
|
||||
} else {
|
||||
mServiceListeners.removeItem(uniqueId);
|
||||
}
|
||||
return DRM_NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -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 != 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");
|
||||
}
|
||||
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);
|
||||
cursor.close();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Given Uri scheme is not supported");
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ DrmManagerClient::DrmManagerClient():
|
||||
DrmManagerClient::~DrmManagerClient() {
|
||||
DrmManagerClientImpl::remove(mUniqueId);
|
||||
mDrmManagerClientImpl->removeClient(mUniqueId);
|
||||
mDrmManagerClientImpl->setOnInfoListener(mUniqueId, NULL);
|
||||
delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,8 @@ status_t DrmManagerClientImpl::setOnInfoListener(
|
||||
int uniqueId, const sp<DrmManagerClient::OnInfoListener>& infoListener) {
|
||||
Mutex::Autolock _l(mLock);
|
||||
mOnInfoListener = infoListener;
|
||||
return getDrmManagerService()->setDrmServiceListener(uniqueId, this);
|
||||
return getDrmManagerService()->setDrmServiceListener(uniqueId,
|
||||
(NULL != infoListener.get()) ? this : NULL);
|
||||
}
|
||||
|
||||
status_t DrmManagerClientImpl::installDrmEngine(int uniqueId, const String8& drmEngineFile) {
|
||||
|
@ -48,6 +48,9 @@ public:
|
||||
public:
|
||||
class OnInfoListener: virtual public RefBase {
|
||||
|
||||
public:
|
||||
virtual ~OnInfoListener() {}
|
||||
|
||||
public:
|
||||
virtual void onInfo(const DrmInfoEvent& event) = 0;
|
||||
};
|
||||
|
Reference in New Issue
Block a user