Loading drm/libmediadrm/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ cc_library_shared { srcs: [ "DrmPluginPath.cpp", "DrmSessionManager.cpp", "IDrmClient.cpp", "IMediaDrmService.cpp", "SharedLibrary.cpp", "DrmHal.cpp", Loading drm/libmediadrm/DrmHal.cpp +0 −11 Original line number Diff line number Diff line Loading @@ -479,12 +479,6 @@ status_t DrmHal::initCheck() const { status_t DrmHal::setListener(const sp<IDrmClient>& listener) { Mutex::Autolock lock(mEventLock); if (mListener != NULL){ IInterface::asBinder(mListener)->unlinkToDeath(this); } if (listener != NULL) { IInterface::asBinder(listener)->linkToDeath(this); } mListener = listener; return NO_ERROR; } Loading Loading @@ -1567,11 +1561,6 @@ status_t DrmHal::signRSA(Vector<uint8_t> const &sessionId, return hResult.isOk() ? err : DEAD_OBJECT; } void DrmHal::binderDied(const wp<IBinder> &the_late_who __unused) { cleanup(); } void DrmHal::reportFrameworkMetrics() const { std::unique_ptr<MediaAnalyticsItem> item(MediaAnalyticsItem::create("mediadrm")); Loading drm/libmediadrm/IDrmClient.cppdeleted 100644 → 0 +0 −181 Original line number Diff line number Diff line /* ** ** Copyright 2013, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ //#define LOG_NDEBUG 0 #define LOG_TAG "IDrmClient" #include <utils/Errors.h> #include <utils/Log.h> #include <utils/RefBase.h> #include <binder/IInterface.h> #include <binder/Parcel.h> #include <hidl/HidlSupport.h> #include <media/IMediaPlayerClient.h> #include <mediadrm/DrmUtils.h> #include <mediadrm/IDrmClient.h> #include <cstddef> #include <cstdint> #include <vector> namespace android { enum { SEND_EVENT = IBinder::FIRST_CALL_TRANSACTION, SEND_EXPIRATION_UPDATE, SEND_KEYS_CHANGE, SEND_SESSION_LOST_STATE, }; namespace { hardware::hidl_vec<uint8_t> ReadByteArray(const Parcel &obj, status_t *err) { int32_t len = obj.readInt32(); hardware::hidl_vec<uint8_t> ret; if (len < 0) { ALOGE("Invalid array len"); *err = BAD_VALUE; return ret; } ret.resize(static_cast<size_t>(len)); *err = obj.read(ret.data(), ret.size()); return ret; } } class BpDrmClient: public BpInterface<IDrmClient> { template <typename F> void notify(uint32_t code, F fillParcel) { Parcel obj, reply; obj.writeInterfaceToken(IDrmClient::getInterfaceDescriptor()); fillParcel(obj); remote()->transact(code, obj, &reply, IBinder::FLAG_ONEWAY); } public: explicit BpDrmClient(const sp<IBinder>& impl) : BpInterface<IDrmClient>(impl) { } virtual void sendEvent( DrmPlugin::EventType eventType, const hardware::hidl_vec<uint8_t> &sessionId, const hardware::hidl_vec<uint8_t> &data) { auto fillParcel = [&] (Parcel &p) { DrmUtils::WriteEventToParcel(p, eventType, sessionId, data); }; notify(SEND_EVENT, fillParcel); } virtual void sendExpirationUpdate( const hardware::hidl_vec<uint8_t> &sessionId, int64_t expiryTimeInMS) { auto fillParcel = [&] (Parcel &p) { DrmUtils::WriteExpirationUpdateToParcel(p, sessionId, expiryTimeInMS); }; notify(SEND_EXPIRATION_UPDATE, fillParcel); } virtual void sendKeysChange( const hardware::hidl_vec<uint8_t> &sessionId, const std::vector<DrmKeyStatus> &keyStatusList, bool hasNewUsableKey) { auto fillParcel = [&] (Parcel &p) { DrmUtils::WriteKeysChange(p, sessionId, keyStatusList, hasNewUsableKey); }; notify(SEND_KEYS_CHANGE, fillParcel); } virtual void sendSessionLostState( const hardware::hidl_vec<uint8_t> &sessionId) { auto fillParcel = [&] (Parcel &p) { DrmUtils::WriteByteArray(p, sessionId); }; notify(SEND_SESSION_LOST_STATE, fillParcel); } }; IMPLEMENT_META_INTERFACE(DrmClient, "android.media.IDrmClient"); // ---------------------------------------------------------------------- status_t BnDrmClient::onTransact( uint32_t code, const Parcel& obj, Parcel* reply, uint32_t flags) { CHECK_INTERFACE(IDrmClient, obj, reply); status_t err = NO_ERROR; hardware::hidl_vec<uint8_t> sessionId(ReadByteArray(obj, &err)); if (err != NO_ERROR) { ALOGE("Failed to read session id, error=%d", err); return err; } switch (code) { case SEND_EVENT: { hardware::hidl_vec<uint8_t> data(ReadByteArray(obj, &err)); int eventType = obj.readInt32(); if (err == NO_ERROR) { sendEvent(static_cast<DrmPlugin::EventType>(eventType), sessionId, data); } return err; } break; case SEND_EXPIRATION_UPDATE: { int64_t expiryTimeInMS = obj.readInt64(); sendExpirationUpdate(sessionId, expiryTimeInMS); return NO_ERROR; } break; case SEND_KEYS_CHANGE: { // ... int32_t n = obj.readInt32(); if (n < 0) { return BAD_VALUE; } std::vector<DrmKeyStatus> keyStatusList; for (int32_t i = 0; i < n; ++i) { hardware::hidl_vec<uint8_t> keyId(ReadByteArray(obj, &err)); if (err != NO_ERROR) { return err; } int32_t type = obj.readInt32(); if (type < 0) { return BAD_VALUE; } keyStatusList.push_back({static_cast<uint32_t>(type), keyId}); } int32_t hasNewUsableKey = obj.readInt32(); sendKeysChange(sessionId, keyStatusList, hasNewUsableKey); return NO_ERROR; } break; case SEND_SESSION_LOST_STATE: { sendSessionLostState(sessionId); return NO_ERROR; } break; default: return BBinder::onTransact(code, obj, reply, flags); } } } // namespace android drm/libmediadrm/include/mediadrm/DrmHal.h +0 −3 Original line number Diff line number Diff line Loading @@ -58,7 +58,6 @@ inline bool operator==(const Vector<uint8_t> &l, const Vector<uint8_t> &r) { } struct DrmHal : public IDrm, public IBinder::DeathRecipient, public IDrmPluginListener_V1_2 { struct DrmSessionClient; Loading Loading @@ -192,8 +191,6 @@ struct DrmHal : public IDrm, Return<void> sendSessionLostState(const hidl_vec<uint8_t>& sessionId); virtual void binderDied(const wp<IBinder> &the_late_who); private: static Mutex mLock; Loading drm/libmediadrm/include/mediadrm/IDrmClient.h +7 −17 Original line number Diff line number Diff line Loading @@ -18,12 +18,8 @@ #define ANDROID_IDRMCLIENT_H #include <utils/RefBase.h> #include <binder/IInterface.h> #include <binder/Parcel.h> #include <media/drm/DrmAPI.h> #include <android/hardware/drm/1.2/types.h> #include <hidl/HidlSupport.h> #include <media/drm/DrmAPI.h> #include <cstdint> #include <vector> Loading @@ -35,10 +31,10 @@ struct DrmKeyStatus { const hardware::hidl_vec<uint8_t> keyId; }; class IDrmClient: public IInterface class IDrmClient: public virtual RefBase { public: DECLARE_META_INTERFACE(DrmClient); ~IDrmClient() {} virtual void sendEvent( DrmPlugin::EventType eventType, Loading @@ -57,17 +53,11 @@ public: virtual void sendSessionLostState( const hardware::hidl_vec<uint8_t> &sessionId) = 0; }; protected: IDrmClient() {} // ---------------------------------------------------------------------------- class BnDrmClient: public BnInterface<IDrmClient> { public: virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); private: DISALLOW_EVIL_CONSTRUCTORS(IDrmClient); }; }; // namespace android Loading Loading
drm/libmediadrm/Android.bp +0 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,6 @@ cc_library_shared { srcs: [ "DrmPluginPath.cpp", "DrmSessionManager.cpp", "IDrmClient.cpp", "IMediaDrmService.cpp", "SharedLibrary.cpp", "DrmHal.cpp", Loading
drm/libmediadrm/DrmHal.cpp +0 −11 Original line number Diff line number Diff line Loading @@ -479,12 +479,6 @@ status_t DrmHal::initCheck() const { status_t DrmHal::setListener(const sp<IDrmClient>& listener) { Mutex::Autolock lock(mEventLock); if (mListener != NULL){ IInterface::asBinder(mListener)->unlinkToDeath(this); } if (listener != NULL) { IInterface::asBinder(listener)->linkToDeath(this); } mListener = listener; return NO_ERROR; } Loading Loading @@ -1567,11 +1561,6 @@ status_t DrmHal::signRSA(Vector<uint8_t> const &sessionId, return hResult.isOk() ? err : DEAD_OBJECT; } void DrmHal::binderDied(const wp<IBinder> &the_late_who __unused) { cleanup(); } void DrmHal::reportFrameworkMetrics() const { std::unique_ptr<MediaAnalyticsItem> item(MediaAnalyticsItem::create("mediadrm")); Loading
drm/libmediadrm/IDrmClient.cppdeleted 100644 → 0 +0 −181 Original line number Diff line number Diff line /* ** ** Copyright 2013, The Android Open Source Project ** ** Licensed under the Apache License, Version 2.0 (the "License"); ** you may not use this file except in compliance with the License. ** You may obtain a copy of the License at ** ** http://www.apache.org/licenses/LICENSE-2.0 ** ** Unless required by applicable law or agreed to in writing, software ** distributed under the License is distributed on an "AS IS" BASIS, ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ** See the License for the specific language governing permissions and ** limitations under the License. */ //#define LOG_NDEBUG 0 #define LOG_TAG "IDrmClient" #include <utils/Errors.h> #include <utils/Log.h> #include <utils/RefBase.h> #include <binder/IInterface.h> #include <binder/Parcel.h> #include <hidl/HidlSupport.h> #include <media/IMediaPlayerClient.h> #include <mediadrm/DrmUtils.h> #include <mediadrm/IDrmClient.h> #include <cstddef> #include <cstdint> #include <vector> namespace android { enum { SEND_EVENT = IBinder::FIRST_CALL_TRANSACTION, SEND_EXPIRATION_UPDATE, SEND_KEYS_CHANGE, SEND_SESSION_LOST_STATE, }; namespace { hardware::hidl_vec<uint8_t> ReadByteArray(const Parcel &obj, status_t *err) { int32_t len = obj.readInt32(); hardware::hidl_vec<uint8_t> ret; if (len < 0) { ALOGE("Invalid array len"); *err = BAD_VALUE; return ret; } ret.resize(static_cast<size_t>(len)); *err = obj.read(ret.data(), ret.size()); return ret; } } class BpDrmClient: public BpInterface<IDrmClient> { template <typename F> void notify(uint32_t code, F fillParcel) { Parcel obj, reply; obj.writeInterfaceToken(IDrmClient::getInterfaceDescriptor()); fillParcel(obj); remote()->transact(code, obj, &reply, IBinder::FLAG_ONEWAY); } public: explicit BpDrmClient(const sp<IBinder>& impl) : BpInterface<IDrmClient>(impl) { } virtual void sendEvent( DrmPlugin::EventType eventType, const hardware::hidl_vec<uint8_t> &sessionId, const hardware::hidl_vec<uint8_t> &data) { auto fillParcel = [&] (Parcel &p) { DrmUtils::WriteEventToParcel(p, eventType, sessionId, data); }; notify(SEND_EVENT, fillParcel); } virtual void sendExpirationUpdate( const hardware::hidl_vec<uint8_t> &sessionId, int64_t expiryTimeInMS) { auto fillParcel = [&] (Parcel &p) { DrmUtils::WriteExpirationUpdateToParcel(p, sessionId, expiryTimeInMS); }; notify(SEND_EXPIRATION_UPDATE, fillParcel); } virtual void sendKeysChange( const hardware::hidl_vec<uint8_t> &sessionId, const std::vector<DrmKeyStatus> &keyStatusList, bool hasNewUsableKey) { auto fillParcel = [&] (Parcel &p) { DrmUtils::WriteKeysChange(p, sessionId, keyStatusList, hasNewUsableKey); }; notify(SEND_KEYS_CHANGE, fillParcel); } virtual void sendSessionLostState( const hardware::hidl_vec<uint8_t> &sessionId) { auto fillParcel = [&] (Parcel &p) { DrmUtils::WriteByteArray(p, sessionId); }; notify(SEND_SESSION_LOST_STATE, fillParcel); } }; IMPLEMENT_META_INTERFACE(DrmClient, "android.media.IDrmClient"); // ---------------------------------------------------------------------- status_t BnDrmClient::onTransact( uint32_t code, const Parcel& obj, Parcel* reply, uint32_t flags) { CHECK_INTERFACE(IDrmClient, obj, reply); status_t err = NO_ERROR; hardware::hidl_vec<uint8_t> sessionId(ReadByteArray(obj, &err)); if (err != NO_ERROR) { ALOGE("Failed to read session id, error=%d", err); return err; } switch (code) { case SEND_EVENT: { hardware::hidl_vec<uint8_t> data(ReadByteArray(obj, &err)); int eventType = obj.readInt32(); if (err == NO_ERROR) { sendEvent(static_cast<DrmPlugin::EventType>(eventType), sessionId, data); } return err; } break; case SEND_EXPIRATION_UPDATE: { int64_t expiryTimeInMS = obj.readInt64(); sendExpirationUpdate(sessionId, expiryTimeInMS); return NO_ERROR; } break; case SEND_KEYS_CHANGE: { // ... int32_t n = obj.readInt32(); if (n < 0) { return BAD_VALUE; } std::vector<DrmKeyStatus> keyStatusList; for (int32_t i = 0; i < n; ++i) { hardware::hidl_vec<uint8_t> keyId(ReadByteArray(obj, &err)); if (err != NO_ERROR) { return err; } int32_t type = obj.readInt32(); if (type < 0) { return BAD_VALUE; } keyStatusList.push_back({static_cast<uint32_t>(type), keyId}); } int32_t hasNewUsableKey = obj.readInt32(); sendKeysChange(sessionId, keyStatusList, hasNewUsableKey); return NO_ERROR; } break; case SEND_SESSION_LOST_STATE: { sendSessionLostState(sessionId); return NO_ERROR; } break; default: return BBinder::onTransact(code, obj, reply, flags); } } } // namespace android
drm/libmediadrm/include/mediadrm/DrmHal.h +0 −3 Original line number Diff line number Diff line Loading @@ -58,7 +58,6 @@ inline bool operator==(const Vector<uint8_t> &l, const Vector<uint8_t> &r) { } struct DrmHal : public IDrm, public IBinder::DeathRecipient, public IDrmPluginListener_V1_2 { struct DrmSessionClient; Loading Loading @@ -192,8 +191,6 @@ struct DrmHal : public IDrm, Return<void> sendSessionLostState(const hidl_vec<uint8_t>& sessionId); virtual void binderDied(const wp<IBinder> &the_late_who); private: static Mutex mLock; Loading
drm/libmediadrm/include/mediadrm/IDrmClient.h +7 −17 Original line number Diff line number Diff line Loading @@ -18,12 +18,8 @@ #define ANDROID_IDRMCLIENT_H #include <utils/RefBase.h> #include <binder/IInterface.h> #include <binder/Parcel.h> #include <media/drm/DrmAPI.h> #include <android/hardware/drm/1.2/types.h> #include <hidl/HidlSupport.h> #include <media/drm/DrmAPI.h> #include <cstdint> #include <vector> Loading @@ -35,10 +31,10 @@ struct DrmKeyStatus { const hardware::hidl_vec<uint8_t> keyId; }; class IDrmClient: public IInterface class IDrmClient: public virtual RefBase { public: DECLARE_META_INTERFACE(DrmClient); ~IDrmClient() {} virtual void sendEvent( DrmPlugin::EventType eventType, Loading @@ -57,17 +53,11 @@ public: virtual void sendSessionLostState( const hardware::hidl_vec<uint8_t> &sessionId) = 0; }; protected: IDrmClient() {} // ---------------------------------------------------------------------------- class BnDrmClient: public BnInterface<IDrmClient> { public: virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); private: DISALLOW_EVIL_CONSTRUCTORS(IDrmClient); }; }; // namespace android Loading