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

Commit 899f7721 authored by Jeff Tinker's avatar Jeff Tinker Committed by Android (Google) Code Review
Browse files

Merge "Prevent findSession from creating new sessions"

parents e424bc24 d76b8b58
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -39,9 +39,10 @@ status_t DrmPlugin::closeSession(const Vector<uint8_t>& sessionId) {
    sp<Session> session = mSessionLibrary->findSession(sessionId);
    if (session.get()) {
        mSessionLibrary->destroySession(session);
    }
        return android::OK;
    }
    return android::ERROR_DRM_SESSION_NOT_OPENED;
}

status_t DrmPlugin::getKeyRequest(
        const Vector<uint8_t>& scope,
+5 −2
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ SessionLibrary* SessionLibrary::get() {
    return sSingleton;
}

const sp<Session>& SessionLibrary::createSession() {
sp<Session> SessionLibrary::createSession() {
    Mutex::Autolock lock(mSessionsLock);

    String8 sessionIdString = String8::format("%u", mNextSessionId);
@@ -57,9 +57,12 @@ const sp<Session>& SessionLibrary::createSession() {
    return mSessions.valueFor(sessionId);
}

const sp<Session>& SessionLibrary::findSession(
sp<Session> SessionLibrary::findSession(
        const Vector<uint8_t>& sessionId) {
    Mutex::Autolock lock(mSessionsLock);
    if (mSessions.indexOfKey(sessionId) < 0) {
        return sp<Session>(NULL);
    }
    return mSessions.valueFor(sessionId);
}

+3 −3
Original line number Diff line number Diff line
@@ -31,9 +31,9 @@ class SessionLibrary {
public:
    static SessionLibrary* get();

    const android::sp<Session>& createSession();
    android::sp<Session> createSession();

    const android::sp<Session>& findSession(
    android::sp<Session> findSession(
            const android::Vector<uint8_t>& sessionId);

    void destroySession(const android::sp<Session>& session);
@@ -48,7 +48,7 @@ private:

    android::Mutex mSessionsLock;
    uint32_t mNextSessionId;
    android::DefaultKeyedVector<android::Vector<uint8_t>, android::sp<Session> >
    android::KeyedVector<android::Vector<uint8_t>, android::sp<Session> >
            mSessions;
};