1 /******************************************************************************
2 *
3 * Copyright 2018-2021 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
19 #include <log/log.h>
20
21 #include "NxpNfc.h"
22 #include "phNxpNciHal.h"
23 #include "phNxpNciHal_Adaptation.h"
24
25 extern bool nfc_debug_enabled;
26
27 namespace vendor {
28 namespace nxp {
29 namespace nxpnfc {
30 namespace V2_0 {
31 namespace implementation {
32
getVendorParam(const::android::hardware::hidl_string & key,getVendorParam_cb _hidl_cb)33 Return<void> NxpNfc::getVendorParam(const ::android::hardware::hidl_string& key,
34 getVendorParam_cb _hidl_cb) {
35 string val = phNxpNciHal_getSystemProperty(key);
36 _hidl_cb(val);
37 return Void();
38 }
39
setVendorParam(const::android::hardware::hidl_string & key,const::android::hardware::hidl_string & value)40 Return<bool> NxpNfc::setVendorParam(
41 const ::android::hardware::hidl_string& key,
42 const ::android::hardware::hidl_string& value) {
43 return phNxpNciHal_setSystemProperty(key, value);
44 }
45
resetEse(uint64_t resetType)46 Return<bool> NxpNfc::resetEse(uint64_t resetType) {
47 NFCSTATUS status = NFCSTATUS_FAILED;
48 bool ret = false;
49 ALOGD("NxpNfc::resetEse Entry");
50
51 status = phNxpNciHal_resetEse(resetType);
52 if (NFCSTATUS_SUCCESS == status) {
53 ret = true;
54 status = NFCSTATUS_SUCCESS;
55 ALOGD("Reset request (%02x) completed", (uint8_t)resetType);
56 } else {
57 ALOGE("Reset request (%02x) failed", (uint8_t)resetType);
58 }
59
60 ALOGD("NxpNfc::resetEse Exit");
61 return ret;
62 }
63
setEseUpdateState(NxpNfcHalEseState eSEState)64 Return<bool> NxpNfc::setEseUpdateState(NxpNfcHalEseState eSEState) {
65 bool status = false;
66
67 ALOGD("NxpNfc::setEseUpdateState Entry");
68
69 if (eSEState == NxpNfcHalEseState::HAL_NFC_ESE_JCOP_UPDATE_COMPLETED ||
70 eSEState == NxpNfcHalEseState::HAL_NFC_ESE_LS_UPDATE_COMPLETED) {
71 ALOGD(
72 "NxpNfc::setEseUpdateState state == HAL_NFC_ESE_JCOP_UPDATE_COMPLETED");
73 seteSEClientState((uint8_t)eSEState);
74 eSEClientUpdate_NFC_Thread();
75 }
76 if (eSEState == NxpNfcHalEseState::HAL_NFC_ESE_UPDATE_COMPLETED) {
77 status = phNxpNciHal_Abort();
78 }
79
80 ALOGD("NxpNfc::setEseUpdateState Exit");
81 return status;
82 }
83
setNxpTransitConfig(const::android::hardware::hidl_string & strval)84 Return<bool> NxpNfc::setNxpTransitConfig(
85 const ::android::hardware::hidl_string& strval) {
86 bool status = true;
87 ALOGD("NxpNfc::setNxpTransitConfig Entry");
88
89 status = phNxpNciHal_setNxpTransitConfig((char*)strval.c_str());
90
91 ALOGD("NxpNfc::setNxpTransitConfig Exit");
92 return status;
93 }
94
isJcopUpdateRequired()95 Return<bool> NxpNfc::isJcopUpdateRequired() {
96 bool status = 0;
97 ALOGD("NxpNfc::isJcopUpdateRequired Entry");
98
99 #ifdef NXP_BOOTTIME_UPDATE
100 status = getJcopUpdateRequired();
101 #endif
102
103 ALOGD("NxpNfc::isJcopUpdateRequired Exit");
104 return status;
105 }
106
isLsUpdateRequired()107 Return<bool> NxpNfc::isLsUpdateRequired() {
108 bool status = 0;
109 ALOGD("NxpNfc::isLsUpdateRequired Entry");
110
111 #ifdef NXP_BOOTTIME_UPDATE
112 status = getLsUpdateRequired();
113 #endif
114
115 ALOGD("NxpNfc::isLsUpdateRequired Exit");
116 return status;
117 }
118
119 } // namespace implementation
120 } // namespace V2_0
121 } // namespace nxpnfc
122 } // namespace nxp
123 } // namespace vendor
124