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