Merge "DRM Framework bug fixes."
This commit is contained in:
@@ -117,7 +117,11 @@ status_t DrmManager::unloadPlugIns() {
|
|||||||
status_t DrmManager::setDrmServiceListener(
|
status_t DrmManager::setDrmServiceListener(
|
||||||
int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) {
|
int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) {
|
||||||
Mutex::Autolock _l(mLock);
|
Mutex::Autolock _l(mLock);
|
||||||
mServiceListeners.add(uniqueId, drmServiceListener);
|
if (NULL != drmServiceListener.get()) {
|
||||||
|
mServiceListeners.add(uniqueId, drmServiceListener);
|
||||||
|
} else {
|
||||||
|
mServiceListeners.removeItem(uniqueId);
|
||||||
|
}
|
||||||
return DRM_NO_ERROR;
|
return DRM_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -738,26 +738,34 @@ public class DrmManagerClient {
|
|||||||
*/
|
*/
|
||||||
private String convertUriToPath(Uri uri) {
|
private String convertUriToPath(Uri uri) {
|
||||||
String path = null;
|
String path = null;
|
||||||
String scheme = uri.getScheme();
|
if (null != uri) {
|
||||||
if (null == scheme || scheme.equals("") || scheme.equals(ContentResolver.SCHEME_FILE)) {
|
String scheme = uri.getScheme();
|
||||||
path = uri.getPath();
|
if (null == scheme || scheme.equals("") ||
|
||||||
} else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
|
scheme.equals(ContentResolver.SCHEME_FILE)) {
|
||||||
String[] projection = new String[] {MediaStore.MediaColumns.DATA};
|
path = uri.getPath();
|
||||||
Cursor cursor = null;
|
} else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {
|
||||||
try {
|
String[] projection = new String[] {MediaStore.MediaColumns.DATA};
|
||||||
cursor = mContext.getContentResolver().query(uri, projection, null, null, null);
|
Cursor cursor = null;
|
||||||
} catch (SQLiteException e) {
|
try {
|
||||||
throw new IllegalArgumentException("Given Uri is not formatted in a way " +
|
cursor = mContext.getContentResolver().query(uri, projection, null,
|
||||||
"so that it can be found in media store.");
|
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;
|
return path;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ DrmManagerClient::DrmManagerClient():
|
|||||||
DrmManagerClient::~DrmManagerClient() {
|
DrmManagerClient::~DrmManagerClient() {
|
||||||
DrmManagerClientImpl::remove(mUniqueId);
|
DrmManagerClientImpl::remove(mUniqueId);
|
||||||
mDrmManagerClientImpl->removeClient(mUniqueId);
|
mDrmManagerClientImpl->removeClient(mUniqueId);
|
||||||
|
mDrmManagerClientImpl->setOnInfoListener(mUniqueId, NULL);
|
||||||
delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL;
|
delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ status_t DrmManagerClientImpl::setOnInfoListener(
|
|||||||
int uniqueId, const sp<DrmManagerClient::OnInfoListener>& infoListener) {
|
int uniqueId, const sp<DrmManagerClient::OnInfoListener>& infoListener) {
|
||||||
Mutex::Autolock _l(mLock);
|
Mutex::Autolock _l(mLock);
|
||||||
mOnInfoListener = infoListener;
|
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) {
|
status_t DrmManagerClientImpl::installDrmEngine(int uniqueId, const String8& drmEngineFile) {
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ public:
|
|||||||
public:
|
public:
|
||||||
class OnInfoListener: virtual public RefBase {
|
class OnInfoListener: virtual public RefBase {
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~OnInfoListener() {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void onInfo(const DrmInfoEvent& event) = 0;
|
virtual void onInfo(const DrmInfoEvent& event) = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user