nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | /****************************************************************************** |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 17 | * |
| 18 | * The original Work has been changed by NXP. |
| 19 | * |
| 20 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 21 | * you may not use this file except in compliance with the License. |
| 22 | * You may obtain a copy of the License at |
| 23 | * |
| 24 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 25 | * |
| 26 | * Unless required by applicable law or agreed to in writing, software |
| 27 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 28 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 29 | * See the License for the specific language governing permissions and |
| 30 | * limitations under the License. |
| 31 | * |
| 32 | * Copyright 2018-2019 NXP |
| 33 | * |
| 34 | ******************************************************************************/ |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 35 | package com.android.nfc; |
| 36 | |
| 37 | import android.annotation.Nullable; |
| 38 | import android.nfc.NdefMessage; |
| 39 | import android.os.Bundle; |
Nikhil Chhabra | 1e1ac46 | 2018-01-10 12:53:43 +0530 | [diff] [blame] | 40 | import java.io.FileDescriptor; |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 41 | import java.io.IOException; |
| 42 | |
| 43 | public interface DeviceHost { |
| 44 | public interface DeviceHostListener { |
| 45 | public void onRemoteEndpointDiscovered(TagEndpoint tag); |
| 46 | |
| 47 | /** |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 48 | */ |
nxpandroid | 34627bd | 2016-05-27 15:52:30 +0530 | [diff] [blame] | 49 | public void onHostCardEmulationActivated(int technology); |
| 50 | public void onHostCardEmulationData(int technology, byte[] data); |
| 51 | public void onHostCardEmulationDeactivated(int technology); |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 52 | /** |
| 53 | * Notifies that the SE has been activated in listen mode |
| 54 | */ |
| 55 | public void onSeListenActivated(); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 56 | |
| 57 | /** |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 58 | * Notifies that the SE has been deactivated |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 59 | */ |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 60 | public void onSeListenDeactivated(); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 61 | |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 62 | public void onSeInitialized(); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 63 | /** |
| 64 | * Notifies P2P Device detected, to activate LLCP link |
| 65 | */ |
| 66 | public void onLlcpLinkActivated(NfcDepEndpoint device); |
| 67 | |
| 68 | /** |
| 69 | * Notifies P2P Device detected, to activate LLCP link |
| 70 | */ |
| 71 | public void onLlcpLinkDeactivated(NfcDepEndpoint device); |
| 72 | |
| 73 | public void onLlcpFirstPacketReceived(NfcDepEndpoint device); |
| 74 | |
| 75 | public void onRemoteFieldActivated(); |
| 76 | |
| 77 | public void onRemoteFieldDeactivated(); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 78 | /** |
| 79 | * Notifies SWP Reader Events. |
| 80 | */ |
Pratap Reddy | 7e57f0d | 2018-03-15 16:54:33 +0530 | [diff] [blame] | 81 | public void onETSIReaderRequestedEvent(boolean istechA, boolean istechB); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 82 | |
Pratap Reddy | 7e57f0d | 2018-03-15 16:54:33 +0530 | [diff] [blame] | 83 | public void onETSIReaderRequestedFail(int FailCause); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 84 | |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 85 | public void onETSIReaderModeStartConfig(int eeHandle); |
| 86 | |
| 87 | public void onETSIReaderModeStopConfig(int disc_ntf_timeout); |
| 88 | |
| 89 | public void onETSIReaderModeSwpTimeout(int disc_ntf_timeout); |
nxpandroid | 34627bd | 2016-05-27 15:52:30 +0530 | [diff] [blame] | 90 | |
Pratap Reddy | 7e57f0d | 2018-03-15 16:54:33 +0530 | [diff] [blame] | 91 | public void onETSIReaderModeRestart(); |
| 92 | |
Suhas Suresh | ca6584b | 2018-04-27 17:17:22 +0530 | [diff] [blame] | 93 | public void onNfcTransactionEvent(byte[] aid, byte[] data, String seName); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | public interface TagEndpoint { |
| 97 | boolean connect(int technology); |
| 98 | boolean reconnect(); |
| 99 | boolean disconnect(); |
| 100 | |
| 101 | boolean presenceCheck(); |
| 102 | boolean isPresent(); |
| 103 | void startPresenceChecking(int presenceCheckDelay, |
| 104 | @Nullable TagDisconnectedCallback callback); |
Suhas Suresh | 5efc543 | 2018-04-27 15:31:02 +0530 | [diff] [blame] | 105 | void stopPresenceChecking(); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 106 | |
| 107 | int[] getTechList(); |
| 108 | void removeTechnology(int tech); // TODO remove this one |
| 109 | Bundle[] getTechExtras(); |
| 110 | byte[] getUid(); |
| 111 | int getHandle(); |
| 112 | |
| 113 | byte[] transceive(byte[] data, boolean raw, int[] returnCode); |
| 114 | |
| 115 | boolean checkNdef(int[] out); |
| 116 | byte[] readNdef(); |
| 117 | boolean writeNdef(byte[] data); |
| 118 | NdefMessage findAndReadNdef(); |
| 119 | boolean formatNdef(byte[] key); |
| 120 | boolean isNdefFormatable(); |
| 121 | boolean makeReadOnly(); |
| 122 | |
| 123 | int getConnectedTechnology(); |
| 124 | } |
| 125 | |
| 126 | public interface TagDisconnectedCallback { |
| 127 | void onTagDisconnected(long handle); |
| 128 | } |
| 129 | |
| 130 | public interface NfceeEndpoint { |
| 131 | // TODO flesh out multi-EE and use this |
| 132 | } |
| 133 | |
| 134 | public interface NfcDepEndpoint { |
| 135 | |
| 136 | /** |
| 137 | * Peer-to-Peer Target |
| 138 | */ |
| 139 | public static final short MODE_P2P_TARGET = 0x00; |
| 140 | /** |
| 141 | * Peer-to-Peer Initiator |
| 142 | */ |
| 143 | public static final short MODE_P2P_INITIATOR = 0x01; |
| 144 | /** |
| 145 | * Invalid target mode |
| 146 | */ |
| 147 | public static final short MODE_INVALID = 0xff; |
| 148 | |
| 149 | public byte[] receive(); |
| 150 | |
| 151 | public boolean send(byte[] data); |
| 152 | |
| 153 | public boolean connect(); |
| 154 | |
| 155 | public boolean disconnect(); |
| 156 | |
| 157 | public byte[] transceive(byte[] data); |
| 158 | |
| 159 | public int getHandle(); |
| 160 | |
| 161 | public int getMode(); |
| 162 | |
| 163 | public byte[] getGeneralBytes(); |
nxpandroid | 1153eb3 | 2015-11-06 18:46:58 +0530 | [diff] [blame] | 164 | |
| 165 | public byte getLlcpVersion(); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | public interface LlcpSocket { |
| 169 | public void connectToSap(int sap) throws IOException; |
| 170 | |
| 171 | public void connectToService(String serviceName) throws IOException; |
| 172 | |
| 173 | public void close() throws IOException; |
| 174 | |
| 175 | public void send(byte[] data) throws IOException; |
| 176 | |
| 177 | public int receive(byte[] recvBuff) throws IOException; |
| 178 | |
| 179 | public int getRemoteMiu(); |
| 180 | |
| 181 | public int getRemoteRw(); |
| 182 | |
| 183 | public int getLocalSap(); |
| 184 | |
| 185 | public int getLocalMiu(); |
| 186 | |
| 187 | public int getLocalRw(); |
| 188 | } |
| 189 | |
| 190 | public interface LlcpServerSocket { |
| 191 | public LlcpSocket accept() throws IOException, LlcpException; |
| 192 | |
| 193 | public void close() throws IOException; |
| 194 | } |
| 195 | |
| 196 | public interface LlcpConnectionlessSocket { |
| 197 | public int getLinkMiu(); |
| 198 | |
| 199 | public int getSap(); |
| 200 | |
| 201 | public void send(int sap, byte[] data) throws IOException; |
| 202 | |
| 203 | public LlcpPacket receive() throws IOException; |
| 204 | |
| 205 | public void close() throws IOException; |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * Called at boot if NFC is disabled to give the device host an opportunity |
| 210 | * to check the firmware version to see if it needs updating. Normally the firmware version |
| 211 | * is checked during {@link #initialize(boolean enableScreenOffSuspend)}, |
| 212 | * but the firmware may need to be updated after an OTA update. |
| 213 | * |
| 214 | * <p>This is called from a thread |
| 215 | * that may block for long periods of time during the update process. |
| 216 | */ |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 217 | public boolean checkFirmware(); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 218 | |
| 219 | public boolean initialize(); |
| 220 | |
| 221 | public boolean deinitialize(); |
| 222 | |
| 223 | public String getName(); |
| 224 | |
| 225 | public void enableDiscovery(NfcDiscoveryParameters params, boolean restart); |
| 226 | |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 227 | public void disableDiscovery(); |
| 228 | |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 229 | public int[] doGetActiveSecureElementList(); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 230 | public boolean sendRawFrame(byte[] data); |
| 231 | |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 232 | public boolean routeAid(byte[] aid, int route, int aidInfo, int powerState); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 233 | |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 234 | public boolean unrouteAid(byte[] aid); |
| 235 | |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 236 | public int getAidTableSize(); |
| 237 | |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 238 | public boolean setRoutingEntry(int type, int value, int route, int power); |
| 239 | |
| 240 | public boolean clearRoutingEntry(int type); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 241 | |
| 242 | public int getDefaultAidRoute(); |
| 243 | |
| 244 | public int getDefaultDesfireRoute(); |
| 245 | |
| 246 | public int getDefaultMifareCLTRoute(); |
| 247 | |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 248 | public int getDefaultFelicaCLTRoute(); |
| 249 | |
nxpandroid | a9a68ba | 2016-01-14 21:12:17 +0530 | [diff] [blame] | 250 | public int getDefaultAidPowerState(); |
| 251 | |
| 252 | public int getDefaultDesfirePowerState(); |
| 253 | |
| 254 | public int getDefaultMifareCLTPowerState(); |
| 255 | |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 256 | public int getDefaultFelicaCLTPowerState(); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 257 | |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 258 | public int getGsmaPwrState(); |
| 259 | |
| 260 | public boolean commitRouting(); |
| 261 | |
| 262 | public void setEmptyAidRoute(int defaultAidRoute); |
| 263 | |
| 264 | public void registerT3tIdentifier(byte[] t3tIdentifier); |
| 265 | |
| 266 | public void deregisterT3tIdentifier(byte[] t3tIdentifier); |
| 267 | |
| 268 | public void clearT3tIdentifiersCache(); |
| 269 | |
| 270 | public int getLfT3tMax(); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 271 | |
nxpandroid | e00bc1a | 2017-07-12 21:39:16 +0530 | [diff] [blame] | 272 | public boolean routeApduPattern(int route, int powerState, byte[] apduData, byte[] apduMask); |
| 273 | |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 274 | public LlcpConnectionlessSocket createLlcpConnectionlessSocket(int nSap, String sn) |
| 275 | throws LlcpException; |
| 276 | |
| 277 | public LlcpServerSocket createLlcpServerSocket(int nSap, String sn, int miu, |
| 278 | int rw, int linearBufferLength) throws LlcpException; |
| 279 | |
| 280 | public LlcpSocket createLlcpSocket(int sap, int miu, int rw, |
| 281 | int linearBufferLength) throws LlcpException; |
| 282 | |
nxpandroid | e00bc1a | 2017-07-12 21:39:16 +0530 | [diff] [blame] | 283 | public boolean unrouteApduPattern(byte[] apduData); |
| 284 | |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 285 | public boolean doCheckLlcp(); |
| 286 | |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 287 | public boolean doActivateLlcp(); |
| 288 | |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 289 | public void resetTimeouts(); |
| 290 | |
| 291 | public boolean setTimeout(int technology, int timeout); |
| 292 | |
| 293 | public int getTimeout(int technology); |
| 294 | |
nxpandroid | 6fd9cdb | 2017-07-12 18:25:41 +0530 | [diff] [blame] | 295 | public void doAbort(String msg); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 296 | |
| 297 | boolean canMakeReadOnly(int technology); |
| 298 | |
| 299 | int getMaxTransceiveLength(int technology); |
| 300 | |
| 301 | void setP2pInitiatorModes(int modes); |
| 302 | |
| 303 | void setP2pTargetModes(int modes); |
| 304 | |
| 305 | boolean getExtendedLengthApdusSupported(); |
| 306 | |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 307 | int getDefaultLlcpMiu(); |
| 308 | |
| 309 | int getDefaultLlcpRwSize(); |
| 310 | |
Nikhil Chhabra | 1e1ac46 | 2018-01-10 12:53:43 +0530 | [diff] [blame] | 311 | void dump(FileDescriptor fd); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 312 | |
| 313 | boolean enableScreenOffSuspend(); |
| 314 | |
| 315 | boolean disableScreenOffSuspend(); |
| 316 | |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 317 | public void doSetScreenState(int screen_state_mask); |
nxpandroid | 281eb92 | 2016-08-25 20:27:46 +0530 | [diff] [blame] | 318 | |
Ganesh Deva | 1ad7d6f | 2019-06-17 11:46:02 +0530 | [diff] [blame^] | 319 | public void doResonantFrequency(boolean isResonantFreq); |
| 320 | |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 321 | void setEtsiReaederState(int newState); |
| 322 | |
| 323 | int getEtsiReaederState(); |
| 324 | |
| 325 | void etsiReaderConfig(int eeHandle); |
| 326 | |
| 327 | void etsiResetReaderConfig(); |
| 328 | |
| 329 | void notifyEEReaderEvent(int evt); |
| 330 | |
| 331 | void etsiInitConfig(); |
| 332 | |
Pratap Reddy | 7e57f0d | 2018-03-15 16:54:33 +0530 | [diff] [blame] | 333 | void stopPoll(int mode); |
| 334 | |
| 335 | void startPoll(); |
| 336 | |
| 337 | int mposSetReaderMode(boolean on); |
| 338 | |
Pratap Reddy | 49abbe3 | 2018-03-27 16:51:59 +0530 | [diff] [blame] | 339 | boolean mposGetReaderMode(); |
| 340 | |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 341 | public int getNciVersion(); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 342 | |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 343 | public void enableDtaMode(); |
| 344 | |
| 345 | public void disableDtaMode(); |
| 346 | |
Suhas Suresh | 1fe09dc | 2018-05-07 11:55:06 +0530 | [diff] [blame] | 347 | public void factoryReset(); |
| 348 | |
Suhas Suresh | c9772c8 | 2018-04-27 15:41:19 +0530 | [diff] [blame] | 349 | public void shutdown(); |
| 350 | |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 351 | public boolean setNfcSecure(boolean enable); |
| 352 | |
| 353 | /* NXP extension are here */ |
| 354 | public void doChangeDiscoveryTech(int pollTech, int listenTech); |
Anil Hiranniah | c180591 | 2019-05-15 21:49:59 +0530 | [diff] [blame] | 355 | public boolean accessControlForCOSU (int mode); |
nxf50051 | 3a018e7 | 2019-04-23 17:11:41 +0530 | [diff] [blame] | 356 | |
| 357 | public int getFWVersion(); |
| 358 | public byte[] readerPassThruMode(byte status, byte modulationTyp); |
| 359 | public byte[] transceiveAppData(byte[] data); |
| 360 | boolean isNfccBusy(); |
| 361 | int setTransitConfig(String configs); |
| 362 | public int getRemainingAidTableSize(); |
nxpandroid | 34627bd | 2016-05-27 15:52:30 +0530 | [diff] [blame] | 363 | public int doselectUicc(int uiccSlot); |
nxpandroid | 34627bd | 2016-05-27 15:52:30 +0530 | [diff] [blame] | 364 | public int doGetSelectedUicc(); |
nxpandroid | ebf53fb | 2016-12-22 18:48:59 +0530 | [diff] [blame] | 365 | public int setPreferredSimSlot(int uiccSlot); |
Suhas Suresh | f2aa04f | 2019-06-14 17:55:46 +0530 | [diff] [blame] | 366 | public int doSetFieldDetectMode(boolean mode); |
| 367 | public boolean isFieldDetectEnabled(); |
nxpandroid | 64fd68c | 2015-09-23 16:45:15 +0530 | [diff] [blame] | 368 | } |