libwvhidl picked from the following builds: +--------+---------+ | arch | build | +--------+---------+ | arm | 7520386 | | arm64 | 7511028 | | x86 | 7511028 | | x86_64 | 7511028 | +--------+---------+ Ran patchelf to set DT_SONAME to libwvhidl@1.3.so Bug: 191881462 Test: atest MediaDrmTest#testOemCryptoVersion Change-Id: I0f6c6750124d89145ef54c47d7dc8c95a7207063
109 lines
3.4 KiB
C++
109 lines
3.4 KiB
C++
/*
|
|
* Copyright 2021 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.
|
|
*/
|
|
#include "hidl/HidlSupport.h"
|
|
#define LOG_TAG "WidevineHidlService"
|
|
|
|
#include <android-base/logging.h>
|
|
#include <android/hardware/drm/1.3/ICryptoFactory.h>
|
|
#include <android/hardware/drm/1.3/IDrmFactory.h>
|
|
#include <binder/ProcessState.h>
|
|
#include <hidl/HidlTransportSupport.h>
|
|
|
|
#include "WVTypes.h"
|
|
|
|
namespace drm = ::android::hardware::drm;
|
|
|
|
namespace wvdrm {
|
|
namespace hardware {
|
|
namespace drm {
|
|
namespace V1_3 {
|
|
namespace widevine {
|
|
|
|
using ::android::hardware::Return;
|
|
using ::android::hardware::hidl_array;
|
|
using ::android::hardware::hidl_string;
|
|
using ::android::hardware::hidl_vec;
|
|
using ::drm::V1_1::SecurityLevel;
|
|
|
|
struct WVCryptoFactory : public ::drm::V1_3::ICryptoFactory {
|
|
public:
|
|
WVCryptoFactory() {}
|
|
virtual ~WVCryptoFactory() {}
|
|
|
|
Return<bool> isCryptoSchemeSupported(const hidl_array<uint8_t, 16>& uuid)
|
|
override;
|
|
|
|
Return<void> createPlugin(
|
|
const hidl_array<uint8_t, 16>& uuid,
|
|
const hidl_vec<uint8_t>& initData,
|
|
createPlugin_cb _hidl_cb) override;
|
|
|
|
private:
|
|
WVDRM_DISALLOW_COPY_AND_ASSIGN(WVCryptoFactory);
|
|
};
|
|
|
|
struct WVDrmFactory : public ::drm::V1_3::IDrmFactory {
|
|
WVDrmFactory() {}
|
|
virtual ~WVDrmFactory() {}
|
|
|
|
Return<bool> isCryptoSchemeSupported(
|
|
const hidl_array<uint8_t, 16>& uuid) override;
|
|
|
|
Return<bool> isCryptoSchemeSupported_1_2(const hidl_array<uint8_t, 16>& uuid,
|
|
const hidl_string& mimeType,
|
|
SecurityLevel level) override;
|
|
|
|
Return<bool> isContentTypeSupported(const hidl_string& mimeType) override;
|
|
|
|
Return<void> createPlugin(const hidl_array<uint8_t, 16>& uuid,
|
|
const hidl_string& appPackageName,
|
|
createPlugin_cb _hidl_cb) override;
|
|
|
|
Return<void> getSupportedCryptoSchemes(
|
|
getSupportedCryptoSchemes_cb _hidl_cb) override;
|
|
|
|
private:
|
|
WVDRM_DISALLOW_COPY_AND_ASSIGN(WVDrmFactory);
|
|
};
|
|
|
|
} // namespace widevine
|
|
} // namespace V1_3
|
|
} // namespace drm
|
|
} // namespace hardware
|
|
} // namespace wvdrm
|
|
|
|
int main(int /* argc */, char** /* argv */) {
|
|
using ::android::sp;
|
|
using ::wvdrm::hardware::drm::V1_3::widevine::WVCryptoFactory;
|
|
using ::wvdrm::hardware::drm::V1_3::widevine::WVDrmFactory;
|
|
|
|
sp<::drm::V1_3::IDrmFactory> drmFactory = new WVDrmFactory;
|
|
sp<::drm::V1_3::ICryptoFactory> cryptoFactory = new WVCryptoFactory;
|
|
|
|
android::hardware::configureRpcThreadpool(8, true /* callerWillJoin */);
|
|
|
|
android::hardware::setRequestingSid(drmFactory, true);
|
|
android::hardware::setRequestingSid(cryptoFactory, true);
|
|
|
|
// Setup hwbinder service
|
|
CHECK_EQ(drmFactory->registerAsService("widevine"), android::NO_ERROR)
|
|
<< "Failed to register Widevine Factory HAL";
|
|
CHECK_EQ(cryptoFactory->registerAsService("widevine"), android::NO_ERROR)
|
|
<< "Failed to register Widevine Crypto HAL";
|
|
|
|
android::hardware::joinRpcThreadpool();
|
|
}
|