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

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

Merge "IMediaDrmService: remove makeDrm method"

parents f66d414f 6571bf6f
Loading
Loading
Loading
Loading
+6 −34
Original line number Original line Diff line number Diff line
@@ -27,8 +27,6 @@
#include <utils/Errors.h>
#include <utils/Errors.h>
#include <utils/Log.h>
#include <utils/Log.h>
#include <utils/String16.h>
#include <utils/String16.h>
#include <binder/IInterface.h>
#include <binder/IServiceManager.h>
#include <cutils/properties.h>
#include <cutils/properties.h>


#include <mediadrm/CryptoHal.h>
#include <mediadrm/CryptoHal.h>
@@ -36,7 +34,6 @@
#include <mediadrm/DrmUtils.h>
#include <mediadrm/DrmUtils.h>
#include <mediadrm/ICrypto.h>
#include <mediadrm/ICrypto.h>
#include <mediadrm/IDrm.h>
#include <mediadrm/IDrm.h>
#include <mediadrm/IMediaDrmService.h>


using HServiceManager = ::android::hidl::manager::V1_0::IServiceManager;
using HServiceManager = ::android::hidl::manager::V1_0::IServiceManager;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_array;
@@ -48,25 +45,12 @@ namespace android {
namespace DrmUtils {
namespace DrmUtils {


namespace {
namespace {
template<typename Iface>

sp<Iface> MakeObjectWithService(status_t *pstatus) {
template<typename Hal>
Hal *MakeObject(status_t *pstatus) {
    status_t err = OK;
    status_t err = OK;
    status_t &status = pstatus ? *pstatus : err;
    status_t &status = pstatus ? *pstatus : err;
    sp<IServiceManager> sm = defaultServiceManager();
    auto obj = new Hal();
    sp<IBinder> binder = sm->getService(String16("media.drm"));

    sp<IMediaDrmService> service = interface_cast<IMediaDrmService>(binder);
    if (service == NULL) {
        status = UNKNOWN_ERROR;
        return NULL;
    }

    auto obj = service->makeObject<Iface>();
    if (obj == NULL) {
        status = UNKNOWN_ERROR;
        return NULL;
    }

    status = obj->initCheck();
    status = obj->initCheck();
    if (status != OK && status != NO_INIT) {
    if (status != OK && status != NO_INIT) {
        return NULL;
        return NULL;
@@ -74,15 +58,6 @@ sp<Iface> MakeObjectWithService(status_t *pstatus) {
    return obj;
    return obj;
}
}


template<typename Iface, typename Hal>
sp<Iface> MakeObject(status_t *pstatus) {
    if (UseDrmService()) {
        return MakeObjectWithService<Iface>(pstatus);
    } else {
        return new Hal();
    }
}

template <typename Hal, typename V>
template <typename Hal, typename V>
void MakeCryptoFactories(const uint8_t uuid[16], V &cryptoFactories) {
void MakeCryptoFactories(const uint8_t uuid[16], V &cryptoFactories) {
    sp<HServiceManager> serviceManager = HServiceManager::getService();
    sp<HServiceManager> serviceManager = HServiceManager::getService();
@@ -140,14 +115,11 @@ bool UseDrmService() {
}
}


sp<IDrm> MakeDrm(status_t *pstatus) {
sp<IDrm> MakeDrm(status_t *pstatus) {
    return MakeObject<IDrm, DrmHal>(pstatus);
    return MakeObject<DrmHal>(pstatus);
}
}


sp<ICrypto> MakeCrypto(status_t *pstatus) {
sp<ICrypto> MakeCrypto(status_t *pstatus) {
    if (pstatus) {
    return MakeObject<CryptoHal>(pstatus);
        *pstatus = OK;
    }
    return new CryptoHal();
}
}


std::vector<sp<::V1_0::ICryptoFactory>> MakeCryptoFactories(const uint8_t uuid[16]) {
std::vector<sp<::V1_0::ICryptoFactory>> MakeCryptoFactories(const uint8_t uuid[16]) {
+0 −23
Original line number Original line Diff line number Diff line
@@ -29,11 +29,6 @@


namespace android {
namespace android {


enum {
    MAKE_CRYPTO = IBinder::FIRST_CALL_TRANSACTION,
    MAKE_DRM,
};

class BpMediaDrmService: public BpInterface<IMediaDrmService>
class BpMediaDrmService: public BpInterface<IMediaDrmService>
{
{
public:
public:
@@ -42,13 +37,6 @@ public:
    {
    {
    }
    }


    virtual sp<IDrm> makeDrm() {
        Parcel data, reply;
        data.writeInterfaceToken(IMediaDrmService::getInterfaceDescriptor());
        remote()->transact(MAKE_DRM, data, &reply);
        return interface_cast<IDrm>(reply.readStrongBinder());
    }

};
};


IMPLEMENT_META_INTERFACE(MediaDrmService, "android.media.IMediaDrmService");
IMPLEMENT_META_INTERFACE(MediaDrmService, "android.media.IMediaDrmService");
@@ -59,12 +47,6 @@ status_t BnMediaDrmService::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
{
    switch (code) {
    switch (code) {
        case MAKE_DRM: {
            CHECK_INTERFACE(IMediaDrmService, data, reply);
            sp<IDrm> drm = makeDrm();
            reply->writeStrongBinder(IInterface::asBinder(drm));
            return NO_ERROR;
        } break;
        default:
        default:
            return BBinder::onTransact(code, data, reply, flags);
            return BBinder::onTransact(code, data, reply, flags);
    }
    }
@@ -72,9 +54,4 @@ status_t BnMediaDrmService::onTransact(


// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------


template<>
sp<IDrm> IMediaDrmService::makeObject<IDrm>() {
    return makeDrm();
}

} // namespace android
} // namespace android
+0 −4
Original line number Original line Diff line number Diff line
@@ -32,10 +32,6 @@ class IMediaDrmService: public IInterface
public:
public:
    DECLARE_META_INTERFACE(MediaDrmService);
    DECLARE_META_INTERFACE(MediaDrmService);


    virtual sp<IDrm>            makeDrm() = 0;

    template<typename I> sp<I>  makeObject();

};
};


// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
+0 −1
Original line number Original line Diff line number Diff line
@@ -35,7 +35,6 @@
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MediaErrors.h>
#include <binder/IServiceManager.h>
#include <binder/IServiceManager.h>
#include <media/NdkMediaCrypto.h>
#include <media/NdkMediaCrypto.h>
#include <mediadrm/IMediaDrmService.h>




using namespace android;
using namespace android;
+0 −4
Original line number Original line Diff line number Diff line
@@ -34,8 +34,4 @@ void MediaDrmService::instantiate() {
            String16("media.drm"), new MediaDrmService());
            String16("media.drm"), new MediaDrmService());
}
}


sp<IDrm> MediaDrmService::makeDrm() {
    return new DrmHal;
}

} // namespace android
} // namespace android
Loading