• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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.dhimpl;
18 
19 import com.android.nfc.DeviceHost;
20 import com.android.nfc.DeviceHost.LlcpSocket;
21 
22 import java.io.IOException;
23 
24 /**
25  * LlcpServiceSocket represents a LLCP Service to be used in a
26  * Connection-oriented communication
27  */
28 public class NativeLlcpServiceSocket implements DeviceHost.LlcpServerSocket {
29     private int mHandle;
30     private int mLocalMiu;
31     private int mLocalRw;
32     private int mLocalLinearBufferLength;
33     private int mSap;
34     private String mServiceName;
35 
NativeLlcpServiceSocket()36     public NativeLlcpServiceSocket(){ }
37 
doAccept(int miu, int rw, int linearBufferLength)38     private native NativeLlcpSocket doAccept(int miu, int rw, int linearBufferLength);
39     @Override
accept()40     public LlcpSocket accept() throws IOException {
41         LlcpSocket socket = doAccept(mLocalMiu, mLocalRw, mLocalLinearBufferLength);
42         if (socket == null) throw new IOException();
43         return socket;
44     }
45 
doClose()46     private native boolean doClose();
47     @Override
close()48     public void close() throws IOException {
49         if (!doClose()) {
50             throw new IOException();
51         }
52     }
53 }
54