• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
BluetoothHeadsetProxy(BluetoothHeadset headset)35     public BluetoothHeadsetProxy(BluetoothHeadset headset) {
36         mBluetoothHeadset = headset;
37     }
38 
clccResponse(int index, int direction, int status, int mode, boolean mpty, String number, int type)39     public void clccResponse(int index, int direction, int status, int mode, boolean mpty,
40             String number, int type) {
41 
42         mBluetoothHeadset.clccResponse(index, direction, status, mode, mpty, number, type);
43     }
44 
phoneStateChanged(int numActive, int numHeld, int callState, String number, int type, String name)45     public void phoneStateChanged(int numActive, int numHeld, int callState, String number,
46             int type, String name) {
47 
48         mBluetoothHeadset.phoneStateChanged(numActive, numHeld, callState, number, type,
49             name);
50     }
51 
getConnectedDevices()52     public List<BluetoothDevice> getConnectedDevices() {
53         return mBluetoothHeadset.getConnectedDevices();
54     }
55 
getConnectionState(BluetoothDevice device)56     public int getConnectionState(BluetoothDevice device) {
57         return mBluetoothHeadset.getConnectionState(device);
58     }
59 
getAudioState(BluetoothDevice device)60     public int getAudioState(BluetoothDevice device) {
61         return mBluetoothHeadset.getAudioState(device);
62     }
63 
connectAudio()64     public boolean connectAudio() {
65         return mBluetoothHeadset.connectAudio();
66     }
67 
setActiveDevice(BluetoothDevice device)68     public boolean setActiveDevice(BluetoothDevice device) {
69         return mBluetoothHeadset.setActiveDevice(device);
70     }
71 
getActiveDevice()72     public BluetoothDevice getActiveDevice() {
73         return mBluetoothHeadset.getActiveDevice();
74     }
75 
isAudioOn()76     public boolean isAudioOn() {
77         return mBluetoothHeadset.isAudioOn();
78     }
79 
disconnectAudio()80     public boolean disconnectAudio() {
81         return mBluetoothHeadset.disconnectAudio();
82     }
83 
isInbandRingingEnabled()84     public boolean isInbandRingingEnabled() {
85         return mBluetoothHeadset.isInbandRingingEnabled();
86     }
87 }
88