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
This commit is contained in:
Jeff Tinker
2017-01-25 11:46:52 -08:00
parent 17c5206bfd
commit 45548ea846
3 changed files with 14 additions and 9 deletions

View File

@@ -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);
};

View File

@@ -45,9 +45,9 @@ Return<bool> DrmFactory::isContentTypeSupported (
isContentTypeSupported<LegacyLoader, String8>(legacyLoader, mimeType);
}
Return<void> DrmFactory::createPlugin(const hidl_array<uint8_t, 16>& uuid,
createPlugin_cb _hidl_cb) {
sp<IDrmPlugin> plugin = createTreblePlugin(uuid);
Return<void> DrmFactory::createPlugin(const hidl_array<uint8_t, 16>& uuid,
const hidl_string& appPackageName, createPlugin_cb _hidl_cb) {
sp<IDrmPlugin> plugin = createTreblePlugin(uuid, appPackageName);
if (plugin == nullptr) {
plugin = createLegacyPlugin(uuid);
}
@@ -55,11 +55,12 @@ Return<void> DrmFactory::createPlugin(const hidl_array<uint8_t, 16>& uuid,
return Void();
}
sp<IDrmPlugin> DrmFactory::createTreblePlugin(const hidl_array<uint8_t, 16>& uuid) {
sp<IDrmPlugin> DrmFactory::createTreblePlugin(const hidl_array<uint8_t, 16>& uuid,
const hidl_string& appPackageName) {
sp<IDrmPlugin> plugin;
for (size_t i = 0; i < trebleLoader.factoryCount(); i++) {
Return<void> hResult = trebleLoader.getFactory(i)->createPlugin(uuid,
[&](Status status, const sp<IDrmPlugin>& hPlugin) {
appPackageName, [&](Status status, const sp<IDrmPlugin>& hPlugin) {
if (status == Status::OK) {
plugin = hPlugin;
}

View File

@@ -49,7 +49,8 @@ struct DrmFactory : public IDrmFactory {
override;
Return<void> createPlugin(const hidl_array<uint8_t, 16>& uuid,
createPlugin_cb _hidl_cb) override;
const hidl_string& appPackageName, createPlugin_cb _hidl_cb) override;
private:
template <typename L> Return<bool> isCryptoSchemeSupported(
const L& loader, const hidl_array<uint8_t, 16>& uuid) {
@@ -71,7 +72,8 @@ private:
return false;
}
sp<IDrmPlugin> createTreblePlugin(const hidl_array<uint8_t, 16>& uuid);
sp<IDrmPlugin> createTreblePlugin(const hidl_array<uint8_t, 16>& uuid,
const hidl_string& appPackageName);
sp<IDrmPlugin> createLegacyPlugin(const hidl_array<uint8_t, 16>& uuid);
typedef android::PluginLoader<IDrmFactory> PluginLoader;