DeviceHost.java revision 358d8b6ad611aba11e69a3b1dd9d132dbc9a7605
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 17package com.android.nfc; 18 19import com.android.nfc.nxp.NativeLlcpConnectionlessSocket; 20import com.android.nfc.nxp.NativeLlcpServiceSocket; 21import com.android.nfc.nxp.NativeLlcpSocket; 22 23import android.nfc.NdefMessage; 24import android.os.Bundle; 25 26public interface DeviceHost { 27 public interface DeviceHostListener { 28 public void onRemoteEndpointDiscovered(TagEndpoint tag); 29 30 /** 31 * Notifies transaction 32 */ 33 public void onCardEmulationDeselected(); 34 35 /** 36 * Notifies transaction 37 */ 38 public void onCardEmulationAidSelected(byte[] aid); 39 40 /** 41 * Notifies P2P Device detected, to activate LLCP link 42 */ 43 public void onLlcpLinkActivated(NfcDepEndpoint device); 44 45 /** 46 * Notifies P2P Device detected, to activate LLCP link 47 */ 48 public void onLlcpLinkDeactivated(NfcDepEndpoint device); 49 50 public void onRemoteFieldActivated(); 51 52 public void onRemoteFieldDeactivated(); 53 54 public void onSeApduReceived(byte[] apdu); 55 56 public void onSeEmvCardRemoval(); 57 58 public void onSeMifareAccess(byte[] block); 59 } 60 61 public interface TagEndpoint { 62 boolean connect(int technology); 63 boolean reconnect(); 64 boolean disconnect(); 65 66 boolean presenceCheck(); 67 boolean isPresent(); 68 void startPresenceChecking(); 69 70 int[] getTechList(); 71 void removeTechnology(int tech); // TODO remove this one 72 Bundle[] getTechExtras(); 73 byte[] getUid(); 74 int getHandle(); 75 76 byte[] transceive(byte[] data, boolean raw, int[] returnCode); 77 78 boolean checkNdef(int[] out); 79 byte[] readNdef(); 80 boolean writeNdef(byte[] data); 81 NdefMessage[] findAndReadNdef(); 82 boolean formatNdef(byte[] key); 83 boolean isNdefFormatable(); 84 boolean makeReadOnly(); 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 106 public byte[] receive(); 107 108 public boolean send(byte[] data); 109 110 public boolean connect(); 111 112 public boolean disconnect(); 113 114 public byte[] transceive(byte[] data); 115 116 public int getHandle(); 117 118 public int getMode(); 119 120 public byte[] getGeneralBytes(); 121 } 122 123 public boolean initialize(); 124 125 public boolean deinitialize(); 126 127 public void enableDiscovery(); 128 129 public void disableDiscovery(); 130 131 public int[] doGetSecureElementList(); 132 133 public void doSelectSecureElement(); 134 135 public void doDeselectSecureElement(); 136 137 public int doGetLastError(); 138 139 public NativeLlcpConnectionlessSocket doCreateLlcpConnectionlessSocket(int nSap); 140 141 public NativeLlcpServiceSocket doCreateLlcpServiceSocket(int nSap, String sn, int miu, 142 int rw, int linearBufferLength); 143 144 public NativeLlcpSocket doCreateLlcpSocket(int sap, int miu, int rw, 145 int linearBufferLength); 146 147 public boolean doCheckLlcp(); 148 149 public boolean doActivateLlcp(); 150 151 public void resetTimeouts(); 152 153 public boolean setTimeout(int technology, int timeout); 154 155 public int getTimeout(int technology); 156} 157