1 /*
2 * Copyright 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 #include <CryptoFactory.h>
17 #include <DrmFactory.h>
18
19 #include <android-base/logging.h>
20 #include <binder/ProcessState.h>
21 #include <hidl/HidlLazyUtils.h>
22 #include <hidl/HidlTransportSupport.h>
23
24 using ::android::hardware::configureRpcThreadpool;
25 using ::android::hardware::joinRpcThreadpool;
26 using ::android::sp;
27
28 using android::hardware::drm::V1_4::ICryptoFactory;
29 using android::hardware::drm::V1_4::IDrmFactory;
30 using android::hardware::drm::V1_4::clearkey::CryptoFactory;
31 using android::hardware::drm::V1_4::clearkey::DrmFactory;
32 using android::hardware::LazyServiceRegistrar;
33
main(int,char **)34 int main(int /* argc */, char** /* argv */) {
35 sp<IDrmFactory> drmFactory = new DrmFactory;
36 sp<ICryptoFactory> cryptoFactory = new CryptoFactory;
37
38 configureRpcThreadpool(8, true /* callerWillJoin */);
39
40 // Setup hwbinder service
41 auto serviceRegistrar = LazyServiceRegistrar::getInstance();
42
43 // Setup hwbinder service
44 CHECK_EQ(serviceRegistrar.registerService(drmFactory, "clearkey"), android::NO_ERROR)
45 << "Failed to register Clearkey Factory HAL";
46 CHECK_EQ(serviceRegistrar.registerService(cryptoFactory, "clearkey"), android::NO_ERROR)
47 << "Failed to register Clearkey Crypto HAL";
48
49 joinRpcThreadpool();
50 }
51