blob: 708627302d62cec612e308111ac1cf0817814ff4 [file] [log] [blame]
LuK1337f267b8f2019-08-19 00:08:08 +02001/*
2 * Copyright 2019 The LineageOS 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
17#define LOG_TAG "android.hardware.keymaster@4.0-service.samsung"
18
19#include <android-base/logging.h>
20#include <android/hardware/keymaster/4.0/IKeymasterDevice.h>
21#include <hidl/HidlTransportSupport.h>
22
23#include <AndroidKeymaster4Device.h>
24
25using android::hardware::configureRpcThreadpool;
26using android::hardware::joinRpcThreadpool;
27
28using android::hardware::keymaster::V4_0::IKeymasterDevice;
29using android::hardware::keymaster::V4_0::SecurityLevel;
30
31using android::OK;
32using android::status_t;
33
34namespace skeymaster {
35IKeymasterDevice* CreateSKeymasterDevice(SecurityLevel securityLevel);
36} // namespace skeymaster
37
38int main() {
39 IKeymasterDevice* keymaster =
40 skeymaster::CreateSKeymasterDevice(SecurityLevel::TRUSTED_ENVIRONMENT);
41
42 configureRpcThreadpool(1, true);
43
44 status_t status = keymaster->registerAsService();
45
46 if (status != OK) {
47 LOG(ERROR) << "Could not register service for Keymaster HAL";
48 goto shutdown;
49 }
50
51 LOG(INFO) << "Keymaster HAL service is Ready.";
52 joinRpcThreadpool();
53
54shutdown:
55 // In normal operation, we don't expect the thread pool to shutdown
56 LOG(ERROR) << "Keymaster HAL failed to join thread pool.";
57 return -1;
58}