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

Commit 3b6149c6 authored by Robert Shih's avatar Robert Shih
Browse files

clearkey aidl: misc fixes

* accept default arguments in isCryptoSchemeSupported
* correctly concat secure stop id & data in getSecureStop(s)
* always return SW_SECURE_CRYPTO in getSecurityLevel
* SessionLibrary NO need to inherit RefBase
* compiler bug 215440148 workaround

Bug: 206804036
Test: atest MediaDrmClearkeyTest
Change-Id: I4952fcf4f8a2bfd5ddf6812257a310fec7bca52b
parent 4de601f8
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -72,7 +72,8 @@ using ::aidl::android::hardware::drm::Uuid;
    // This should match the in_mimeTypes handed by InitDataParser.
    *_aidl_return = in_mimeType == kIsoBmffVideoMimeType || in_mimeType == kIsoBmffAudioMimeType ||
                    in_mimeType == kCencInitDataFormat || in_mimeType == kWebmVideoMimeType ||
                    in_mimeType == kWebmAudioMimeType || in_mimeType == kWebmInitDataFormat;
                    in_mimeType == kWebmAudioMimeType || in_mimeType == kWebmInitDataFormat ||
                    in_mimeType.empty();
    return ::ndk::ScopedAStatus::ok();
}

@@ -85,7 +86,9 @@ using ::aidl::android::hardware::drm::Uuid;
        ALOGD("%s mime type is not supported by crypto scheme", in_mimeType.c_str());
    }
    *_aidl_return = isClearKeyUUID(in_uuid.uuid.data()) && isSupportedMimeType &&
                    in_securityLevel == SecurityLevel::SW_SECURE_CRYPTO;
                    (in_securityLevel == SecurityLevel::SW_SECURE_CRYPTO ||
                     in_securityLevel == SecurityLevel::DEFAULT ||
                     in_securityLevel == SecurityLevel::UNKNOWN);
    return ::ndk::ScopedAStatus::ok();
}

+9 −7
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@
#include <inttypes.h>
#include <stdio.h>
#include <chrono>
#include <set>

#include "AidlUtils.h"
#include "ClearKeyDrmProperties.h"
@@ -188,7 +189,8 @@ void DrmPlugin::installSecureStop(const std::vector<uint8_t>& sessionId) {

    const std::vector<uint8_t> scopeId = in_scope;
    ::android::sp<Session> session;
    if (in_keyType == KeyType::STREAMING || in_keyType == KeyType::OFFLINE) {
    std::set<KeyType> init_types{KeyType::STREAMING, KeyType::OFFLINE};
    if (init_types.count(in_keyType)) {
        std::vector<uint8_t> sessionId(scopeId.begin(), scopeId.end());
        session = mSessionLibrary->findSession(sessionId);
        if (!session.get()) {
@@ -402,8 +404,8 @@ void DrmPlugin::installSecureStop(const std::vector<uint8_t>& sessionId) {
    auto itr = mSecureStops.find(in_secureStopId.secureStopId);
    if (itr != mSecureStops.end()) {
        ClearkeySecureStop clearkeyStop = itr->second;
        stop.assign(clearkeyStop.id.begin(), clearkeyStop.id.end());
        stop.assign(clearkeyStop.data.begin(), clearkeyStop.data.end());
        stop.insert(stop.end(), clearkeyStop.id.begin(), clearkeyStop.id.end());
        stop.insert(stop.end(), clearkeyStop.data.begin(), clearkeyStop.data.end());
    }
    mSecureStopLock.unlock();

@@ -439,9 +441,9 @@ void DrmPlugin::installSecureStop(const std::vector<uint8_t>& sessionId) {
    std::vector<::aidl::android::hardware::drm::SecureStop> stops;
    for (auto itr = mSecureStops.begin(); itr != mSecureStops.end(); ++itr) {
        ClearkeySecureStop clearkeyStop = itr->second;
        std::vector<uint8_t> stop = {};
        stop.assign(clearkeyStop.id.begin(), clearkeyStop.id.end());
        stop.assign(clearkeyStop.data.begin(), clearkeyStop.data.end());
        std::vector<uint8_t> stop{};
        stop.insert(stop.end(), clearkeyStop.id.begin(), clearkeyStop.id.end());
        stop.insert(stop.end(), clearkeyStop.data.begin(), clearkeyStop.data.end());

        SecureStop secureStop;
        secureStop.opaqueData = stop;
@@ -476,7 +478,7 @@ void DrmPlugin::installSecureStop(const std::vector<uint8_t>& sessionId) {
        return toNdkScopedAStatus(Status::ERROR_DRM_INVALID_STATE);
    }

    *_aidl_return = itr->second;
    *_aidl_return = SecurityLevel::SW_SECURE_CRYPTO;
    return toNdkScopedAStatus(Status::OK);
}

+1 −1
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@

namespace clearkeydrm {

class SessionLibrary : public ::android::RefBase {
class SessionLibrary {
  public:
    static SessionLibrary* get();