• 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.nfc.NdefMessage;
20 import android.os.Bundle;
21 
22 import java.io.IOException;
23 
24 public interface DeviceHost {
25     public interface DeviceHostListener {
onRemoteEndpointDiscovered(TagEndpoint tag)26         public void onRemoteEndpointDiscovered(TagEndpoint tag);
27 
28         /**
29          * Notifies transaction
30          */
onCardEmulationDeselected()31         public void onCardEmulationDeselected();
32 
33         /**
34          * Notifies transaction
35          */
onCardEmulationAidSelected(byte[] aid)36         public void onCardEmulationAidSelected(byte[] aid);
37 
38         /**
39          * Notifies P2P Device detected, to activate LLCP link
40          */
onLlcpLinkActivated(NfcDepEndpoint device)41         public void onLlcpLinkActivated(NfcDepEndpoint device);
42 
43         /**
44          * Notifies P2P Device detected, to activate LLCP link
45          */
onLlcpLinkDeactivated(NfcDepEndpoint device)46         public void onLlcpLinkDeactivated(NfcDepEndpoint device);
47 
onRemoteFieldActivated()48         public void onRemoteFieldActivated();
49 
onRemoteFieldDeactivated()50         public void onRemoteFieldDeactivated();
51 
onSeApduReceived(byte[] apdu)52         public void onSeApduReceived(byte[] apdu);
53 
onSeEmvCardRemoval()54         public void onSeEmvCardRemoval();
55 
onSeMifareAccess(byte[] block)56         public void onSeMifareAccess(byte[] block);
57     }
58 
59     public interface TagEndpoint {
connect(int technology)60         boolean connect(int technology);
reconnect()61         boolean reconnect();
disconnect()62         boolean disconnect();
63 
presenceCheck()64         boolean presenceCheck();
isPresent()65         boolean isPresent();
startPresenceChecking()66         void startPresenceChecking();
67 
getTechList()68         int[] getTechList();
removeTechnology(int tech)69         void removeTechnology(int tech); // TODO remove this one
getTechExtras()70         Bundle[] getTechExtras();
getUid()71         byte[] getUid();
getHandle()72         int getHandle();
73 
transceive(byte[] data, boolean raw, int[] returnCode)74         byte[] transceive(byte[] data, boolean raw, int[] returnCode);
75 
checkNdef(int[] out)76         boolean checkNdef(int[] out);
readNdef()77         byte[] readNdef();
writeNdef(byte[] data)78         boolean writeNdef(byte[] data);
findAndReadNdef()79         NdefMessage[] findAndReadNdef();
formatNdef(byte[] key)80         boolean formatNdef(byte[] key);
isNdefFormatable()81         boolean isNdefFormatable();
makeReadOnly()82         boolean makeReadOnly();
83 
getConnectedTechnology()84         int getConnectedTechnology();
85     }
86 
87     public interface NfceeEndpoint {
88         // TODO flesh out multi-EE and use this
89     }
90 
91     public interface NfcDepEndpoint {
92 
93         /**
94          * Peer-to-Peer Target
95          */
96         public static final short MODE_P2P_TARGET = 0x00;
97         /**
98          * Peer-to-Peer Initiator
99          */
100         public static final short MODE_P2P_INITIATOR = 0x01;
101         /**
102          * Invalid target mode
103          */
104         public static final short MODE_INVALID = 0xff;
105 
receive()106         public byte[] receive();
107 
send(byte[] data)108         public boolean send(byte[] data);
109 
connect()110         public boolean connect();
111 
disconnect()112         public boolean disconnect();
113 
transceive(byte[] data)114         public byte[] transceive(byte[] data);
115 
getHandle()116         public int getHandle();
117 
getMode()118         public int getMode();
119 
getGeneralBytes()120         public byte[] getGeneralBytes();
121     }
122 
123     public interface LlcpSocket {
connectToSap(int sap)124         public void connectToSap(int sap) throws IOException;
125 
connectToService(String serviceName)126         public void connectToService(String serviceName) throws IOException;
127 
close()128         public void close() throws IOException;
129 
send(byte[] data)130         public void send(byte[] data) throws IOException;
131 
receive(byte[] recvBuff)132         public int receive(byte[] recvBuff) throws IOException;
133 
getRemoteMiu()134         public int getRemoteMiu();
135 
getRemoteRw()136         public int getRemoteRw();
137 
getLocalSap()138         public int getLocalSap();
139 
getLocalMiu()140         public int getLocalMiu();
141 
getLocalRw()142         public int getLocalRw();
143     }
144 
145     public interface LlcpServerSocket {
accept()146         public LlcpSocket accept() throws IOException, LlcpException;
147 
close()148         public void close() throws IOException;
149     }
150 
151     /**
152      * Called at boot if NFC is disabled to give the device host an opportunity
153      * to check the firmware version to see if it needs updating. Normally the firmware version
154      * is checked during {@link #initialize()}, but the firmware may need to be updated after
155      * an OTA update.
156      *
157      * <p>This is called from a thread
158      * that may block for long periods of time during the update process.
159      */
checkFirmware()160     public void checkFirmware();
161 
initialize()162     public boolean initialize();
163 
deinitialize()164     public boolean deinitialize();
165 
enableDiscovery()166     public void enableDiscovery();
167 
disableDiscovery()168     public void disableDiscovery();
169 
doGetSecureElementList()170     public int[] doGetSecureElementList();
171 
doSelectSecureElement()172     public void doSelectSecureElement();
173 
doDeselectSecureElement()174     public void doDeselectSecureElement();
175 
doGetLastError()176     public int doGetLastError();
177 
createLlcpServerSocket(int nSap, String sn, int miu, int rw, int linearBufferLength)178     public LlcpServerSocket createLlcpServerSocket(int nSap, String sn, int miu,
179             int rw, int linearBufferLength) throws LlcpException;
180 
createLlcpSocket(int sap, int miu, int rw, int linearBufferLength)181     public LlcpSocket createLlcpSocket(int sap, int miu, int rw,
182             int linearBufferLength) throws LlcpException;
183 
doCheckLlcp()184     public boolean doCheckLlcp();
185 
doActivateLlcp()186     public boolean doActivateLlcp();
187 
resetTimeouts()188     public void resetTimeouts();
189 
setTimeout(int technology, int timeout)190     public boolean setTimeout(int technology, int timeout);
191 
getTimeout(int technology)192     public int getTimeout(int technology);
193 
doAbort()194     public void doAbort();
195 
canMakeReadOnly(int technology)196     boolean canMakeReadOnly(int technology);
197 
getMaxTransceiveLength(int technology)198     int getMaxTransceiveLength(int technology);
199 
dump()200     String dump();
201 }
202