1fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie/* 2fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie* Copyright (C) 2013 Samsung System LSI 3fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie* Licensed under the Apache License, Version 2.0 (the "License"); 4fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie* you may not use this file except in compliance with the License. 5fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie* You may obtain a copy of the License at 6fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie* 7fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie* http://www.apache.org/licenses/LICENSE-2.0 8fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie* 9fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie* Unless required by applicable law or agreed to in writing, software 10fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie* distributed under the License is distributed on an "AS IS" BASIS, 11fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie* See the License for the specific language governing permissions and 13fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie* limitations under the License. 14fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie*/ 15fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xiepackage com.android.bluetooth.map; 16fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 17fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xieimport android.bluetooth.BluetoothSocket; 18fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 19fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xieimport java.io.DataInputStream; 20fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xieimport java.io.DataOutputStream; 21fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xieimport java.io.IOException; 22fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xieimport java.io.InputStream; 23fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xieimport java.io.OutputStream; 24fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 25fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xieimport javax.obex.ObexTransport; 26fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 27fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xiepublic class BluetoothMnsRfcommTransport implements ObexTransport { 28fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 29fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie private final BluetoothSocket mSocket; 30fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 31fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie public BluetoothMnsRfcommTransport(BluetoothSocket socket) { 32fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie super(); 33fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie this.mSocket = socket; 34fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie } 35fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 36fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie public void close() throws IOException { 37fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie mSocket.close(); 38fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie } 39fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 40fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie public DataInputStream openDataInputStream() throws IOException { 41fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie return new DataInputStream(openInputStream()); 42fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie } 43fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 44fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie public DataOutputStream openDataOutputStream() throws IOException { 45fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie return new DataOutputStream(openOutputStream()); 46fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie } 47fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 48fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie public InputStream openInputStream() throws IOException { 49fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie return mSocket.getInputStream(); 50fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie } 51fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 52fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie public OutputStream openOutputStream() throws IOException { 53fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie return mSocket.getOutputStream(); 54fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie } 55fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 56fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie public void connect() throws IOException { 57fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie } 58fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 59fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie public void create() throws IOException { 60fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie } 61fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 62fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie public void disconnect() throws IOException { 63fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie } 64fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 65fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie public void listen() throws IOException { 66fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie } 67fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 68fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie public boolean isConnected() throws IOException { 69fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie // TODO: add implementation 70fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie return true; 71fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie } 72fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 73fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie public String getRemoteAddress() { 74fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie if (mSocket == null) 75fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie return null; 76fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie return mSocket.getRemoteDevice().getAddress(); 77fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie } 78fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie 79fd6603b8bf9ed72dcc8bd59aaef3209251b6e17cMatthew Xie} 80