• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2023 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 #include "NfcExtns.h"
19 
20 #include "phNfcStatus.h"
21 #include "phNxpConfig.h"
22 #include "phNxpNciHal_extOperations.h"
23 
24 namespace android {
25 namespace hardware {
26 namespace nfc {
27 namespace V1_1 {
28 namespace implementation {
29 
30 /******************************************************************************
31  * Function         getConfig
32  *
33  * Description      This function can be used by HAL to inform
34  *                 to update vendor configuration parameters
35  *
36  * Returns          void.
37  *
38  ******************************************************************************/
getConfig(android::hardware::nfc::V1_1::NfcConfig & config)39 void NfcExtns::getConfig(android::hardware::nfc::V1_1::NfcConfig& config) {
40   unsigned long num = 0;
41   std::array<uint8_t, NXP_MAX_CONFIG_STRING_LEN> buffer;
42   buffer.fill(0);
43   long retlen = 0;
44   memset(&config, 0x00, sizeof(android::hardware::nfc::V1_1::NfcConfig));
45   phNxpNciHal_getExtVendorConfig();
46   if (GetNxpNumValue(NAME_NFA_POLL_BAIL_OUT_MODE, &num, sizeof(num))) {
47     config.nfaPollBailOutMode = (bool)num;
48   }
49   if (GetNxpNumValue(NAME_ISO_DEP_MAX_TRANSCEIVE, &num, sizeof(num))) {
50     config.maxIsoDepTransceiveLength = (uint32_t)num;
51   }
52   if (GetNxpNumValue(NAME_DEFAULT_OFFHOST_ROUTE, &num, sizeof(num))) {
53     config.defaultOffHostRoute = (uint8_t)num;
54   }
55   if (GetNxpNumValue(NAME_DEFAULT_NFCF_ROUTE, &num, sizeof(num))) {
56     config.defaultOffHostRouteFelica = (uint8_t)num;
57   }
58   if (GetNxpNumValue(NAME_DEFAULT_SYS_CODE_ROUTE, &num, sizeof(num))) {
59     config.defaultSystemCodeRoute = (uint8_t)num;
60   }
61   if (GetNxpNumValue(NAME_DEFAULT_SYS_CODE_PWR_STATE, &num, sizeof(num))) {
62     config.defaultSystemCodePowerState =
63         phNxpNciHal_updateAutonomousPwrState((uint8_t)num);
64   }
65   if (GetNxpNumValue(NAME_DEFAULT_ROUTE, &num, sizeof(num))) {
66     config.defaultRoute = (uint8_t)num;
67   }
68   if (GetNxpByteArrayValue(NAME_DEVICE_HOST_ALLOW_LIST, (char*)buffer.data(),
69                            buffer.size(), &retlen)) {
70     config.hostWhitelist.resize(retlen);
71     for (long i = 0; i < retlen; i++) config.hostWhitelist[i] = buffer[i];
72   }
73   if (GetNxpNumValue(NAME_OFF_HOST_ESE_PIPE_ID, &num, sizeof(num))) {
74     config.offHostESEPipeId = (uint8_t)num;
75   }
76   if (GetNxpNumValue(NAME_OFF_HOST_SIM_PIPE_ID, &num, sizeof(num))) {
77     config.offHostSIMPipeId = (uint8_t)num;
78   }
79   if ((GetNxpByteArrayValue(NAME_NFA_PROPRIETARY_CFG, (char*)buffer.data(),
80                             buffer.size(), &retlen)) &&
81       (retlen == 9)) {
82     config.nfaProprietaryCfg.protocol18092Active = (uint8_t)buffer[0];
83     config.nfaProprietaryCfg.protocolBPrime = (uint8_t)buffer[1];
84     config.nfaProprietaryCfg.protocolDual = (uint8_t)buffer[2];
85     config.nfaProprietaryCfg.protocol15693 = (uint8_t)buffer[3];
86     config.nfaProprietaryCfg.protocolKovio = (uint8_t)buffer[4];
87     config.nfaProprietaryCfg.protocolMifare = (uint8_t)buffer[5];
88     config.nfaProprietaryCfg.discoveryPollKovio = (uint8_t)buffer[6];
89     config.nfaProprietaryCfg.discoveryPollBPrime = (uint8_t)buffer[7];
90     config.nfaProprietaryCfg.discoveryListenBPrime = (uint8_t)buffer[8];
91   } else {
92     memset(&config.nfaProprietaryCfg, 0xFF, sizeof(ProtocolDiscoveryConfig));
93   }
94   if ((GetNxpNumValue(NAME_PRESENCE_CHECK_ALGORITHM, &num, sizeof(num))) &&
95       (num <= 2)) {
96     config.presenceCheckAlgorithm = (PresenceCheckAlgorithm)num;
97   }
98 }
99 
100 }  // namespace implementation
101 }  // namespace V1_1
102 }  // namespace nfc
103 }  // namespace hardware
104 }  // namespace android
105