/* * 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 #include #include #include #include #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 isCryptoSchemeSupported(const hidl_array& uuid) override; Return createPlugin( const hidl_array& uuid, const hidl_vec& initData, createPlugin_cb _hidl_cb) override; private: WVDRM_DISALLOW_COPY_AND_ASSIGN(WVCryptoFactory); }; struct WVDrmFactory : public ::drm::V1_3::IDrmFactory { WVDrmFactory() {} virtual ~WVDrmFactory() {} Return isCryptoSchemeSupported( const hidl_array& uuid) override; Return isCryptoSchemeSupported_1_2(const hidl_array& uuid, const hidl_string& mimeType, SecurityLevel level) override; Return isContentTypeSupported(const hidl_string& mimeType) override; Return createPlugin(const hidl_array& uuid, const hidl_string& appPackageName, createPlugin_cb _hidl_cb) override; Return 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(); }