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

Commit d162af25 authored by Robert Shih's avatar Robert Shih Committed by Android (Google) Code Review
Browse files

Merge "libmediadrm: cleanup exception log spam" into sc-dev

parents 867ce902 54e1d21e
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -338,7 +338,7 @@ void DrmHal::cleanup() {
}
}


std::vector<sp<IDrmFactory>> DrmHal::makeDrmFactories() {
std::vector<sp<IDrmFactory>> DrmHal::makeDrmFactories() {
    std::vector<sp<IDrmFactory>> factories(DrmUtils::MakeDrmFactories());
    static std::vector<sp<IDrmFactory>> factories(DrmUtils::MakeDrmFactories());
    if (factories.size() == 0) {
    if (factories.size() == 0) {
        // must be in passthrough mode, load the default passthrough service
        // must be in passthrough mode, load the default passthrough service
        auto passthrough = IDrmFactory::getService();
        auto passthrough = IDrmFactory::getService();
+21 −8
Original line number Original line Diff line number Diff line
@@ -43,6 +43,9 @@
#include <mediadrm/ICrypto.h>
#include <mediadrm/ICrypto.h>
#include <mediadrm/IDrm.h>
#include <mediadrm/IDrm.h>


#include <map>
#include <string>

using HServiceManager = ::android::hidl::manager::V1_2::IServiceManager;
using HServiceManager = ::android::hidl::manager::V1_2::IServiceManager;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_string;
@@ -66,8 +69,8 @@ Hal *MakeObject(status_t *pstatus) {
    return obj;
    return obj;
}
}


template <typename Hal, typename V>
template <typename Hal, typename V, typename M>
void MakeHidlFactories(const uint8_t uuid[16], V &factories) {
void MakeHidlFactories(const uint8_t uuid[16], V &factories, M& instances) {
    sp<HServiceManager> serviceManager = HServiceManager::getService();
    sp<HServiceManager> serviceManager = HServiceManager::getService();
    if (serviceManager == nullptr) {
    if (serviceManager == nullptr) {
        LOG2BE("Failed to get service manager");
        LOG2BE("Failed to get service manager");
@@ -78,7 +81,7 @@ void MakeHidlFactories(const uint8_t uuid[16], V &factories) {
        for (const auto &instance : registered) {
        for (const auto &instance : registered) {
            auto factory = Hal::getService(instance);
            auto factory = Hal::getService(instance);
            if (factory != nullptr) {
            if (factory != nullptr) {
                LOG2BI("found %s %s", Hal::descriptor, instance.c_str());
                instances[instance.c_str()] = Hal::descriptor;
                if (!uuid || factory->isCryptoSchemeSupported(uuid)) {
                if (!uuid || factory->isCryptoSchemeSupported(uuid)) {
                    factories.push_back(factory);
                    factories.push_back(factory);
                }
                }
@@ -87,6 +90,12 @@ void MakeHidlFactories(const uint8_t uuid[16], V &factories) {
    });
    });
}
}


template <typename Hal, typename V>
void MakeHidlFactories(const uint8_t uuid[16], V &factories) {
    std::map<std::string, std::string> instances;
    MakeHidlFactories<Hal>(uuid, factories, instances);
}

hidl_vec<uint8_t> toHidlVec(const void *ptr, size_t size) {
hidl_vec<uint8_t> toHidlVec(const void *ptr, size_t size) {
    hidl_vec<uint8_t> vec(size);
    hidl_vec<uint8_t> vec(size);
    if (ptr != nullptr) {
    if (ptr != nullptr) {
@@ -147,11 +156,15 @@ sp<ICrypto> MakeCrypto(status_t *pstatus) {


std::vector<sp<::V1_0::IDrmFactory>> MakeDrmFactories(const uint8_t uuid[16]) {
std::vector<sp<::V1_0::IDrmFactory>> MakeDrmFactories(const uint8_t uuid[16]) {
    std::vector<sp<::V1_0::IDrmFactory>> drmFactories;
    std::vector<sp<::V1_0::IDrmFactory>> drmFactories;
    MakeHidlFactories<::V1_0::IDrmFactory>(uuid, drmFactories);
    std::map<std::string, std::string> instances;
    MakeHidlFactories<::V1_1::IDrmFactory>(uuid, drmFactories);
    MakeHidlFactories<::V1_0::IDrmFactory>(uuid, drmFactories, instances);
    MakeHidlFactories<::V1_2::IDrmFactory>(uuid, drmFactories);
    MakeHidlFactories<::V1_1::IDrmFactory>(uuid, drmFactories, instances);
    MakeHidlFactories<::V1_3::IDrmFactory>(uuid, drmFactories);
    MakeHidlFactories<::V1_2::IDrmFactory>(uuid, drmFactories, instances);
    MakeHidlFactories<::V1_4::IDrmFactory>(uuid, drmFactories);
    MakeHidlFactories<::V1_3::IDrmFactory>(uuid, drmFactories, instances);
    MakeHidlFactories<::V1_4::IDrmFactory>(uuid, drmFactories, instances);
    for (auto const& entry : instances) {
        LOG2BI("found instance=%s version=%s", entry.first.c_str(), entry.second.c_str());
    }
    return drmFactories;
    return drmFactories;
}
}