Home | History | Annotate | Download | only in 1.0
      1 /******************************************************************************
      2  *
      3  *  Copyright 2018 NXP
      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 #define LOG_TAG "nxpese (at) 1.0-service"
     19 #include <android/hardware/secure_element/1.0/ISecureElement.h>
     20 #include <hidl/LegacySupport.h>
     21 #include <log/log.h>
     22 #include <vendor/nxp/nxpese/1.0/INxpEse.h>
     23 
     24 #include "NxpEse.h"
     25 #include "SecureElement.h"
     26 
     27 // Generated HIDL files
     28 using android::hardware::secure_element::V1_0::ISecureElement;
     29 using android::hardware::secure_element::V1_0::implementation::SecureElement;
     30 using android::hardware::configureRpcThreadpool;
     31 using android::hardware::joinRpcThreadpool;
     32 using android::OK;
     33 using android::sp;
     34 using android::status_t;
     35 using vendor::nxp::nxpese::V1_0::INxpEse;
     36 using vendor::nxp::nxpese::V1_0::implementation::NxpEse;
     37 
     38 int main() {
     39   ALOGD("Secure Element HAL Service 1.0 is starting.");
     40   sp<ISecureElement> se_service = new SecureElement();
     41   configureRpcThreadpool(1, true /*callerWillJoin*/);
     42   status_t status = se_service->registerAsService("eSE1");
     43   if (status != OK) {
     44     LOG_ALWAYS_FATAL(
     45         "Could not register service for Secure Element HAL Iface (%d).",
     46         status);
     47     return -1;
     48   }
     49   sp<INxpEse> nxp_se_service = new NxpEse();
     50   status = nxp_se_service->registerAsService();
     51   if (status != OK) {
     52     LOG_ALWAYS_FATAL(
     53         "Could not register service for Power Secure Element Extn Iface (%d).",
     54         status);
     55     return -1;
     56   }
     57   ALOGD("Secure Element Service is ready");
     58   joinRpcThreadpool();
     59   return 1;
     60 }
     61