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 Original line Diff line number Diff line
@@ -39,9 +39,10 @@ status_t DrmPlugin::closeSession(const Vector<uint8_t>& sessionId) {
    sp<Session> session = mSessionLibrary->findSession(sessionId);
    sp<Session> session = mSessionLibrary->findSession(sessionId);
    if (session.get()) {
    if (session.get()) {
        mSessionLibrary->destroySession(session);
        mSessionLibrary->destroySession(session);
    }
        return android::OK;
        return android::OK;
    }
    }
    return android::ERROR_DRM_SESSION_NOT_OPENED;
}


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


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


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


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


+3 −3
Original line number Original line Diff line number Diff line
@@ -31,9 +31,9 @@ class SessionLibrary {
public:
public:
    static SessionLibrary* get();
    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);
            const android::Vector<uint8_t>& sessionId);


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


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