Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 2017 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 "NfcNciHalWrapper" |
| 20 | #include <cutils/properties.h> |
| 21 | #include <errno.h> |
| 22 | #include <hardware/nfc.h> |
George Chang | a009f4e | 2020-12-29 16:57:45 +0800 | [diff] [blame^] | 23 | #include <log/log.h> |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 24 | #include <string.h> |
Arach MOHAMMED BRAHIM | ef5b4d9 | 2018-09-24 16:07:04 +0200 | [diff] [blame] | 25 | #include <unistd.h> |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 26 | #include "android_logmsg.h" |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 27 | #include "hal_fd.h" |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 28 | #include "halcore.h" |
| 29 | |
| 30 | extern void HalCoreCallback(void* context, uint32_t event, const void* d, |
| 31 | size_t length); |
| 32 | extern bool I2cOpenLayer(void* dev, HAL_CALLBACK callb, HALHANDLE* pHandle); |
| 33 | extern void I2cCloseLayer(); |
| 34 | |
| 35 | typedef struct { |
| 36 | struct nfc_nci_device nci_device; // nci_device must be first struct member |
| 37 | // below declarations are private variables within HAL |
| 38 | nfc_stack_callback_t* p_cback; |
| 39 | nfc_stack_data_callback_t* p_data_cback; |
| 40 | HALHANDLE hHAL; |
| 41 | } st21nfc_dev_t; |
| 42 | |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 43 | static void halWrapperDataCallback(uint16_t data_len, uint8_t* p_data); |
| 44 | static void halWrapperCallback(uint8_t event, uint8_t event_status); |
| 45 | |
| 46 | nfc_stack_callback_t* mHalWrapperCallback = NULL; |
| 47 | nfc_stack_data_callback_t* mHalWrapperDataCallback = NULL; |
| 48 | hal_wrapper_state_e mHalWrapperState = HAL_WRAPPER_STATE_CLOSED; |
| 49 | HALHANDLE mHalHandle = NULL; |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 50 | |
| 51 | uint8_t mClfMode; |
| 52 | uint8_t mFwUpdateTaskMask; |
| 53 | int mRetryFwDwl; |
| 54 | uint8_t mFwUpdateResMask = 0; |
Arach MOHAMMED BRAHIM | dbc5db0 | 2019-05-07 12:26:29 +0200 | [diff] [blame] | 55 | uint8_t* ConfigBuffer = NULL; |
Arach MOHAMMED BRAHIM | 507dcb0 | 2019-09-13 10:30:38 +0200 | [diff] [blame] | 56 | uint8_t mError_count = 0; |
| 57 | bool mIsActiveRW = false; |
Arach MOHAMMED BRAHIM | dbc5db0 | 2019-05-07 12:26:29 +0200 | [diff] [blame] | 58 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; |
| 59 | pthread_cond_t ready_cond = PTHREAD_COND_INITIALIZER; |
| 60 | |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 61 | static const uint8_t ApduGetAtr[] = {0x2F, 0x04, 0x05, 0x80, |
| 62 | 0x8A, 0x00, 0x00, 0x04}; |
| 63 | |
Arach MOHAMMED BRAHIM | cb8da7f | 2019-02-15 16:20:29 +0100 | [diff] [blame] | 64 | static const uint8_t nciHeaderPropSetConfig[9] = {0x2F, 0x02, 0x98, 0x04, 0x00, |
| 65 | 0x14, 0x01, 0x00, 0x92}; |
| 66 | static uint8_t nciPropEnableFwDbgTraces[256]; |
| 67 | static uint8_t nciPropGetFwDbgTracesConfig[] = {0x2F, 0x02, 0x05, 0x03, |
| 68 | 0x00, 0x14, 0x01, 0x00}; |
| 69 | bool mReadFwConfigDone = false; |
| 70 | |
Arach MOHAMMED BRAHIM | 449661b | 2018-09-24 17:02:54 +0200 | [diff] [blame] | 71 | bool mHciCreditLent = false; |
Arach MOHAMMED BRAHIM | cf7bd92 | 2019-05-09 15:40:17 +0200 | [diff] [blame] | 72 | bool mfactoryReset = false; |
Arach MOHAMMED BRAHIM | dbc5db0 | 2019-05-07 12:26:29 +0200 | [diff] [blame] | 73 | bool ready_flag = 0; |
Arach MOHAMMED BRAHIM | 507dcb0 | 2019-09-13 10:30:38 +0200 | [diff] [blame] | 74 | bool mTimerStarted = false; |
| 75 | bool forceRecover = false; |
Arach MOHAMMED BRAHIM | dbc5db0 | 2019-05-07 12:26:29 +0200 | [diff] [blame] | 76 | |
| 77 | void wait_ready() { |
| 78 | pthread_mutex_lock(&mutex); |
| 79 | while (!ready_flag) { |
| 80 | pthread_cond_wait(&ready_cond, &mutex); |
| 81 | } |
| 82 | pthread_mutex_unlock(&mutex); |
| 83 | } |
| 84 | |
| 85 | void set_ready(bool ready) { |
| 86 | pthread_mutex_lock(&mutex); |
| 87 | ready_flag = ready; |
| 88 | pthread_cond_signal(&ready_cond); |
| 89 | pthread_mutex_unlock(&mutex); |
| 90 | } |
| 91 | |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 92 | bool hal_wrapper_open(st21nfc_dev_t* dev, nfc_stack_callback_t* p_cback, |
| 93 | nfc_stack_data_callback_t* p_data_cback, |
| 94 | HALHANDLE* pHandle) { |
| 95 | bool result; |
| 96 | |
| 97 | STLOG_HAL_D("%s", __func__); |
| 98 | |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 99 | mFwUpdateResMask = hal_fd_init(); |
| 100 | mRetryFwDwl = 5; |
| 101 | mFwUpdateTaskMask = 0; |
| 102 | |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 103 | mHalWrapperState = HAL_WRAPPER_STATE_OPEN; |
Arach MOHAMMED BRAHIM | 449661b | 2018-09-24 17:02:54 +0200 | [diff] [blame] | 104 | mHciCreditLent = false; |
Arach MOHAMMED BRAHIM | cb8da7f | 2019-02-15 16:20:29 +0100 | [diff] [blame] | 105 | mReadFwConfigDone = false; |
Arach MOHAMMED BRAHIM | 507dcb0 | 2019-09-13 10:30:38 +0200 | [diff] [blame] | 106 | mError_count = 0; |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 107 | |
| 108 | mHalWrapperCallback = p_cback; |
| 109 | mHalWrapperDataCallback = p_data_cback; |
| 110 | |
| 111 | dev->p_data_cback = halWrapperDataCallback; |
| 112 | dev->p_cback = halWrapperCallback; |
| 113 | |
| 114 | result = I2cOpenLayer(dev, HalCoreCallback, pHandle); |
| 115 | |
| 116 | if (!result || !(*pHandle)) { |
| 117 | return -1; // We are doomed, stop it here, NOW ! |
| 118 | } |
| 119 | |
| 120 | mHalHandle = *pHandle; |
| 121 | |
| 122 | return 1; |
| 123 | } |
| 124 | |
Arach MOHAMMED BRAHIM | ef5b4d9 | 2018-09-24 16:07:04 +0200 | [diff] [blame] | 125 | int hal_wrapper_close(int call_cb, int nfc_mode) { |
| 126 | STLOG_HAL_V("%s - Sending PROP_NFC_MODE_SET_CMD(%d)", __func__, nfc_mode); |
| 127 | uint8_t propNfcModeSetCmdQb[] = {0x2f, 0x02, 0x02, 0x02, (uint8_t)nfc_mode}; |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 128 | |
Arach MOHAMMED BRAHIM | ef5b4d9 | 2018-09-24 16:07:04 +0200 | [diff] [blame] | 129 | mHalWrapperState = HAL_WRAPPER_STATE_CLOSING; |
| 130 | // Send PROP_NFC_MODE_SET_CMD |
| 131 | if (!HalSendDownstreamTimer(mHalHandle, propNfcModeSetCmdQb, |
Arach MOHAMMED BRAHIM | b9c65c1 | 2020-08-05 10:11:11 +0200 | [diff] [blame] | 132 | sizeof(propNfcModeSetCmdQb), 40)) { |
Arach MOHAMMED BRAHIM | ef5b4d9 | 2018-09-24 16:07:04 +0200 | [diff] [blame] | 133 | STLOG_HAL_E("NFC-NCI HAL: %s HalSendDownstreamTimer failed", __func__); |
| 134 | return -1; |
| 135 | } |
| 136 | // Let the CLF receive and process this |
| 137 | usleep(50000); |
| 138 | |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 139 | I2cCloseLayer(); |
Arach MOHAMMED BRAHIM | 838910b | 2018-08-16 16:05:24 +0200 | [diff] [blame] | 140 | if (call_cb) mHalWrapperCallback(HAL_NFC_CLOSE_CPLT_EVT, HAL_NFC_STATUS_OK); |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 141 | |
| 142 | return 1; |
| 143 | } |
| 144 | |
Arach MOHAMMED BRAHIM | dbc5db0 | 2019-05-07 12:26:29 +0200 | [diff] [blame] | 145 | void hal_wrapper_send_core_config_prop() { |
| 146 | long retlen = 0; |
| 147 | int isfound = 0; |
Alexandra Ducati-Manas | 9030f51 | 2018-11-22 09:22:43 +0100 | [diff] [blame] | 148 | |
Arach MOHAMMED BRAHIM | dbc5db0 | 2019-05-07 12:26:29 +0200 | [diff] [blame] | 149 | // allocate buffer for setting parameters |
| 150 | ConfigBuffer = (uint8_t*)malloc(256 * sizeof(uint8_t)); |
| 151 | if (ConfigBuffer != NULL) { |
| 152 | isfound = GetByteArrayValue(NAME_CORE_CONF_PROP, (char*)ConfigBuffer, 256, |
| 153 | &retlen); |
| 154 | |
| 155 | if (isfound > 0) { |
| 156 | STLOG_HAL_V("%s - Enter", __func__); |
| 157 | set_ready(0); |
| 158 | |
| 159 | if (!HalSendDownstreamTimer(mHalHandle, ConfigBuffer, retlen, 500)) { |
| 160 | STLOG_HAL_E("NFC-NCI HAL: %s SendDownstream failed", __func__); |
| 161 | } |
| 162 | mHalWrapperState = HAL_WRAPPER_STATE_PROP_CONFIG; |
| 163 | wait_ready(); |
| 164 | } |
| 165 | free(ConfigBuffer); |
| 166 | ConfigBuffer = NULL; |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 167 | } |
Arach MOHAMMED BRAHIM | dbc5db0 | 2019-05-07 12:26:29 +0200 | [diff] [blame] | 168 | } |
Alexandra Ducati-Manas | 9030f51 | 2018-11-22 09:22:43 +0100 | [diff] [blame] | 169 | |
Arach MOHAMMED BRAHIM | dbc5db0 | 2019-05-07 12:26:29 +0200 | [diff] [blame] | 170 | void hal_wrapper_send_vs_config() { |
| 171 | STLOG_HAL_V("%s - Enter", __func__); |
| 172 | set_ready(0); |
| 173 | |
| 174 | if (!HalSendDownstreamTimer(mHalHandle, nciPropGetFwDbgTracesConfig, |
| 175 | sizeof(nciPropGetFwDbgTracesConfig), 500)) { |
| 176 | STLOG_HAL_E("%s - SendDownstream failed", __func__); |
| 177 | } |
| 178 | mReadFwConfigDone = true; |
| 179 | wait_ready(); |
| 180 | } |
| 181 | |
| 182 | void hal_wrapper_send_config() { |
| 183 | hal_wrapper_send_core_config_prop(); |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 184 | mHalWrapperState = HAL_WRAPPER_STATE_PROP_CONFIG; |
Arach MOHAMMED BRAHIM | dbc5db0 | 2019-05-07 12:26:29 +0200 | [diff] [blame] | 185 | hal_wrapper_send_vs_config(); |
Alexandra Ducati-Manas | 9030f51 | 2018-11-22 09:22:43 +0100 | [diff] [blame] | 186 | } |
| 187 | |
Arach MOHAMMED BRAHIM | cf7bd92 | 2019-05-09 15:40:17 +0200 | [diff] [blame] | 188 | void hal_wrapper_factoryReset() { |
| 189 | mfactoryReset = true; |
| 190 | STLOG_HAL_V("%s - mfactoryReset = %d", __func__, mfactoryReset); |
| 191 | } |
Arach MOHAMMED BRAHIM | 0b1b8ab | 2019-05-29 18:10:20 +0200 | [diff] [blame] | 192 | |
| 193 | void hal_wrapper_update_complete() { |
| 194 | STLOG_HAL_V("%s ", __func__); |
| 195 | mHalWrapperCallback(HAL_NFC_OPEN_CPLT_EVT, HAL_NFC_STATUS_OK); |
| 196 | mHalWrapperState = HAL_WRAPPER_STATE_OPEN_CPLT; |
| 197 | } |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 198 | void halWrapperDataCallback(uint16_t data_len, uint8_t* p_data) { |
| 199 | uint8_t propNfcModeSetCmdOn[] = {0x2f, 0x02, 0x02, 0x02, 0x01}; |
| 200 | uint8_t coreInitCmd[] = {0x20, 0x01, 0x02, 0x00, 0x00}; |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 201 | uint8_t coreResetCmd[] = {0x20, 0x00, 0x01, 0x01}; |
Arach MOHAMMED BRAHIM | cb8da7f | 2019-02-15 16:20:29 +0100 | [diff] [blame] | 202 | unsigned long num = 0; |
Arach MOHAMMED BRAHIM | 53fedaa | 2020-04-15 11:58:56 +0200 | [diff] [blame] | 203 | int nciPropEnableFwDbgTraces_size = sizeof(nciPropEnableFwDbgTraces); |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 204 | |
| 205 | switch (mHalWrapperState) { |
| 206 | case HAL_WRAPPER_STATE_CLOSED: // 0 |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 207 | STLOG_HAL_V("%s - mHalWrapperState = HAL_WRAPPER_STATE_CLOSED", __func__); |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 208 | break; |
| 209 | case HAL_WRAPPER_STATE_OPEN: // 1 |
| 210 | // CORE_RESET_NTF |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 211 | STLOG_HAL_V("%s - mHalWrapperState = HAL_WRAPPER_STATE_OPEN", __func__); |
| 212 | |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 213 | if ((p_data[0] == 0x60) && (p_data[1] == 0x00)) { |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 214 | mFwUpdateTaskMask = ft_cmd_HwReset(p_data, &mClfMode); |
Arach MOHAMMED BRAHIM | cf7bd92 | 2019-05-09 15:40:17 +0200 | [diff] [blame] | 215 | |
| 216 | if (mfactoryReset == true) { |
| 217 | STLOG_HAL_V( |
| 218 | "%s - first boot after factory reset detected - start FW update", |
| 219 | __func__); |
| 220 | if ((mFwUpdateResMask & FW_PATCH_AVAILABLE) && |
| 221 | (mFwUpdateResMask & FW_CUSTOM_PARAM_AVAILABLE)) { |
| 222 | mFwUpdateTaskMask = FW_UPDATE_NEEDED | CONF_UPDATE_NEEDED; |
| 223 | mfactoryReset = false; |
| 224 | } |
| 225 | } |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 226 | STLOG_HAL_V( |
| 227 | "%s - mFwUpdateTaskMask = %d, mClfMode = %d, mRetryFwDwl = %d", |
| 228 | __func__, mFwUpdateTaskMask, mClfMode, mRetryFwDwl); |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 229 | // CLF in MODE LOADER & Update needed. |
| 230 | if (mClfMode == FT_CLF_MODE_LOADER) { |
| 231 | HalSendDownstreamStopTimer(mHalHandle); |
| 232 | STLOG_HAL_V("%s --- CLF mode is LOADER ---", __func__); |
| 233 | |
| 234 | if (mRetryFwDwl == 0) { |
| 235 | STLOG_HAL_V( |
| 236 | "%s - Reached maximum nb of retries, FW update failed, exiting", |
| 237 | __func__); |
| 238 | mHalWrapperCallback(HAL_NFC_OPEN_CPLT_EVT, HAL_NFC_STATUS_FAILED); |
| 239 | I2cCloseLayer(); |
| 240 | } else { |
| 241 | STLOG_HAL_V("%s - Send APDU_GET_ATR_CMD", __func__); |
| 242 | mRetryFwDwl--; |
| 243 | if (!HalSendDownstreamTimer(mHalHandle, ApduGetAtr, |
| 244 | sizeof(ApduGetAtr), |
| 245 | FW_TIMER_DURATION)) { |
| 246 | STLOG_HAL_E("%s - SendDownstream failed", __func__); |
| 247 | } |
| 248 | mHalWrapperState = HAL_WRAPPER_STATE_UPDATE; |
| 249 | } |
| 250 | } else if (mFwUpdateTaskMask == 0 || mRetryFwDwl == 0) { |
| 251 | STLOG_HAL_V("%s - Proceeding with normal startup", __func__); |
| 252 | if (p_data[3] == 0x01) { |
| 253 | // Normal mode, start HAL |
| 254 | mHalWrapperCallback(HAL_NFC_OPEN_CPLT_EVT, HAL_NFC_STATUS_OK); |
| 255 | mHalWrapperState = HAL_WRAPPER_STATE_OPEN_CPLT; |
| 256 | } else { |
| 257 | // No more retries or CLF not in correct mode |
| 258 | mHalWrapperCallback(HAL_NFC_OPEN_CPLT_EVT, HAL_NFC_STATUS_FAILED); |
| 259 | } |
| 260 | // CLF in MODE ROUTER & Update needed. |
| 261 | } else if (mClfMode == FT_CLF_MODE_ROUTER) { |
| 262 | if ((mFwUpdateTaskMask & FW_UPDATE_NEEDED) && |
| 263 | (mFwUpdateResMask & FW_PATCH_AVAILABLE)) { |
| 264 | STLOG_HAL_V( |
| 265 | "%s - CLF in ROUTER mode, FW update needed, try upgrade FW -", |
| 266 | __func__); |
| 267 | mRetryFwDwl--; |
| 268 | |
| 269 | if (!HalSendDownstream(mHalHandle, coreResetCmd, |
| 270 | sizeof(coreResetCmd))) { |
| 271 | STLOG_HAL_E("%s - SendDownstream failed", __func__); |
| 272 | } |
| 273 | mHalWrapperState = HAL_WRAPPER_STATE_EXIT_HIBERNATE_INTERNAL; |
| 274 | } else if ((mFwUpdateTaskMask & CONF_UPDATE_NEEDED) && |
| 275 | (mFwUpdateResMask & FW_CUSTOM_PARAM_AVAILABLE)) { |
| 276 | if (!HalSendDownstream(mHalHandle, coreResetCmd, |
| 277 | sizeof(coreResetCmd))) { |
| 278 | STLOG_HAL_E("%s - SendDownstream failed", __func__); |
| 279 | } |
| 280 | mHalWrapperState = HAL_WRAPPER_STATE_APPLY_CUSTOM_PARAM; |
| 281 | } |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 282 | } |
| 283 | } else { |
| 284 | mHalWrapperDataCallback(data_len, p_data); |
| 285 | } |
| 286 | break; |
| 287 | case HAL_WRAPPER_STATE_OPEN_CPLT: // 2 |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 288 | STLOG_HAL_V("%s - mHalWrapperState = HAL_WRAPPER_STATE_OPEN_CPLT", |
| 289 | __func__); |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 290 | // CORE_INIT_RSP |
| 291 | if ((p_data[0] == 0x40) && (p_data[1] == 0x01)) { |
| 292 | } else if ((p_data[0] == 0x60) && (p_data[1] == 0x06)) { |
Arach MOHAMMED BRAHIM | ed64c1b | 2018-07-25 16:45:04 +0200 | [diff] [blame] | 293 | STLOG_HAL_V("%s - Sending PROP_NFC_MODE_SET_CMD", __func__); |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 294 | // Send PROP_NFC_MODE_SET_CMD(ON) |
| 295 | if (!HalSendDownstreamTimer(mHalHandle, propNfcModeSetCmdOn, |
| 296 | sizeof(propNfcModeSetCmdOn), 100)) { |
Arach MOHAMMED BRAHIM | 838910b | 2018-08-16 16:05:24 +0200 | [diff] [blame] | 297 | STLOG_HAL_E("NFC-NCI HAL: %s HalSendDownstreamTimer failed", |
| 298 | __func__); |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 299 | } |
| 300 | mHalWrapperState = HAL_WRAPPER_STATE_NFC_ENABLE_ON; |
| 301 | } else { |
| 302 | mHalWrapperDataCallback(data_len, p_data); |
| 303 | } |
| 304 | break; |
Alexandra Ducati-Manas | 9030f51 | 2018-11-22 09:22:43 +0100 | [diff] [blame] | 305 | |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 306 | case HAL_WRAPPER_STATE_NFC_ENABLE_ON: // 3 |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 307 | STLOG_HAL_V("%s - mHalWrapperState = HAL_WRAPPER_STATE_NFC_ENABLE_ON", |
| 308 | __func__); |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 309 | // PROP_NFC_MODE_SET_RSP |
| 310 | if ((p_data[0] == 0x4f) && (p_data[1] == 0x02)) { |
| 311 | // DO nothing: wait for core_reset_ntf or timer timeout |
| 312 | } |
| 313 | // CORE_RESET_NTF |
| 314 | else if ((p_data[0] == 0x60) && (p_data[1] == 0x00)) { |
| 315 | // Stop timer |
| 316 | HalSendDownstreamStopTimer(mHalHandle); |
| 317 | |
| 318 | // Send CORE_INIT_CMD |
Arach MOHAMMED BRAHIM | ed64c1b | 2018-07-25 16:45:04 +0200 | [diff] [blame] | 319 | STLOG_HAL_V("%s - Sending CORE_INIT_CMD", __func__); |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 320 | if (!HalSendDownstream(mHalHandle, coreInitCmd, sizeof(coreInitCmd))) { |
Arach MOHAMMED BRAHIM | 838910b | 2018-08-16 16:05:24 +0200 | [diff] [blame] | 321 | STLOG_HAL_E("NFC-NCI HAL: %s SendDownstream failed", __func__); |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 322 | } |
| 323 | } |
| 324 | // CORE_INIT_RSP |
| 325 | else if ((p_data[0] == 0x40) && (p_data[1] == 0x01)) { |
| 326 | STLOG_HAL_D("%s - NFC mode enabled", __func__); |
Arach MOHAMMED BRAHIM | 449661b | 2018-09-24 17:02:54 +0200 | [diff] [blame] | 327 | // Do we need to lend a credit ? |
| 328 | if (p_data[13] == 0x00) { |
| 329 | STLOG_HAL_D("%s - 1 credit lent", __func__); |
| 330 | p_data[13] = 0x01; |
| 331 | mHciCreditLent = true; |
| 332 | } |
Alexandra Ducati-Manas | 9030f51 | 2018-11-22 09:22:43 +0100 | [diff] [blame] | 333 | |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 334 | mHalWrapperState = HAL_WRAPPER_STATE_READY; |
| 335 | mHalWrapperDataCallback(data_len, p_data); |
| 336 | } |
| 337 | break; |
Alexandra Ducati-Manas | 9030f51 | 2018-11-22 09:22:43 +0100 | [diff] [blame] | 338 | |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 339 | case HAL_WRAPPER_STATE_PROP_CONFIG: // 4 |
| 340 | STLOG_HAL_V("%s - mHalWrapperState = HAL_WRAPPER_STATE_PROP_CONFIG", |
| 341 | __func__); |
| 342 | // CORE_SET_CONFIG_RSP |
Alexandra Ducati-Manas | 9030f51 | 2018-11-22 09:22:43 +0100 | [diff] [blame] | 343 | if ((p_data[0] == 0x40) && (p_data[1] == 0x02)) { |
Arach MOHAMMED BRAHIM | dbc5db0 | 2019-05-07 12:26:29 +0200 | [diff] [blame] | 344 | HalSendDownstreamStopTimer(mHalHandle); |
| 345 | set_ready(1); |
| 346 | |
Arach MOHAMMED BRAHIM | cb8da7f | 2019-02-15 16:20:29 +0100 | [diff] [blame] | 347 | STLOG_HAL_V("%s - Received config RSP, read FW dDBG config", __func__); |
Alexandra Ducati-Manas | 9030f51 | 2018-11-22 09:22:43 +0100 | [diff] [blame] | 348 | } else if (mHciCreditLent && (p_data[0] == 0x60) && (p_data[1] == 0x06)) { |
Arach MOHAMMED BRAHIM | cb8da7f | 2019-02-15 16:20:29 +0100 | [diff] [blame] | 349 | // CORE_CONN_CREDITS_NTF |
Alexandra Ducati-Manas | 9030f51 | 2018-11-22 09:22:43 +0100 | [diff] [blame] | 350 | if (p_data[4] == 0x01) { // HCI connection |
| 351 | mHciCreditLent = false; |
| 352 | STLOG_HAL_D("%s - credit returned", __func__); |
| 353 | if (p_data[5] == 0x01) { |
| 354 | // no need to send this. |
| 355 | break; |
| 356 | } else { |
| 357 | if (p_data[5] != 0x00 && p_data[5] != 0xFF) { |
| 358 | // send with 1 less |
| 359 | p_data[5]--; |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | mHalWrapperDataCallback(data_len, p_data); |
Arach MOHAMMED BRAHIM | cb8da7f | 2019-02-15 16:20:29 +0100 | [diff] [blame] | 364 | } else if (p_data[0] == 0x4f) { |
| 365 | // PROP_RSP |
| 366 | if (mReadFwConfigDone == true) { |
| 367 | mReadFwConfigDone = false; |
Arach MOHAMMED BRAHIM | dbc5db0 | 2019-05-07 12:26:29 +0200 | [diff] [blame] | 368 | HalSendDownstreamStopTimer(mHalHandle); |
| 369 | set_ready(1); |
Arach MOHAMMED BRAHIM | cb8da7f | 2019-02-15 16:20:29 +0100 | [diff] [blame] | 370 | // NFC_STATUS_OK |
| 371 | if (p_data[3] == 0x00) { |
| 372 | bool confNeeded = false; |
| 373 | |
| 374 | // Check if FW DBG shall be set |
| 375 | if (GetNumValue(NAME_STNFC_FW_DEBUG_ENABLED, &num, sizeof(num))) { |
| 376 | // If conf file indicate set needed and not yet enabled |
| 377 | if ((num == 1) && (p_data[7] == 0x00)) { |
| 378 | STLOG_HAL_D("%s - FW DBG traces enabling needed", __func__); |
| 379 | nciPropEnableFwDbgTraces[9] = 0x01; |
| 380 | confNeeded = true; |
| 381 | } else if ((num == 0) && (p_data[7] == 0x01)) { |
| 382 | STLOG_HAL_D("%s - FW DBG traces disabling needed", __func__); |
| 383 | nciPropEnableFwDbgTraces[9] = 0x00; |
| 384 | confNeeded = true; |
| 385 | } else { |
| 386 | STLOG_HAL_D("%s - No changes in FW DBG traces config needed", |
| 387 | __func__); |
| 388 | } |
| 389 | |
George Chang | a009f4e | 2020-12-29 16:57:45 +0800 | [diff] [blame^] | 390 | if (data_len < 9 || p_data[6] == 0 || p_data[6] < (data_len - 7) |
| 391 | || p_data[6] > (sizeof(nciPropEnableFwDbgTraces) - 9)) { |
| 392 | if (confNeeded) { |
| 393 | android_errorWriteLog(0x534e4554, "169328517"); |
| 394 | confNeeded = false; |
| 395 | } |
| 396 | } |
| 397 | |
Arach MOHAMMED BRAHIM | cb8da7f | 2019-02-15 16:20:29 +0100 | [diff] [blame] | 398 | if (confNeeded) { |
| 399 | memcpy(nciPropEnableFwDbgTraces, nciHeaderPropSetConfig, 9); |
| 400 | memcpy(&nciPropEnableFwDbgTraces[10], &p_data[8], |
| 401 | p_data[6] - 1); |
Arach MOHAMMED BRAHIM | 53fedaa | 2020-04-15 11:58:56 +0200 | [diff] [blame] | 402 | if ((9 + p_data[6]) < sizeof(nciPropEnableFwDbgTraces)) { |
| 403 | nciPropEnableFwDbgTraces_size = 9 + p_data[6]; |
| 404 | } |
| 405 | |
Arach MOHAMMED BRAHIM | cb8da7f | 2019-02-15 16:20:29 +0100 | [diff] [blame] | 406 | confNeeded = false; |
| 407 | |
| 408 | if (!HalSendDownstream(mHalHandle, nciPropEnableFwDbgTraces, |
Arach MOHAMMED BRAHIM | 53fedaa | 2020-04-15 11:58:56 +0200 | [diff] [blame] | 409 | nciPropEnableFwDbgTraces_size)) { |
Arach MOHAMMED BRAHIM | cb8da7f | 2019-02-15 16:20:29 +0100 | [diff] [blame] | 410 | STLOG_HAL_E("%s - SendDownstream failed", __func__); |
| 411 | } |
| 412 | |
| 413 | break; |
| 414 | } |
| 415 | } |
| 416 | } |
| 417 | } |
| 418 | |
| 419 | // Exit state, all processing done |
| 420 | mHalWrapperCallback(HAL_NFC_POST_INIT_CPLT_EVT, HAL_NFC_STATUS_OK); |
| 421 | mHalWrapperState = HAL_WRAPPER_STATE_READY; |
Alexandra Ducati-Manas | 9030f51 | 2018-11-22 09:22:43 +0100 | [diff] [blame] | 422 | } |
| 423 | break; |
| 424 | |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 425 | case HAL_WRAPPER_STATE_READY: // 5 |
| 426 | STLOG_HAL_V("%s - mHalWrapperState = HAL_WRAPPER_STATE_READY", __func__); |
Arach MOHAMMED BRAHIM | 838910b | 2018-08-16 16:05:24 +0200 | [diff] [blame] | 427 | if (!((p_data[0] == 0x60) && (p_data[3] == 0xa0))) { |
Arach MOHAMMED BRAHIM | 449661b | 2018-09-24 17:02:54 +0200 | [diff] [blame] | 428 | if (mHciCreditLent && (p_data[0] == 0x60) && (p_data[1] == 0x06)) { |
| 429 | if (p_data[4] == 0x01) { // HCI connection |
| 430 | mHciCreditLent = false; |
| 431 | STLOG_HAL_D("%s - credit returned", __func__); |
| 432 | if (p_data[5] == 0x01) { |
| 433 | // no need to send this. |
| 434 | break; |
| 435 | } else { |
| 436 | if (p_data[5] != 0x00 && p_data[5] != 0xFF) { |
| 437 | // send with 1 less |
| 438 | p_data[5]--; |
| 439 | } |
| 440 | } |
| 441 | } |
Arach MOHAMMED BRAHIM | 507dcb0 | 2019-09-13 10:30:38 +0200 | [diff] [blame] | 442 | } else if ((p_data[0] == 0x6f) && (p_data[1] == 0x05)) { |
| 443 | // start timer |
| 444 | mTimerStarted = true; |
Jack Yu | b5ec429 | 2020-06-23 17:08:11 +0800 | [diff] [blame] | 445 | HalSendDownstreamTimer(mHalHandle, 5000); |
Arach MOHAMMED BRAHIM | 507dcb0 | 2019-09-13 10:30:38 +0200 | [diff] [blame] | 446 | mIsActiveRW = true; |
| 447 | } else if ((p_data[0] == 0x6f) && (p_data[1] == 0x06)) { |
| 448 | // stop timer |
| 449 | if (mTimerStarted) { |
| 450 | HalSendDownstreamStopTimer(mHalHandle); |
| 451 | mTimerStarted = false; |
| 452 | } |
| 453 | if(mIsActiveRW == true) { |
| 454 | mIsActiveRW = false; |
| 455 | } else { |
| 456 | mError_count ++; |
| 457 | STLOG_HAL_E("Error Act -> Act count=%d", mError_count); |
| 458 | if(mError_count > 20) { |
| 459 | mError_count = 0; |
| 460 | STLOG_HAL_E("NFC Recovery Start"); |
| 461 | mTimerStarted = true; |
| 462 | HalSendDownstreamTimer(mHalHandle, 1); |
| 463 | } |
| 464 | } |
| 465 | } else if (((p_data[0] == 0x61) && (p_data[1] == 0x05)) || |
| 466 | ((p_data[0] == 0x61) && (p_data[1] == 0x03))) { |
| 467 | mError_count = 0; |
| 468 | // stop timer |
| 469 | if (mTimerStarted) { |
| 470 | HalSendDownstreamStopTimer(mHalHandle); |
| 471 | mTimerStarted = false; |
| 472 | } |
Arach MOHAMMED BRAHIM | 449661b | 2018-09-24 17:02:54 +0200 | [diff] [blame] | 473 | } |
Arach MOHAMMED BRAHIM | 838910b | 2018-08-16 16:05:24 +0200 | [diff] [blame] | 474 | mHalWrapperDataCallback(data_len, p_data); |
Arach MOHAMMED BRAHIM | 507dcb0 | 2019-09-13 10:30:38 +0200 | [diff] [blame] | 475 | } else if (forceRecover == true) { |
| 476 | forceRecover = false; |
| 477 | mHalWrapperDataCallback(data_len, p_data); |
Arach MOHAMMED BRAHIM | 838910b | 2018-08-16 16:05:24 +0200 | [diff] [blame] | 478 | } else { |
| 479 | STLOG_HAL_V("%s - Core reset notification - Nfc mode ", __func__); |
| 480 | } |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 481 | break; |
Alexandra Ducati-Manas | 9030f51 | 2018-11-22 09:22:43 +0100 | [diff] [blame] | 482 | |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 483 | case HAL_WRAPPER_STATE_CLOSING: // 6 |
| 484 | STLOG_HAL_V("%s - mHalWrapperState = HAL_WRAPPER_STATE_CLOSING", |
| 485 | __func__); |
Arach MOHAMMED BRAHIM | 0b1b8ab | 2019-05-29 18:10:20 +0200 | [diff] [blame] | 486 | hal_fd_close(); |
Arach MOHAMMED BRAHIM | ef5b4d9 | 2018-09-24 16:07:04 +0200 | [diff] [blame] | 487 | if ((p_data[0] == 0x4f) && (p_data[1] == 0x02)) { |
Arach MOHAMMED BRAHIM | 7469e92 | 2018-11-29 18:47:50 +0100 | [diff] [blame] | 488 | // intercept this expected message, don t forward. |
Arach MOHAMMED BRAHIM | ef5b4d9 | 2018-09-24 16:07:04 +0200 | [diff] [blame] | 489 | mHalWrapperState = HAL_WRAPPER_STATE_CLOSED; |
Arach MOHAMMED BRAHIM | 7469e92 | 2018-11-29 18:47:50 +0100 | [diff] [blame] | 490 | } else { |
| 491 | mHalWrapperDataCallback(data_len, p_data); |
Arach MOHAMMED BRAHIM | ef5b4d9 | 2018-09-24 16:07:04 +0200 | [diff] [blame] | 492 | } |
| 493 | break; |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 494 | |
| 495 | case HAL_WRAPPER_STATE_EXIT_HIBERNATE_INTERNAL: // 6 |
| 496 | STLOG_HAL_V( |
| 497 | "%s - mHalWrapperState = HAL_WRAPPER_STATE_EXIT_HIBERNATE_INTERNAL", |
| 498 | __func__); |
| 499 | ExitHibernateHandler(mHalHandle, data_len, p_data); |
| 500 | break; |
| 501 | |
| 502 | case HAL_WRAPPER_STATE_UPDATE: // 7 |
| 503 | STLOG_HAL_V("%s - mHalWrapperState = HAL_WRAPPER_STATE_UPDATE", __func__); |
| 504 | UpdateHandler(mHalHandle, data_len, p_data); |
| 505 | break; |
| 506 | case HAL_WRAPPER_STATE_APPLY_CUSTOM_PARAM: // 8 |
| 507 | STLOG_HAL_V( |
| 508 | "%s - mHalWrapperState = HAL_WRAPPER_STATE_APPLY_CUSTOM_PARAM", |
| 509 | __func__); |
| 510 | ApplyCustomParamHandler(mHalHandle, data_len, p_data); |
| 511 | break; |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 512 | } |
| 513 | } |
| 514 | |
| 515 | static void halWrapperCallback(uint8_t event, uint8_t event_status) { |
| 516 | uint8_t coreInitCmd[] = {0x20, 0x01, 0x02, 0x00, 0x00}; |
Arach MOHAMMED BRAHIM | 507dcb0 | 2019-09-13 10:30:38 +0200 | [diff] [blame] | 517 | uint8_t propNfcModeSetCmdOn[] = {0x2f, 0x02, 0x02, 0x02, 0x01}; |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 518 | |
| 519 | switch (mHalWrapperState) { |
Arach MOHAMMED BRAHIM | b9c65c1 | 2020-08-05 10:11:11 +0200 | [diff] [blame] | 520 | case HAL_WRAPPER_STATE_CLOSING: |
| 521 | if (event == HAL_WRAPPER_TIMEOUT_EVT) { |
| 522 | STLOG_HAL_D("NFC-NCI HAL: %s Timeout. Close anyway", __func__); |
| 523 | HalSendDownstreamStopTimer(mHalHandle); |
| 524 | hal_fd_close(); |
| 525 | mHalWrapperState = HAL_WRAPPER_STATE_CLOSED; |
| 526 | return; |
| 527 | } |
| 528 | break; |
| 529 | |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 530 | case HAL_WRAPPER_STATE_CLOSED: |
Arach MOHAMMED BRAHIM | d9214f1 | 2018-11-29 14:54:52 +0100 | [diff] [blame] | 531 | if (event == HAL_WRAPPER_TIMEOUT_EVT) { |
| 532 | STLOG_HAL_D("NFC-NCI HAL: %s Timeout. Close anyway", __func__); |
| 533 | HalSendDownstreamStopTimer(mHalHandle); |
| 534 | return; |
| 535 | } |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 536 | break; |
| 537 | |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 538 | case HAL_WRAPPER_STATE_UPDATE: |
| 539 | if (event == HAL_WRAPPER_TIMEOUT_EVT) { |
| 540 | STLOG_HAL_E("%s - Timer for FW update procedure timeout, retry", |
| 541 | __func__); |
| 542 | HalSendDownstreamStopTimer(mHalHandle); |
| 543 | resetHandlerState(); |
| 544 | I2cResetPulse(); |
| 545 | mHalWrapperState = HAL_WRAPPER_STATE_OPEN; |
| 546 | } |
| 547 | break; |
| 548 | |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 549 | case HAL_WRAPPER_STATE_NFC_ENABLE_ON: |
| 550 | if (event == HAL_WRAPPER_TIMEOUT_EVT) { |
| 551 | // timeout |
| 552 | // Send CORE_INIT_CMD |
Arach MOHAMMED BRAHIM | 838910b | 2018-08-16 16:05:24 +0200 | [diff] [blame] | 553 | STLOG_HAL_V("%s - Sending CORE_INIT_CMD", __func__); |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 554 | if (!HalSendDownstream(mHalHandle, coreInitCmd, sizeof(coreInitCmd))) { |
Arach MOHAMMED BRAHIM | 838910b | 2018-08-16 16:05:24 +0200 | [diff] [blame] | 555 | STLOG_HAL_E("NFC-NCI HAL: %s SendDownstream failed", __func__); |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 556 | } |
| 557 | return; |
| 558 | } |
| 559 | break; |
Arach MOHAMMED BRAHIM | dbc5db0 | 2019-05-07 12:26:29 +0200 | [diff] [blame] | 560 | case HAL_WRAPPER_STATE_PROP_CONFIG: |
| 561 | if (event == HAL_WRAPPER_TIMEOUT_EVT) { |
| 562 | STLOG_HAL_E("%s - Timer when sending conf parameters, retry", __func__); |
| 563 | HalSendDownstreamStopTimer(mHalHandle); |
| 564 | resetHandlerState(); |
| 565 | I2cResetPulse(); |
| 566 | mHalWrapperState = HAL_WRAPPER_STATE_OPEN; |
| 567 | } |
| 568 | break; |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 569 | |
Arach MOHAMMED BRAHIM | 507dcb0 | 2019-09-13 10:30:38 +0200 | [diff] [blame] | 570 | case HAL_WRAPPER_STATE_READY: |
| 571 | if (event == HAL_WRAPPER_TIMEOUT_EVT) { |
| 572 | if (mTimerStarted) { |
| 573 | STLOG_HAL_D("NFC-NCI HAL: %s Timeout.. Recover", __func__); |
| 574 | HalSendDownstreamStopTimer(mHalHandle); |
| 575 | mTimerStarted = false; |
| 576 | forceRecover = true; |
| 577 | if (!HalSendDownstream(mHalHandle, propNfcModeSetCmdOn, |
| 578 | sizeof(propNfcModeSetCmdOn))) { |
| 579 | STLOG_HAL_E("NFC-NCI HAL: %s SendDownstream failed", __func__); |
| 580 | } |
| 581 | } |
| 582 | return; |
| 583 | } |
| 584 | break; |
| 585 | |
Arach MOHAMMED BRAHIM | 7c2cf79 | 2018-05-09 10:04:24 +0200 | [diff] [blame] | 586 | default: |
| 587 | break; |
| 588 | } |
| 589 | |
| 590 | mHalWrapperCallback(event, event_status); |
| 591 | } |
Arach MOHAMMED BRAHIM | 7238143 | 2019-02-11 18:03:27 +0100 | [diff] [blame] | 592 | |
| 593 | /******************************************************************************* |
| 594 | ** |
| 595 | ** Function nfc_set_state |
| 596 | ** |
| 597 | ** Description Set the state of NFC stack |
| 598 | ** |
| 599 | ** Returns void |
| 600 | ** |
| 601 | *******************************************************************************/ |
| 602 | void hal_wrapper_set_state(hal_wrapper_state_e new_wrapper_state) { |
| 603 | ALOGD("nfc_set_state %d->%d", mHalWrapperState, new_wrapper_state); |
| 604 | |
| 605 | mHalWrapperState = new_wrapper_state; |
| 606 | } |