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

Commit 9d2f386d authored by James Dong's avatar James Dong
Browse files

Separate sniffing from session initialization

This avoid lengthy/duplicate sniffing for drm plugins when a decrypt session is opened

o The change is backward compatibile in that no update is required
  for existing drm plug-ins if they do not plan to provide separate
  sniffer/extractor

related-to-bug: 5725548

Change-Id: I7fc4caf82d77472da4e2bc7b5d31060fb54fd84c
parent 83bc7f3c
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -120,14 +120,24 @@ DrmSupportInfo* DrmEngineBase::getSupportInfo(int uniqueId) {
}

status_t DrmEngineBase::openDecryptSession(
    int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) {
    int uniqueId, DecryptHandle* decryptHandle,
    int fd, off64_t offset, off64_t length, const char* mime) {

    if (!mime || mime[0] == '\0') {
        return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length);
    }

    return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length, mime);
}

status_t DrmEngineBase::openDecryptSession(
    int uniqueId, DecryptHandle* decryptHandle, const char* uri) {
    int uniqueId, DecryptHandle* decryptHandle,
    const char* uri, const char* mime) {
    if (!mime || mime[0] == '\0') {
        return onOpenDecryptSession(uniqueId, decryptHandle, uri);
    }
    return onOpenDecryptSession(uniqueId, decryptHandle, uri, mime);
}

status_t DrmEngineBase::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) {
    return onCloseDecryptSession(uniqueId, decryptHandle);
+20 −5
Original line number Diff line number Diff line
@@ -600,7 +600,7 @@ status_t BpDrmManagerService::getAllSupportInfo(
}

DecryptHandle* BpDrmManagerService::openDecryptSession(
            int uniqueId, int fd, off64_t offset, off64_t length) {
            int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) {
    ALOGV("Entering BpDrmManagerService::openDecryptSession");
    Parcel data, reply;

@@ -609,6 +609,11 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(
    data.writeFileDescriptor(fd);
    data.writeInt64(offset);
    data.writeInt64(length);
    String8 mimeType;
    if (mime) {
        mimeType = mime;
    }
    data.writeString8(mimeType);

    remote()->transact(OPEN_DECRYPT_SESSION, data, &reply);

@@ -620,13 +625,20 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(
    return handle;
}

DecryptHandle* BpDrmManagerService::openDecryptSession(int uniqueId, const char* uri) {
    ALOGV("Entering BpDrmManagerService::openDecryptSession");
DecryptHandle* BpDrmManagerService::openDecryptSession(
        int uniqueId, const char* uri, const char* mime) {

    ALOGV("Entering BpDrmManagerService::openDecryptSession: mime=%s", mime? mime: "NULL");
    Parcel data, reply;

    data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
    data.writeInt32(uniqueId);
    data.writeString8(String8(uri));
    String8 mimeType;
    if (mime) {
        mimeType = mime;
    }
    data.writeString8(mimeType);

    remote()->transact(OPEN_DECRYPT_SESSION_FROM_URI, data, &reply);

@@ -1265,8 +1277,10 @@ status_t BnDrmManagerService::onTransact(

        const off64_t offset = data.readInt64();
        const off64_t length = data.readInt64();
        const String8 mime = data.readString8();

        DecryptHandle* handle
            = openDecryptSession(uniqueId, fd, offset, length);
            = openDecryptSession(uniqueId, fd, offset, length, mime.string());

        if (NULL != handle) {
            writeDecryptHandleToParcelData(handle, reply);
@@ -1283,8 +1297,9 @@ status_t BnDrmManagerService::onTransact(

        const int uniqueId = data.readInt32();
        const String8 uri = data.readString8();
        const String8 mime = data.readString8();

        DecryptHandle* handle = openDecryptSession(uniqueId, uri.string());
        DecryptHandle* handle = openDecryptSession(uniqueId, uri.string(), mime.string());

        if (NULL != handle) {
            writeDecryptHandleToParcelData(handle, reply);
+7 −4
Original line number Diff line number Diff line
@@ -426,7 +426,9 @@ status_t DrmManager::getAllSupportInfo(
    return DRM_NO_ERROR;
}

DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length) {
DecryptHandle* DrmManager::openDecryptSession(
        int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) {

    Mutex::Autolock _l(mDecryptLock);
    status_t result = DRM_ERROR_CANNOT_HANDLE;
    Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
@@ -438,7 +440,7 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, off64_t offs
        for (unsigned int index = 0; index < plugInIdList.size(); index++) {
            String8 plugInId = plugInIdList.itemAt(index);
            IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
            result = rDrmEngine.openDecryptSession(uniqueId, handle, fd, offset, length);
            result = rDrmEngine.openDecryptSession(uniqueId, handle, fd, offset, length, mime);

            if (DRM_NO_ERROR == result) {
                ++mDecryptSessionId;
@@ -453,7 +455,8 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, off64_t offs
    return handle;
}

DecryptHandle* DrmManager::openDecryptSession(int uniqueId, const char* uri) {
DecryptHandle* DrmManager::openDecryptSession(
        int uniqueId, const char* uri, const char* mime) {
    Mutex::Autolock _l(mDecryptLock);
    status_t result = DRM_ERROR_CANNOT_HANDLE;
    Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList();
@@ -465,7 +468,7 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, const char* uri) {
        for (unsigned int index = 0; index < plugInIdList.size(); index++) {
            String8 plugInId = plugInIdList.itemAt(index);
            IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
            result = rDrmEngine.openDecryptSession(uniqueId, handle, uri);
            result = rDrmEngine.openDecryptSession(uniqueId, handle, uri, mime);

            if (DRM_NO_ERROR == result) {
                ++mDecryptSessionId;
+4 −4
Original line number Diff line number Diff line
@@ -208,20 +208,20 @@ status_t DrmManagerService::getAllSupportInfo(
}

DecryptHandle* DrmManagerService::openDecryptSession(
            int uniqueId, int fd, off64_t offset, off64_t length) {
            int uniqueId, int fd, off64_t offset, off64_t length, const char* mime) {
    ALOGV("Entering DrmManagerService::openDecryptSession");
    if (isProtectedCallAllowed()) {
        return mDrmManager->openDecryptSession(uniqueId, fd, offset, length);
        return mDrmManager->openDecryptSession(uniqueId, fd, offset, length, mime);
    }

    return NULL;
}

DecryptHandle* DrmManagerService::openDecryptSession(
            int uniqueId, const char* uri) {
            int uniqueId, const char* uri, const char* mime) {
    ALOGV("Entering DrmManagerService::openDecryptSession with uri");
    if (isProtectedCallAllowed()) {
        return mDrmManager->openDecryptSession(uniqueId, uri);
        return mDrmManager->openDecryptSession(uniqueId, uri, mime);
    }

    return NULL;
+10 −4
Original line number Diff line number Diff line
@@ -116,12 +116,18 @@ status_t DrmManagerClient::getAllSupportInfo(int* length, DrmSupportInfo** drmSu
    return mDrmManagerClientImpl->getAllSupportInfo(mUniqueId, length, drmSupportInfoArray);
}

sp<DecryptHandle> DrmManagerClient::openDecryptSession(int fd, off64_t offset, off64_t length) {
    return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length);
sp<DecryptHandle> DrmManagerClient::openDecryptSession(
        int fd, off64_t offset, off64_t length, const char* mime) {

    return mDrmManagerClientImpl->openDecryptSession(
                    mUniqueId, fd, offset, length, mime);
}

sp<DecryptHandle> DrmManagerClient::openDecryptSession(const char* uri) {
    return mDrmManagerClientImpl->openDecryptSession(mUniqueId, uri);
sp<DecryptHandle> DrmManagerClient::openDecryptSession(
        const char* uri, const char* mime) {

    return mDrmManagerClientImpl->openDecryptSession(
                    mUniqueId, uri, mime);
}

status_t DrmManagerClient::closeDecryptSession(sp<DecryptHandle> &decryptHandle) {
Loading