1 /*
2  * Copyright (C) 2016 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.bluetooth.pbapclient;
18 
19 import android.bluetooth.BluetoothSocket;
20 
21 import java.io.DataInputStream;
22 import java.io.DataOutputStream;
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.io.OutputStream;
26 
27 import javax.obex.ObexTransport;
28 
29 class BluetoothPbapObexTransport implements ObexTransport {
30 
31     private BluetoothSocket mSocket = null;
32 
BluetoothPbapObexTransport(BluetoothSocket rfs)33     public BluetoothPbapObexTransport(BluetoothSocket rfs) {
34         super();
35         mSocket = rfs;
36     }
37 
38     @Override
close()39     public void close() throws IOException {
40         mSocket.close();
41     }
42 
43     @Override
openDataInputStream()44     public DataInputStream openDataInputStream() throws IOException {
45         return new DataInputStream(openInputStream());
46     }
47 
48     @Override
openDataOutputStream()49     public DataOutputStream openDataOutputStream() throws IOException {
50         return new DataOutputStream(openOutputStream());
51     }
52 
53     @Override
openInputStream()54     public InputStream openInputStream() throws IOException {
55         return mSocket.getInputStream();
56     }
57 
58     @Override
openOutputStream()59     public OutputStream openOutputStream() throws IOException {
60         return mSocket.getOutputStream();
61     }
62 
63     @Override
connect()64     public void connect() throws IOException {
65     }
66 
67     @Override
create()68     public void create() throws IOException {
69     }
70 
71     @Override
disconnect()72     public void disconnect() throws IOException {
73     }
74 
75     @Override
listen()76     public void listen() throws IOException {
77     }
78 
isConnected()79     public boolean isConnected() throws IOException {
80         // return true;
81         return mSocket.isConnected();
82     }
83 
84     @Override
getMaxTransmitPacketSize()85     public int getMaxTransmitPacketSize() {
86         return -1;
87     }
88 
89     @Override
getMaxReceivePacketSize()90     public int getMaxReceivePacketSize() {
91         return -1;
92     }
93 
94     @Override
isSrmSupported()95     public boolean isSrmSupported() {
96         return false;
97     }
98 }
99