From 45548ea8463e8a462dc3f1a629ccbe6415aa9c13 Mon Sep 17 00:00:00 2001 From: Jeff Tinker Date: Wed, 25 Jan 2017 11:46:52 -0800 Subject: [PATCH] Add vendor-requested parameter to createPlugin A feature in O requires a small change to the drm HAL: adding a parameter to the createPlugin method in the DrmFactory. bug:31306973 Change-Id: Iab0f7ee58103b357f10cf05ea7986a8fc01eebf6 --- drm/1.0/IDrmFactory.hal | 6 ++++-- drm/1.0/default/DrmFactory.cpp | 11 ++++++----- drm/1.0/default/DrmFactory.h | 6 ++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drm/1.0/IDrmFactory.hal b/drm/1.0/IDrmFactory.hal index de53929cbc..f8e4779e16 100644 --- a/drm/1.0/IDrmFactory.hal +++ b/drm/1.0/IDrmFactory.hal @@ -50,10 +50,12 @@ interface IDrmFactory { * * @param uuid uniquely identifies the drm scheme. See * http://dashif.org/identifiers/protection for uuid assignments + * @param appPackageName identifies the package name of the calling + * application. * @return status the status of the call. The HAL implementation must return * OK if the plugin is created and ERROR_DRM_CANNOT_HANDLE if the plugin * cannot be created. */ - createPlugin(uint8_t[16] uuid) generates (Status status, - IDrmPlugin drmPlugin); + createPlugin(uint8_t[16] uuid, string appPackageName) + generates (Status status, IDrmPlugin drmPlugin); }; diff --git a/drm/1.0/default/DrmFactory.cpp b/drm/1.0/default/DrmFactory.cpp index d7a7c6dccc..c98c1daa0a 100644 --- a/drm/1.0/default/DrmFactory.cpp +++ b/drm/1.0/default/DrmFactory.cpp @@ -45,9 +45,9 @@ Return DrmFactory::isContentTypeSupported ( isContentTypeSupported(legacyLoader, mimeType); } -Return DrmFactory::createPlugin(const hidl_array& uuid, - createPlugin_cb _hidl_cb) { - sp plugin = createTreblePlugin(uuid); + Return DrmFactory::createPlugin(const hidl_array& uuid, + const hidl_string& appPackageName, createPlugin_cb _hidl_cb) { + sp plugin = createTreblePlugin(uuid, appPackageName); if (plugin == nullptr) { plugin = createLegacyPlugin(uuid); } @@ -55,11 +55,12 @@ Return DrmFactory::createPlugin(const hidl_array& uuid, return Void(); } -sp DrmFactory::createTreblePlugin(const hidl_array& uuid) { +sp DrmFactory::createTreblePlugin(const hidl_array& uuid, + const hidl_string& appPackageName) { sp plugin; for (size_t i = 0; i < trebleLoader.factoryCount(); i++) { Return hResult = trebleLoader.getFactory(i)->createPlugin(uuid, - [&](Status status, const sp& hPlugin) { + appPackageName, [&](Status status, const sp& hPlugin) { if (status == Status::OK) { plugin = hPlugin; } diff --git a/drm/1.0/default/DrmFactory.h b/drm/1.0/default/DrmFactory.h index 3291ea26ab..2e71624ea0 100644 --- a/drm/1.0/default/DrmFactory.h +++ b/drm/1.0/default/DrmFactory.h @@ -49,7 +49,8 @@ struct DrmFactory : public IDrmFactory { override; Return createPlugin(const hidl_array& uuid, - createPlugin_cb _hidl_cb) override; + const hidl_string& appPackageName, createPlugin_cb _hidl_cb) override; + private: template Return isCryptoSchemeSupported( const L& loader, const hidl_array& uuid) { @@ -71,7 +72,8 @@ private: return false; } - sp createTreblePlugin(const hidl_array& uuid); + sp createTreblePlugin(const hidl_array& uuid, + const hidl_string& appPackageName); sp createLegacyPlugin(const hidl_array& uuid); typedef android::PluginLoader PluginLoader;