• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.android.nfc;
18 
19 import android.annotation.Nullable;
20 import android.nfc.NdefMessage;
21 import android.nfc.cardemulation.PollingFrame;
22 import android.os.Bundle;
23 
24 import java.io.FileDescriptor;
25 import java.io.PrintWriter;
26 import java.util.List;
27 import java.util.Map;
28 
29 public interface DeviceHost {
30     public interface DeviceHostListener {
onRemoteEndpointDiscovered(TagEndpoint tag)31         public void onRemoteEndpointDiscovered(TagEndpoint tag);
32 
33         /**
34          */
onHostCardEmulationActivated(int technology)35         public void onHostCardEmulationActivated(int technology);
onHostCardEmulationData(int technology, byte[] data)36         public void onHostCardEmulationData(int technology, byte[] data);
onHostCardEmulationDeactivated(int technology)37         public void onHostCardEmulationDeactivated(int technology);
38 
onRemoteFieldActivated()39         public void onRemoteFieldActivated();
40 
onRemoteFieldDeactivated()41         public void onRemoteFieldDeactivated();
42 
onNfcTransactionEvent(byte[] aid, byte[] data, String seName)43         public void onNfcTransactionEvent(byte[] aid, byte[] data, String seName);
44 
onEeUpdated()45         public void onEeUpdated();
46 
onHwErrorReported()47         public void onHwErrorReported();
48 
onPollingLoopDetected(List<PollingFrame> pollingFrames)49         public void onPollingLoopDetected(List<PollingFrame> pollingFrames);
50 
onObserveModeEnabledInFirmware()51         public void onObserveModeEnabledInFirmware();
52 
onObserveModeDisabledInFirmware(PollingFrame exitFrame)53         public void onObserveModeDisabledInFirmware(PollingFrame exitFrame);
54 
onWlcStopped(int wpt_end_condition)55         public void onWlcStopped(int wpt_end_condition);
56 
onTagRfDiscovered(boolean discovered)57         public void onTagRfDiscovered(boolean discovered);
58 
onVendorSpecificEvent(int gid, int oid, byte[] payload)59         public void onVendorSpecificEvent(int gid, int oid, byte[] payload);
60 
onObserveModeStateChanged(boolean enable)61         public void onObserveModeStateChanged(boolean enable);
62 
onRfDiscoveryEvent(boolean isDiscoveryStarted)63         public void onRfDiscoveryEvent(boolean isDiscoveryStarted);
64 
onEeListenActivated(boolean isActivated)65         public void onEeListenActivated(boolean isActivated);
66 
onSeSelected(int type)67         public void onSeSelected(int type);
68 
onCommandTimeout()69         public void onCommandTimeout();
70 
onEndpointRemoved(int reason)71         public void onEndpointRemoved(int reason);
72 
73         /**
74          * On Restart Rf Discovery
75          */
onRestartRfDiscovery()76         void onRestartRfDiscovery();
77     }
78 
79     public interface TagEndpoint {
connect(int technology)80         boolean connect(int technology);
reconnect()81         boolean reconnect();
disconnect()82         boolean disconnect();
83 
presenceCheck()84         boolean presenceCheck();
isPresent()85         boolean isPresent();
startPresenceChecking(int presenceCheckDelay, @Nullable TagDisconnectedCallback callback)86         void startPresenceChecking(int presenceCheckDelay,
87                                    @Nullable TagDisconnectedCallback callback);
stopPresenceChecking()88         void stopPresenceChecking();
isPresenceCheckStopped()89         boolean isPresenceCheckStopped();
prepareForRemovalDetectionMode()90         void prepareForRemovalDetectionMode();
91 
getTechList()92         int[] getTechList();
removeTechnology(int tech)93         void removeTechnology(int tech); // TODO remove this one
getTechExtras()94         Bundle[] getTechExtras();
getUid()95         byte[] getUid();
getHandle()96         int getHandle();
97 
transceive(byte[] data, boolean raw, int[] returnCode)98         byte[] transceive(byte[] data, boolean raw, int[] returnCode);
99 
checkNdef(int[] out)100         boolean checkNdef(int[] out);
readNdef()101         byte[] readNdef();
writeNdef(byte[] data)102         boolean writeNdef(byte[] data);
findAndReadNdef()103         NdefMessage findAndReadNdef();
getNdef()104         NdefMessage getNdef();
formatNdef(byte[] key)105         boolean formatNdef(byte[] key);
isNdefFormatable()106         boolean isNdefFormatable();
makeReadOnly()107         boolean makeReadOnly();
108 
getConnectedTechnology()109         int getConnectedTechnology();
110 
111         /**
112          * Find Ndef only
113          * As per NFC forum test specification ndef write test expects only
114          * ndef detection followed by ndef write. System property
115          * nfc.dta.skipNdefRead added to skip default ndef read before tag
116          * dispatch. This system property is valid only in reader mode.
117          */
findNdef()118         void findNdef();
119     }
120 
121     public interface TagDisconnectedCallback {
onTagDisconnected()122         void onTagDisconnected();
123     }
124 
125     public interface NfceeEndpoint {
126         // TODO flesh out multi-EE and use this
127     }
128 
129     public interface NfcDepEndpoint {
130         /**
131          * Invalid target mode
132          */
133         public static final short MODE_INVALID = 0xff;
134 
receive()135         public byte[] receive();
136 
send(byte[] data)137         public boolean send(byte[] data);
138 
connect()139         public boolean connect();
140 
disconnect()141         public boolean disconnect();
142 
transceive(byte[] data)143         public byte[] transceive(byte[] data);
144 
getHandle()145         public int getHandle();
146 
getMode()147         public int getMode();
148 
getGeneralBytes()149         public byte[] getGeneralBytes();
150     }
151 
152     /**
153      * Called at boot if NFC is disabled to give the device host an opportunity
154      * to check the firmware version to see if it needs updating. Normally the firmware version
155      * is checked during {@link #initialize(boolean enableScreenOffSuspend)},
156      * but the firmware may need to be updated after an OTA update.
157      *
158      * <p>This is called from a thread
159      * that may block for long periods of time during the update process.
160      */
checkFirmware()161     public boolean checkFirmware();
162 
initialize()163     public boolean initialize();
164 
setPartialInitMode(int mode)165     public void setPartialInitMode(int mode);
166 
deinitialize()167     public boolean deinitialize();
168 
getName()169     public String getName();
170 
enableDiscovery(NfcDiscoveryParameters params, boolean restart)171     public void enableDiscovery(NfcDiscoveryParameters params, boolean restart);
172 
disableDiscovery()173     public void disableDiscovery();
174 
sendRawFrame(byte[] data)175     public boolean sendRawFrame(byte[] data);
176 
routeAid(byte[] aid, int route, int aidInfo, int power)177     public boolean routeAid(byte[] aid, int route, int aidInfo, int power);
178 
unrouteAid(byte[] aid)179     public boolean unrouteAid(byte[] aid);
180 
commitRouting()181     public int commitRouting();
182 
183     /**
184      * Get the T4T Nfcee power state supported.
185      * @return T4T Nfcee power state
186      */
getT4TNfceePowerState()187     int getT4TNfceePowerState();
188 
189     /**
190      * Get the NDEF NFCEE Route ID.
191      * @return NDEF NFCEE Route ID
192      */
getNdefNfceeRouteId()193     int getNdefNfceeRouteId();
194 
195     /**
196      * Write the data into the NDEF NFCEE file of the specific file ID
197      * @param fileId file id to write to
198      * @param data data to write
199      * @return number of data bytes written
200      */
doWriteData(byte[] fileId, byte[] data)201     int doWriteData(byte[] fileId, byte[] data);
202 
203     /**
204      * Read the data from the NDEF NFCEE file of the specific file ID.
205      * @param fileId file id to read from
206      * @return read data buffer
207      */
doReadData(byte[] fileId)208     byte[] doReadData(byte[] fileId);
209 
210     /**
211      * This API will set all the NFCEE NDEF data to zero.
212      * @return "True" when operation is successful. else "False"
213      */
doClearNdefData()214     boolean doClearNdefData();
215 
216     /**
217      * This API will get NDEF NFCEE status.
218      * @return Indicates whether NDEF NFCEE Read or write operation is under process
219      *         Return "True" when operation is in progress. else "False"
220      */
isNdefOperationOngoing()221     boolean isNdefOperationOngoing();
222 
223     /**
224      * This API will tell whether NDEF NFCEE emulation is supported or not.
225      * @return "True" when feature supported. else "False"
226      */
isNdefNfceeEmulationSupported()227     boolean isNdefNfceeEmulationSupported();
228 
229     /**
230      * This API will tell whether T4T_NFCEE_ENABLE is declared in the HAL configuration file.
231      * @return "True" when declare, else "False"
232      */
isNdefNfceefeatureEnabled()233     boolean isNdefNfceefeatureEnabled();
234 
registerT3tIdentifier(byte[] t3tIdentifier)235     public void registerT3tIdentifier(byte[] t3tIdentifier);
236 
deregisterT3tIdentifier(byte[] t3tIdentifier)237     public void deregisterT3tIdentifier(byte[] t3tIdentifier);
238 
clearT3tIdentifiersCache()239     public void clearT3tIdentifiersCache();
240 
getLfT3tMax()241     public int getLfT3tMax();
242 
resetTimeouts()243     public void resetTimeouts();
244 
setTimeout(int technology, int timeout)245     public boolean setTimeout(int technology, int timeout);
246 
getTimeout(int technology)247     public int getTimeout(int technology);
248 
doAbort(String msg)249     public void doAbort(String msg);
250 
canMakeReadOnly(int technology)251     boolean canMakeReadOnly(int technology);
252 
getMaxTransceiveLength(int technology)253     int getMaxTransceiveLength(int technology);
254 
getAidTableSize()255     public int getAidTableSize();
256 
getExtendedLengthApdusSupported()257     boolean getExtendedLengthApdusSupported();
258 
dump(PrintWriter pw, FileDescriptor fd)259     void dump(PrintWriter pw, FileDescriptor fd);
260 
doSetScreenState(int screen_state_mask, boolean alwaysPoll)261     public void doSetScreenState(int screen_state_mask, boolean alwaysPoll);
262 
getNciVersion()263     public int getNciVersion();
264 
enableDtaMode()265     public void enableDtaMode();
266 
disableDtaMode()267     public void disableDtaMode();
268 
factoryReset()269     public void factoryReset();
270 
shutdown()271     public void shutdown();
272 
setNfcSecure(boolean enable)273     public boolean setNfcSecure(boolean enable);
274 
isReaderModeAnnotationSupported()275     public boolean isReaderModeAnnotationSupported();
276 
isObserveModeSupported()277     public boolean isObserveModeSupported();
278 
setObserveMode(boolean enable)279     public boolean setObserveMode(boolean enable);
280 
isObserveModeEnabled()281     public boolean isObserveModeEnabled();
282 
isFirmwareExitFramesSupported()283     public boolean isFirmwareExitFramesSupported();
284 
getNumberOfFirmwareExitFramesSupported()285     public int getNumberOfFirmwareExitFramesSupported();
286 
setFirmwareExitFrameTable(ExitFrame[] exitFrames, byte[] timeoutMs)287     public boolean setFirmwareExitFrameTable(ExitFrame[] exitFrames, byte[] timeoutMs);
288 
289     /**
290     * Get the committed listen mode routing configuration
291     */
getRoutingTable()292     byte[] getRoutingTable();
293 
294     /**
295     * Get the Max Routing Table size from cache
296     */
getMaxRoutingTableSize()297     int getMaxRoutingTableSize();
298 
299     /**
300     * Start or stop RF polling
301     */
startStopPolling(boolean enable)302     void startStopPolling(boolean enable);
303 
304     /**
305     * Set NFCC power state by sending NFCEE_POWER_AND_LINK_CNTRL_CMD
306     */
setNfceePowerAndLinkCtrl(boolean enable)307     void setNfceePowerAndLinkCtrl(boolean enable);
308 
309     /**
310      * Enable or Disable the Power Saving Mode based on flag
311      */
setPowerSavingMode(boolean flag)312     boolean setPowerSavingMode(boolean flag);
313 
isMultiTag()314     boolean isMultiTag();
315 
setIsoDepProtocolRoute(int route)316     void setIsoDepProtocolRoute(int route);
317     /**
318     * Set NFCC technology routing for ABF listening
319     */
setTechnologyABFRoute(int route, int felicaRoute)320     void setTechnologyABFRoute(int route, int felicaRoute);
setSystemCodeRoute(int route)321     void setSystemCodeRoute(int route);
clearRoutingEntry(int clearFlags)322     void clearRoutingEntry(int clearFlags);
323 
324     /**
325     * Set NFCC discovery technology for polling and listening
326     */
setDiscoveryTech(int pollTech, int listenTech)327     void setDiscoveryTech(int pollTech, int listenTech);
resetDiscoveryTech()328     void resetDiscoveryTech();
329     /**
330      * Sends Vendor NCI command
331      */
332 
sendRawVendorCmd(int mt, int gid, int oid, byte[] payload)333     NfcVendorNciResponse sendRawVendorCmd(int mt, int gid, int oid, byte[] payload);
334 
detectEpRemoval(int waiting_time_int)335     public boolean detectEpRemoval(int waiting_time_int);
336 
enableVendorNciNotifications(boolean enabled)337     void enableVendorNciNotifications(boolean enabled);
338 
339     /**
340      * Get the active NFCEE list
341      */
dofetchActiveNfceeList()342     public Map<String, Integer> dofetchActiveNfceeList();
isRemovalDetectionInPollModeSupported()343     public boolean isRemovalDetectionInPollModeSupported();
344     /**
345      * Restarts RF Discovery
346      */
restartRfDiscovery()347     void restartRfDiscovery();
348 }
349