diff options
author | Martijn Coenen <maco@google.com> | 2012-01-27 12:27:08 -0800 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2012-01-27 13:24:23 -0800 |
commit | 3b82eef50f734cab061330f55de8b8bf5396f24b (patch) | |
tree | ba6471e129ed55eeeda9f194bab74c2849b183ca /src/com/android | |
parent | 6f0e3b8e1de5137077127bf3144effa2016c27c6 (diff) | |
download | packages_apps_nfc-3b82eef50f734cab061330f55de8b8bf5396f24b.zip packages_apps_nfc-3b82eef50f734cab061330f55de8b8bf5396f24b.tar.gz packages_apps_nfc-3b82eef50f734cab061330f55de8b8bf5396f24b.tar.bz2 |
LLCP 1.1 support.
- Allow servicename for connectionless sockets;
- Pass in servicename in Bind() for both types;
- EchoServer: allow MIU=128 again since ATR_RES
fix was merged in libnfc-nxp
- EchoServer: fix reading from incorrect offset.
Change-Id: Ie77fe5b46e7a17435e6261c8b7400dcca4d3784a
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/nfc/DeviceHost.java | 2 | ||||
-rwxr-xr-x | src/com/android/nfc/NfcService.java | 4 | ||||
-rw-r--r-- | src/com/android/nfc/echoserver/EchoServer.java | 12 | ||||
-rwxr-xr-x | src/com/android/nfc/nxp/NativeNfcManager.java | 7 |
4 files changed, 14 insertions, 11 deletions
diff --git a/src/com/android/nfc/DeviceHost.java b/src/com/android/nfc/DeviceHost.java index 1975ed2..0b57d55 100644 --- a/src/com/android/nfc/DeviceHost.java +++ b/src/com/android/nfc/DeviceHost.java @@ -187,7 +187,7 @@ public interface DeviceHost { public int doGetLastError(); - public LlcpConnectionlessSocket createLlcpConnectionlessSocket(int nSap) + public LlcpConnectionlessSocket createLlcpConnectionlessSocket(int nSap, String sn) throws LlcpException; public LlcpServerSocket createLlcpServerSocket(int nSap, String sn, int miu, diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index d910d80..386e52b 100755 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -1486,9 +1486,9 @@ public class NfcService extends Application implements DeviceHostListener { } /** For use by code in this process */ - public LlcpConnectionlessSocket createLlcpConnectionLessSocket(int sap) + public LlcpConnectionlessSocket createLlcpConnectionLessSocket(int sap, String sn) throws LlcpException { - return mDeviceHost.createLlcpConnectionlessSocket(sap); + return mDeviceHost.createLlcpConnectionlessSocket(sap, sn); } /** For use by code in this process */ diff --git a/src/com/android/nfc/echoserver/EchoServer.java b/src/com/android/nfc/echoserver/EchoServer.java index bd060f7..71d0bf8 100644 --- a/src/com/android/nfc/echoserver/EchoServer.java +++ b/src/com/android/nfc/echoserver/EchoServer.java @@ -99,7 +99,7 @@ public class EchoServer { * We use ECHO_MIU=48 because of a bug in PN544, which does not respect * the target length reduction parameter of the p2p protocol. */ - static final int ECHO_MIU = 48; + static final int ECHO_MIU = 128; final BlockingQueue<byte[]> dataQueue; final Handler handler; @@ -123,7 +123,7 @@ public class EchoServer { try { // Split up the packet in ECHO_MIU size packets int sizeLeft = size; - + int offset = 0; if (dataQueue.isEmpty()) { // First message: start echo'ing in 2 seconds handler.sendMessageDelayed(handler.obtainMessage(), ECHO_DELAY_IN_MS); @@ -136,9 +136,10 @@ public class EchoServer { while (sizeLeft > 0) { int minSize = Math.min(size, ECHO_MIU); byte[] data = new byte[minSize]; - System.arraycopy(unit, 0, data, 0, minSize); + System.arraycopy(unit, offset, data, 0, minSize); dataQueue.put(data); sizeLeft -= minSize; + offset += minSize; } } catch (InterruptedException e) { // Ignore @@ -252,8 +253,9 @@ public class EchoServer { if (clientSocket != null) { try { clientSocket.send(data); + Log.e(TAG, "Send success!"); } catch (IOException e) { - // Ignore + Log.e(TAG, "Send failed."); } } } @@ -290,7 +292,7 @@ public class EchoServer { if (DBG) Log.d(TAG, "about create LLCP connectionless socket"); try { socket = mService.createLlcpConnectionLessSocket( - DEFAULT_CL_SAP); + DEFAULT_CL_SAP, CONNECTIONLESS_SERVICE_NAME); if (socket == null) { if (DBG) Log.d(TAG, "failed to create LLCP connectionless socket"); return; diff --git a/src/com/android/nfc/nxp/NativeNfcManager.java b/src/com/android/nfc/nxp/NativeNfcManager.java index 1a4d51c..62994b1 100755 --- a/src/com/android/nfc/nxp/NativeNfcManager.java +++ b/src/com/android/nfc/nxp/NativeNfcManager.java @@ -134,12 +134,13 @@ public class NativeNfcManager implements DeviceHost { @Override public native int doGetLastError(); - private native NativeLlcpConnectionlessSocket doCreateLlcpConnectionlessSocket(int nSap); + private native NativeLlcpConnectionlessSocket doCreateLlcpConnectionlessSocket(int nSap, + String sn); @Override - public LlcpConnectionlessSocket createLlcpConnectionlessSocket(int nSap) + public LlcpConnectionlessSocket createLlcpConnectionlessSocket(int nSap, String sn) throws LlcpException { - LlcpConnectionlessSocket socket = doCreateLlcpConnectionlessSocket(nSap); + LlcpConnectionlessSocket socket = doCreateLlcpConnectionlessSocket(nSap, sn); if (socket != null) { return socket; } else { |