1 /*
2  * Copyright (C) 2015 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.server.telecom;
18 
19 import android.bluetooth.BluetoothDevice;
20 import android.bluetooth.BluetoothHeadset;
21 
22 import java.util.List;
23 
24 /**
25  * A proxy class that facilitates testing of the BluetoothPhoneServiceImpl class.
26  *
27  * This is necessary due to the "final" attribute of the BluetoothHeadset class. In order to
28  * test the correct functioning of the BluetoothPhoneServiceImpl class, the final class must be put
29  * into a container that can be mocked correctly.
30  */
31 public class BluetoothHeadsetProxy {
32 
33     private BluetoothHeadset mBluetoothHeadset;
34 
35     public BluetoothHeadsetProxy(BluetoothHeadset headset) {
36         mBluetoothHeadset = headset;
37     }
38 
39     public List<BluetoothDevice> getConnectedDevices() {
40         return mBluetoothHeadset.getConnectedDevices();
41     }
42 
43     public int getConnectionState(BluetoothDevice device) {
44         return mBluetoothHeadset.getConnectionState(device);
45     }
46 
47     public int getAudioState(BluetoothDevice device) {
48         return mBluetoothHeadset.getAudioState(device);
49     }
50 
51     public boolean connectAudio() {
52         return mBluetoothHeadset.connectAudio();
53     }
54 
55     public boolean setActiveDevice(BluetoothDevice device) {
56         return mBluetoothHeadset.setActiveDevice(device);
57     }
58 
59     public BluetoothDevice getActiveDevice() {
60         return mBluetoothHeadset.getActiveDevice();
61     }
62 
63     public boolean isAudioOn() {
64         return mBluetoothHeadset.isAudioOn();
65     }
66 
67     public boolean disconnectAudio() {
68         return mBluetoothHeadset.disconnectAudio();
69     }
70 
71     public boolean isInbandRingingEnabled() {
72         return mBluetoothHeadset.isInbandRingingEnabled();
73     }
74 }
75