Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f05913aa authored by Takeshi Aimi's avatar Takeshi Aimi
Browse files

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
parent f0f6c54b
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -117,7 +117,11 @@ status_t DrmManager::unloadPlugIns() {
status_t DrmManager::setDrmServiceListener(
            int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) {
    Mutex::Autolock _l(mLock);
    if (NULL != drmServiceListener.get()) {
        mServiceListeners.add(uniqueId, drmServiceListener);
    } else {
        mServiceListeners.removeItem(uniqueId);
    }
    return DRM_NO_ERROR;
}

+27 −19
Original line number Diff line number Diff line
@@ -738,27 +738,35 @@ public class DrmManagerClient {
     */
    private String convertUriToPath(Uri uri) {
        String path = null;
        if (null != uri) {
            String scheme = uri.getScheme();
        if (null == scheme || scheme.equals("") || scheme.equals(ContentResolver.SCHEME_FILE)) {
            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.");
            }
                    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");
                        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");
            }
        }
        return path;
    }

+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ DrmManagerClient::DrmManagerClient():
DrmManagerClient::~DrmManagerClient() {
    DrmManagerClientImpl::remove(mUniqueId);
    mDrmManagerClientImpl->removeClient(mUniqueId);
    mDrmManagerClientImpl->setOnInfoListener(mUniqueId, NULL);
    delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL;
}

+2 −1
Original line number Diff line number Diff line
@@ -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) {
+3 −0
Original line number Diff line number Diff line
@@ -48,6 +48,9 @@ public:
public:
    class OnInfoListener: virtual public RefBase {

    public:
        virtual ~OnInfoListener() {}

    public:
        virtual void onInfo(const DrmInfoEvent& event) = 0;
    };