The interface is defined in hardware/interfaces/drm/aidl(http://go/ag/15329852). Test: build m android.hardware.drm-service.widevine -j128 Test: build_and_run_all_unit_tests.sh for hidl tests Test: atest VtsAidlHalDrmTargetTest Bug: 200055138 Bug: 170964303 Change-Id: If2f2a129914436ba5cef1c46f6cb9415e12c3d1c
66 lines
2.0 KiB
C++
66 lines
2.0 KiB
C++
//
|
|
// Copyright 2021 Google LLC. All Rights Reserved. This file and proprietary
|
|
// source code may only be used and distributed under the Widevine License
|
|
// Agreement.
|
|
//
|
|
|
|
//#define LOG_NDEBUG 0
|
|
#define LOG_TAG "WVCdm"
|
|
#include "WVCryptoFactory.h"
|
|
|
|
#include <android/binder_ibinder_platform.h>
|
|
#include <binder/IPCThreadState.h>
|
|
#include <utils/Log.h>
|
|
|
|
#include "Utils.h"
|
|
#include "WVCDMSingleton.h"
|
|
#include "WVCryptoPlugin.h"
|
|
#include "WVUUID.h"
|
|
|
|
namespace wvdrm {
|
|
namespace hardware {
|
|
namespace drm {
|
|
namespace widevine {
|
|
|
|
using ::aidl::android::hardware::drm::Status;
|
|
using ::aidl::android::hardware::drm::Uuid;
|
|
|
|
::ndk::ScopedAStatus WVCryptoFactory::isCryptoSchemeSupported(
|
|
const Uuid& in_uuid, bool* _aidl_return) {
|
|
*_aidl_return = isWidevineUUID(in_uuid.uuid.data());
|
|
return ::ndk::ScopedAStatus::ok();
|
|
}
|
|
|
|
::ndk::ScopedAStatus WVCryptoFactory::createPlugin(
|
|
const ::aidl::android::hardware::drm::Uuid& in_uuid,
|
|
const std::vector<uint8_t>& in_initData,
|
|
std::shared_ptr<::aidl::android::hardware::drm::ICryptoPlugin>*
|
|
_aidl_return) {
|
|
const auto& self = android::IPCThreadState::self();
|
|
const char* sid = self->getCallingSid();
|
|
sid = sid ? (std::strstr(sid, "mediadrmserver") ? sid : "app") : "nullptr";
|
|
ALOGI("[%s] calling %s", sid, __PRETTY_FUNCTION__);
|
|
|
|
bool isSupported = false;
|
|
isCryptoSchemeSupported(in_uuid, &isSupported);
|
|
if (!isSupported) {
|
|
ALOGE(
|
|
"Widevine Drm HAL: failed to create crypto plugin, "
|
|
"invalid crypto scheme");
|
|
*_aidl_return = nullptr;
|
|
return toNdkScopedAStatus(Status::ERROR_DRM_CANNOT_HANDLE);
|
|
}
|
|
|
|
std::shared_ptr<WVCryptoPlugin> plugin =
|
|
::ndk::SharedRefBase::make<WVCryptoPlugin>(in_initData.data(),
|
|
in_initData.size(), getCDM());
|
|
AIBinder_setRequestingSid(plugin->asBinder().get(), true);
|
|
*_aidl_return = std::move(plugin);
|
|
return toNdkScopedAStatus(Status::OK);
|
|
}
|
|
|
|
} // namespace widevine
|
|
} // namespace drm
|
|
} // namespace hardware
|
|
} // namespace wvdrm
|