1 /******************************************************************************
2  *
3  *  Copyright (C) 2018 ST Microelectronics S.A.
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  *
18  ******************************************************************************/
19 #define LOG_TAG "ese@1.2-service.st"
20 #include <android/hardware/secure_element/1.2/ISecureElement.h>
21 #include <hidl/LegacySupport.h>
22 #include <log/log.h>
23 
24 #include "SecureElement.h"
25 
26 // Generated HIDL files
27 using android::OK;
28 using android::sp;
29 using android::status_t;
30 using android::hardware::configureRpcThreadpool;
31 using android::hardware::joinRpcThreadpool;
32 using android::hardware::secure_element::V1_2::ISecureElement;
33 using android::hardware::secure_element::V1_2::implementation::SecureElement;
34 
main()35 int main() {
36   ALOGD("Secure Element HAL Service 1.2 is starting.");
37   sp<ISecureElement> se_service = new SecureElement();
38   configureRpcThreadpool(1, true /*callerWillJoin*/);
39   status_t status = se_service->registerAsService("eSE1");
40   if (status != OK) {
41     LOG_ALWAYS_FATAL(
42         "Could not register service for Secure Element HAL Iface (%d).",
43         status);
44     return -1;
45   }
46 
47   ALOGD("Secure Element Service is ready");
48   joinRpcThreadpool();
49   return 1;
50 }
51