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

Commit 6571bf6f authored by Robert Shih's avatar Robert Shih
Browse files

IMediaDrmService: remove makeDrm method

This means IDrm will always be local.

Bug: 134787536
Test: GtsMediaTestCases
Change-Id: I291cca47b97c3f5da40e750bd339693268b46ba0
parent e62c35eb
Loading
Loading
Loading
Loading
+6 −34
Original line number Diff line number Diff line
@@ -27,8 +27,6 @@
#include <utils/Errors.h>
#include <utils/Log.h>
#include <utils/String16.h>
#include <binder/IInterface.h>
#include <binder/IServiceManager.h>
#include <cutils/properties.h>

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

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

namespace {
template<typename Iface>
sp<Iface> MakeObjectWithService(status_t *pstatus) {

template<typename Hal>
Hal *MakeObject(status_t *pstatus) {
    status_t err = OK;
    status_t &status = pstatus ? *pstatus : err;
    sp<IServiceManager> sm = defaultServiceManager();
    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;
    }

    auto obj = new Hal();
    status = obj->initCheck();
    if (status != OK && status != NO_INIT) {
        return NULL;
@@ -74,15 +58,6 @@ sp<Iface> MakeObjectWithService(status_t *pstatus) {
    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>
void MakeCryptoFactories(const uint8_t uuid[16], V &cryptoFactories) {
    sp<HServiceManager> serviceManager = HServiceManager::getService();
@@ -140,14 +115,11 @@ bool UseDrmService() {
}

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

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

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

namespace android {

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

class BpMediaDrmService: public BpInterface<IMediaDrmService>
{
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");
@@ -59,12 +47,6 @@ status_t BnMediaDrmService::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch (code) {
        case MAKE_DRM: {
            CHECK_INTERFACE(IMediaDrmService, data, reply);
            sp<IDrm> drm = makeDrm();
            reply->writeStrongBinder(IInterface::asBinder(drm));
            return NO_ERROR;
        } break;
        default:
            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
+0 −4
Original line number Diff line number Diff line
@@ -32,10 +32,6 @@ class IMediaDrmService: public IInterface
public:
    DECLARE_META_INTERFACE(MediaDrmService);

    virtual sp<IDrm>            makeDrm() = 0;

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

};

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


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

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

} // namespace android
Loading