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

Commit 5f5e43fa authored by Tobias Thierer's avatar Tobias Thierer
Browse files

Revert "Fix MediaDrm security level APIs"

This reverts commit 56134cc9.

Reason for revert: Build cop here. The CL topic that I'm reverting broke several builds: Drm.h's openSession(Vector<uint8_t> &sessionId) hides overloaded virtual function openSession(DrmPlugin::SecurityLevel securityLevel, ..) from IDrm.h.

https://android-build.googleplex.com/builds/submitted/4598692/full-eng/latest/view/logs/build_error.log

Change-Id: I0de7738748ab793249df68bcbf18232d6a2d120a
parent 56134cc9
Loading
Loading
Loading
Loading
+45 −47
Original line number Diff line number Diff line
@@ -510,54 +510,17 @@ status_t DrmHal::destroyPlugin() {
    return OK;
}

status_t DrmHal::openSession(DrmPlugin::SecurityLevel level,
        Vector<uint8_t> &sessionId) {
status_t DrmHal::openSession(Vector<uint8_t> &sessionId) {
    Mutex::Autolock autoLock(mLock);
    INIT_CHECK();

    SecurityLevel hSecurityLevel;
    bool setSecurityLevel = true;

    switch(level) {
    case DrmPlugin::kSecurityLevelSwSecureCrypto:
        hSecurityLevel = SecurityLevel::SW_SECURE_CRYPTO;
        break;
    case DrmPlugin::kSecurityLevelSwSecureDecode:
        hSecurityLevel = SecurityLevel::SW_SECURE_DECODE;
        break;
    case DrmPlugin::kSecurityLevelHwSecureCrypto:
        hSecurityLevel = SecurityLevel::HW_SECURE_CRYPTO;
        break;
    case DrmPlugin::kSecurityLevelHwSecureDecode:
        hSecurityLevel = SecurityLevel::HW_SECURE_DECODE;
        break;
    case DrmPlugin::kSecurityLevelHwSecureAll:
        hSecurityLevel = SecurityLevel::HW_SECURE_ALL;
        break;
    case DrmPlugin::kSecurityLevelMax:
        setSecurityLevel = false;
        break;
    default:
        return ERROR_DRM_CANNOT_HANDLE;
    }

    status_t  err = UNKNOWN_ERROR;

    bool retry = true;
    do {
        hidl_vec<uint8_t> hSessionId;

        Return<void> hResult;
        if (mPluginV1_1 == NULL || !setSecurityLevel) {
            hResult = mPlugin->openSession(
                    [&](Status status,const hidl_vec<uint8_t>& id) {
                        if (status == Status::OK) {
                            sessionId = toVector(id);
                        }
                        err = toStatusT(status);
                    }
                );
        } else {
            hResult = mPluginV1_1->openSession_1_1(hSecurityLevel,
        Return<void> hResult = mPlugin->openSession(
                [&](Status status, const hidl_vec<uint8_t>& id) {
                    if (status == Status::OK) {
                        sessionId = toVector(id);
@@ -565,7 +528,6 @@ status_t DrmHal::openSession(DrmPlugin::SecurityLevel level,
                    err = toStatusT(status);
                }
            );
        }

        if (!hResult.isOk()) {
            err = DEAD_OBJECT;
@@ -1017,6 +979,42 @@ status_t DrmHal::getSecurityLevel(Vector<uint8_t> const &sessionId,
    return hResult.isOk() ? err : DEAD_OBJECT;
}

status_t DrmHal::setSecurityLevel(Vector<uint8_t> const &sessionId,
        const DrmPlugin::SecurityLevel& level) {
    Mutex::Autolock autoLock(mLock);
    INIT_CHECK();

    if (mPluginV1_1 == NULL) {
        return ERROR_DRM_CANNOT_HANDLE;
    }

    SecurityLevel hSecurityLevel;

    switch(level) {
    case DrmPlugin::kSecurityLevelSwSecureCrypto:
        hSecurityLevel = SecurityLevel::SW_SECURE_CRYPTO;
        break;
    case DrmPlugin::kSecurityLevelSwSecureDecode:
        hSecurityLevel = SecurityLevel::SW_SECURE_DECODE;
        break;
    case DrmPlugin::kSecurityLevelHwSecureCrypto:
        hSecurityLevel = SecurityLevel::HW_SECURE_CRYPTO;
        break;
    case DrmPlugin::kSecurityLevelHwSecureDecode:
        hSecurityLevel = SecurityLevel::HW_SECURE_DECODE;
        break;
    case DrmPlugin::kSecurityLevelHwSecureAll:
        hSecurityLevel = SecurityLevel::HW_SECURE_ALL;
        break;
    default:
        return ERROR_DRM_CANNOT_HANDLE;
    }

    Status status = mPluginV1_1->setSecurityLevel(toHidlVec(sessionId),
            hSecurityLevel);
    return toStatusT(status);
}

status_t DrmHal::getPropertyString(String8 const &name, String8 &value ) const {
    Mutex::Autolock autoLock(mLock);
    return getPropertyStringInternal(name, value);
+32 −6
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ enum {
    GET_HDCP_LEVELS,
    GET_NUMBER_OF_SESSIONS,
    GET_SECURITY_LEVEL,
    SET_SECURITY_LEVEL,
    REMOVE_SECURE_STOP,
    GET_SECURE_STOP_IDS
};
@@ -120,11 +121,9 @@ struct BpDrm : public BpInterface<IDrm> {
        return reply.readInt32();
    }

    virtual status_t openSession(DrmPlugin::SecurityLevel securityLevel,
            Vector<uint8_t> &sessionId) {
    virtual status_t openSession(Vector<uint8_t> &sessionId) {
        Parcel data, reply;
        data.writeInterfaceToken(IDrm::getInterfaceDescriptor());
        data.writeInt32(securityLevel);

        status_t status = remote()->transact(OPEN_SESSION, data, &reply);
        if (status != OK) {
@@ -449,6 +448,23 @@ struct BpDrm : public BpInterface<IDrm> {
        return reply.readInt32();
    }

    virtual status_t setSecurityLevel(Vector<uint8_t> const &sessionId,
            const DrmPlugin::SecurityLevel& level) {
        Parcel data, reply;

        data.writeInterfaceToken(IDrm::getInterfaceDescriptor());

        writeVector(data, sessionId);
        data.writeInt32(static_cast<uint32_t>(level));

        status_t status = remote()->transact(SET_SECURITY_LEVEL, data, &reply);
        if (status != OK) {
            return status;
        }

        return reply.readInt32();
    }

    virtual status_t getPropertyByteArray(String8 const &name, Vector<uint8_t> &value) const {
        Parcel data, reply;
        data.writeInterfaceToken(IDrm::getInterfaceDescriptor());
@@ -726,10 +742,8 @@ status_t BnDrm::onTransact(
        case OPEN_SESSION:
        {
            CHECK_INTERFACE(IDrm, data, reply);
            DrmPlugin::SecurityLevel level =
                    static_cast<DrmPlugin::SecurityLevel>(data.readInt32());
            Vector<uint8_t> sessionId;
            status_t result = openSession(level, sessionId);
            status_t result = openSession(sessionId);
            writeVector(reply, sessionId);
            reply->writeInt32(result);
            return OK;
@@ -963,6 +977,18 @@ status_t BnDrm::onTransact(
            return OK;
        }

        case SET_SECURITY_LEVEL:
        {
            CHECK_INTERFACE(IDrm, data, reply);
            Vector<uint8_t> sessionId;
            readVector(data, sessionId);
            DrmPlugin::SecurityLevel level =
                    static_cast<DrmPlugin::SecurityLevel>(data.readInt32());
            status_t result = setSecurityLevel(sessionId, level);
            reply->writeInt32(result);
            return OK;
        }

        case GET_PROPERTY_STRING:
        {
            CHECK_INTERFACE(IDrm, data, reply);
+4 −16
Original line number Diff line number Diff line
@@ -73,24 +73,12 @@ void DrmPlugin::initProperties() {
    mByteArrayProperties[kMetricsKey] = valueVector;
}


Return<void> DrmPlugin::openSession(openSession_cb _hidl_cb) {
    sp<Session> session = mSessionLibrary->createSession();
    std::vector<uint8_t> sessionId = session->sessionId();

    Status status = setSecurityLevel(sessionId, SecurityLevel::SW_SECURE_CRYPTO);
    _hidl_cb(status, toHidlVec(sessionId));
    mOpenSessionOkCount++;
    return Void();
}

Return<void> DrmPlugin::openSession_1_1(SecurityLevel securityLevel,
        openSession_1_1_cb _hidl_cb) {
    sp<Session> session = mSessionLibrary->createSession();
    std::vector<uint8_t> sessionId = session->sessionId();

    Status status = setSecurityLevel(sessionId, securityLevel);
    _hidl_cb(status, toHidlVec(sessionId));
    setSecurityLevel(sessionId, SecurityLevel::SW_SECURE_CRYPTO);
    _hidl_cb(Status::OK, toHidlVec(sessionId));
    mOpenSessionOkCount++;
    return Void();
}
@@ -356,8 +344,8 @@ Return<Status> DrmPlugin::setSecurityLevel(const hidl_vec<uint8_t>& sessionId,
        return Status::BAD_VALUE;
    }

    if (level > SecurityLevel::SW_SECURE_CRYPTO) {
        ALOGE("Cannot set security level > max");
    if (level > SecurityLevel::HW_SECURE_ALL) {
        ALOGE("Cannot set invalid security level");
        return Status::BAD_VALUE;
    }

+3 −5
Original line number Diff line number Diff line
@@ -53,8 +53,6 @@ struct DrmPlugin : public IDrmPlugin {
    virtual ~DrmPlugin() {}

    Return<void> openSession(openSession_cb _hidl_cb) override;
    Return<void> openSession_1_1(SecurityLevel securityLevel,
            openSession_cb _hidl_cb) override;

    Return<Status> closeSession(const hidl_vec<uint8_t>& sessionId) override;

@@ -164,6 +162,9 @@ struct DrmPlugin : public IDrmPlugin {
    Return<void> getSecurityLevel(const hidl_vec<uint8_t>& sessionId,
            getSecurityLevel_cb _hidl_cb) override;

    Return<Status> setSecurityLevel(const hidl_vec<uint8_t>& sessionId,
            SecurityLevel level) override;

    Return<void> getMetrics(getMetrics_cb _hidl_cb) override;

    Return<void> getPropertyString(
@@ -332,9 +333,6 @@ private:
    void initProperties();
    void setPlayPolicy();

    Return<Status> setSecurityLevel(const hidl_vec<uint8_t>& sessionId,
            SecurityLevel level);

    std::vector<KeyValue> mPlayPolicy;
    std::map<std::string, std::string> mStringProperties;
    std::map<std::string, std::vector<uint8_t> > mByteArrayProperties;
+3 −2
Original line number Diff line number Diff line
@@ -63,8 +63,7 @@ struct DrmHal : public BnDrm,

    virtual status_t destroyPlugin();

    virtual status_t openSession(DrmPlugin::SecurityLevel level,
            Vector<uint8_t> &sessionId);
    virtual status_t openSession(Vector<uint8_t> &sessionId);

    virtual status_t closeSession(Vector<uint8_t> const &sessionId);

@@ -111,6 +110,8 @@ struct DrmHal : public BnDrm,
            uint32_t *maxSessions) const;
    virtual status_t getSecurityLevel(Vector<uint8_t> const &sessionId,
            DrmPlugin::SecurityLevel *level) const;
    virtual status_t setSecurityLevel(Vector<uint8_t> const &sessionId,
            const DrmPlugin::SecurityLevel& level);

    virtual status_t getPropertyString(String8 const &name, String8 &value ) const;
    virtual status_t getPropertyByteArray(String8 const &name,
Loading