blob: 6799241607b3810a768a11f0c9c76b4744a77c3b [file] [log] [blame]
nxpandroid64fd68c2015-09-23 16:45:15 +05301/*
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/******************************************************************************
nxf500513a018e72019-04-23 17:11:41 +053017*
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******************************************************************************/
nxpandroid64fd68c2015-09-23 16:45:15 +053035package com.android.nfc;
36
37import android.annotation.Nullable;
38import android.nfc.NdefMessage;
39import android.os.Bundle;
Nikhil Chhabra1e1ac462018-01-10 12:53:43 +053040import java.io.FileDescriptor;
nxpandroid64fd68c2015-09-23 16:45:15 +053041import java.io.IOException;
42
43public interface DeviceHost {
44 public interface DeviceHostListener {
45 public void onRemoteEndpointDiscovered(TagEndpoint tag);
46
47 /**
nxpandroid64fd68c2015-09-23 16:45:15 +053048 */
nxpandroid34627bd2016-05-27 15:52:30 +053049 public void onHostCardEmulationActivated(int technology);
50 public void onHostCardEmulationData(int technology, byte[] data);
51 public void onHostCardEmulationDeactivated(int technology);
nxf500513a018e72019-04-23 17:11:41 +053052 /**
53 * Notifies that the SE has been activated in listen mode
54 */
55 public void onSeListenActivated();
nxpandroid64fd68c2015-09-23 16:45:15 +053056
57 /**
nxf500513a018e72019-04-23 17:11:41 +053058 * Notifies that the SE has been deactivated
nxpandroid64fd68c2015-09-23 16:45:15 +053059 */
nxf500513a018e72019-04-23 17:11:41 +053060 public void onSeListenDeactivated();
nxpandroid64fd68c2015-09-23 16:45:15 +053061
nxf500513a018e72019-04-23 17:11:41 +053062 public void onSeInitialized();
nxpandroid64fd68c2015-09-23 16:45:15 +053063 /**
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();
nxpandroid64fd68c2015-09-23 16:45:15 +053078 /**
79 * Notifies SWP Reader Events.
80 */
Pratap Reddy7e57f0d2018-03-15 16:54:33 +053081 public void onETSIReaderRequestedEvent(boolean istechA, boolean istechB);
nxpandroid64fd68c2015-09-23 16:45:15 +053082
Pratap Reddy7e57f0d2018-03-15 16:54:33 +053083 public void onETSIReaderRequestedFail(int FailCause);
nxpandroid64fd68c2015-09-23 16:45:15 +053084
nxpandroid64fd68c2015-09-23 16:45:15 +053085 public void onETSIReaderModeStartConfig(int eeHandle);
86
87 public void onETSIReaderModeStopConfig(int disc_ntf_timeout);
88
89 public void onETSIReaderModeSwpTimeout(int disc_ntf_timeout);
nxpandroid34627bd2016-05-27 15:52:30 +053090
Pratap Reddy7e57f0d2018-03-15 16:54:33 +053091 public void onETSIReaderModeRestart();
92
Suhas Sureshca6584b2018-04-27 17:17:22 +053093 public void onNfcTransactionEvent(byte[] aid, byte[] data, String seName);
nxpandroid64fd68c2015-09-23 16:45:15 +053094 }
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 Suresh5efc5432018-04-27 15:31:02 +0530105 void stopPresenceChecking();
nxpandroid64fd68c2015-09-23 16:45:15 +0530106
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();
nxpandroid1153eb32015-11-06 18:46:58 +0530164
165 public byte getLlcpVersion();
nxpandroid64fd68c2015-09-23 16:45:15 +0530166 }
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 */
nxf500513a018e72019-04-23 17:11:41 +0530217 public boolean checkFirmware();
nxpandroid64fd68c2015-09-23 16:45:15 +0530218
219 public boolean initialize();
220
221 public boolean deinitialize();
222
223 public String getName();
224
225 public void enableDiscovery(NfcDiscoveryParameters params, boolean restart);
226
nxpandroid64fd68c2015-09-23 16:45:15 +0530227 public void disableDiscovery();
228
nxpandroid64fd68c2015-09-23 16:45:15 +0530229 public int[] doGetActiveSecureElementList();
nxpandroid64fd68c2015-09-23 16:45:15 +0530230 public boolean sendRawFrame(byte[] data);
231
nxf500513a018e72019-04-23 17:11:41 +0530232 public boolean routeAid(byte[] aid, int route, int aidInfo, int powerState);
nxpandroid64fd68c2015-09-23 16:45:15 +0530233
nxpandroid64fd68c2015-09-23 16:45:15 +0530234 public boolean unrouteAid(byte[] aid);
235
nxpandroid64fd68c2015-09-23 16:45:15 +0530236 public int getAidTableSize();
237
nxf500513a018e72019-04-23 17:11:41 +0530238 public boolean setRoutingEntry(int type, int value, int route, int power);
239
240 public boolean clearRoutingEntry(int type);
nxpandroid64fd68c2015-09-23 16:45:15 +0530241
242 public int getDefaultAidRoute();
243
244 public int getDefaultDesfireRoute();
245
246 public int getDefaultMifareCLTRoute();
247
nxf500513a018e72019-04-23 17:11:41 +0530248 public int getDefaultFelicaCLTRoute();
249
nxpandroida9a68ba2016-01-14 21:12:17 +0530250 public int getDefaultAidPowerState();
251
252 public int getDefaultDesfirePowerState();
253
254 public int getDefaultMifareCLTPowerState();
255
nxf500513a018e72019-04-23 17:11:41 +0530256 public int getDefaultFelicaCLTPowerState();
nxpandroid64fd68c2015-09-23 16:45:15 +0530257
nxf500513a018e72019-04-23 17:11:41 +0530258 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();
nxpandroid64fd68c2015-09-23 16:45:15 +0530271
272 public LlcpConnectionlessSocket createLlcpConnectionlessSocket(int nSap, String sn)
273 throws LlcpException;
274
275 public LlcpServerSocket createLlcpServerSocket(int nSap, String sn, int miu,
276 int rw, int linearBufferLength) throws LlcpException;
277
278 public LlcpSocket createLlcpSocket(int sap, int miu, int rw,
279 int linearBufferLength) throws LlcpException;
280
281 public boolean doCheckLlcp();
282
nxpandroid64fd68c2015-09-23 16:45:15 +0530283 public boolean doActivateLlcp();
284
nxpandroid64fd68c2015-09-23 16:45:15 +0530285 public void resetTimeouts();
286
287 public boolean setTimeout(int technology, int timeout);
288
289 public int getTimeout(int technology);
290
nxpandroid6fd9cdb2017-07-12 18:25:41 +0530291 public void doAbort(String msg);
nxpandroid64fd68c2015-09-23 16:45:15 +0530292
293 boolean canMakeReadOnly(int technology);
294
295 int getMaxTransceiveLength(int technology);
296
297 void setP2pInitiatorModes(int modes);
298
299 void setP2pTargetModes(int modes);
300
301 boolean getExtendedLengthApdusSupported();
302
nxpandroid64fd68c2015-09-23 16:45:15 +0530303 int getDefaultLlcpMiu();
304
305 int getDefaultLlcpRwSize();
306
Nikhil Chhabra1e1ac462018-01-10 12:53:43 +0530307 void dump(FileDescriptor fd);
nxpandroid64fd68c2015-09-23 16:45:15 +0530308
309 boolean enableScreenOffSuspend();
310
311 boolean disableScreenOffSuspend();
312
nxf500513a018e72019-04-23 17:11:41 +0530313 public void doSetScreenState(int screen_state_mask);
nxpandroid281eb922016-08-25 20:27:46 +0530314
Ganesh Deva1ad7d6f2019-06-17 11:46:02 +0530315 public void doResonantFrequency(boolean isResonantFreq);
316
nxpandroid64fd68c2015-09-23 16:45:15 +0530317 void setEtsiReaederState(int newState);
318
319 int getEtsiReaederState();
320
321 void etsiReaderConfig(int eeHandle);
322
323 void etsiResetReaderConfig();
324
325 void notifyEEReaderEvent(int evt);
326
327 void etsiInitConfig();
328
Pratap Reddy7e57f0d2018-03-15 16:54:33 +0530329 void stopPoll(int mode);
330
331 void startPoll();
332
333 int mposSetReaderMode(boolean on);
334
Pratap Reddy49abbe32018-03-27 16:51:59 +0530335 boolean mposGetReaderMode();
336
nxf500513a018e72019-04-23 17:11:41 +0530337 public int getNciVersion();
nxpandroid64fd68c2015-09-23 16:45:15 +0530338
nxpandroid64fd68c2015-09-23 16:45:15 +0530339 public void enableDtaMode();
340
341 public void disableDtaMode();
342
Suhas Suresh1fe09dc2018-05-07 11:55:06 +0530343 public void factoryReset();
344
Suhas Sureshc9772c82018-04-27 15:41:19 +0530345 public void shutdown();
346
nxf500513a018e72019-04-23 17:11:41 +0530347 public boolean setNfcSecure(boolean enable);
348
349/* NXP extension are here */
350 public void doChangeDiscoveryTech(int pollTech, int listenTech);
Anil Hiranniahc1805912019-05-15 21:49:59 +0530351 public boolean accessControlForCOSU (int mode);
nxf500513a018e72019-04-23 17:11:41 +0530352
353 public int getFWVersion();
354 public byte[] readerPassThruMode(byte status, byte modulationTyp);
355 public byte[] transceiveAppData(byte[] data);
356 boolean isNfccBusy();
357 int setTransitConfig(String configs);
358 public int getRemainingAidTableSize();
nxpandroid34627bd2016-05-27 15:52:30 +0530359 public int doselectUicc(int uiccSlot);
nxpandroid34627bd2016-05-27 15:52:30 +0530360 public int doGetSelectedUicc();
nxpandroidebf53fb2016-12-22 18:48:59 +0530361 public int setPreferredSimSlot(int uiccSlot);
Suhas Sureshf2aa04f2019-06-14 17:55:46 +0530362 public int doSetFieldDetectMode(boolean mode);
363 public boolean isFieldDetectEnabled();
nxpandroid64fd68c2015-09-23 16:45:15 +0530364}