blob: 0f492dfec60ab969c9d8d0c753459bdf28b038cb [file] [log] [blame]
Brad Ebinger53855132015-10-30 10:58:19 -07001/*
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
17package com.android.server.telecom;
18
Hall Liue74af082016-02-10 16:12:47 -080019import android.bluetooth.BluetoothDevice;
Brad Ebinger53855132015-10-30 10:58:19 -070020import android.bluetooth.BluetoothHeadset;
21
Hall Liue74af082016-02-10 16:12:47 -080022import java.util.List;
23
Brad Ebinger53855132015-10-30 10:58:19 -070024/**
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 */
31public class BluetoothHeadsetProxy {
32
33 private BluetoothHeadset mBluetoothHeadset;
34
35 public BluetoothHeadsetProxy(BluetoothHeadset headset) {
36 mBluetoothHeadset = headset;
37 }
38
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
45 public void phoneStateChanged(int numActive, int numHeld, int callState, String number,
46 int type) {
47
48 mBluetoothHeadset.phoneStateChanged(numActive, numHeld, callState, number, type);
49 }
Hall Liue74af082016-02-10 16:12:47 -080050
51 public List<BluetoothDevice> getConnectedDevices() {
52 return mBluetoothHeadset.getConnectedDevices();
53 }
54
55 public int getConnectionState(BluetoothDevice device) {
56 return mBluetoothHeadset.getConnectionState(device);
57 }
58
Hall Liu74098952018-05-18 16:46:26 -070059 public int getAudioState(BluetoothDevice device) {
60 return mBluetoothHeadset.getAudioState(device);
Hall Liue74af082016-02-10 16:12:47 -080061 }
62
Hall Liu67eb3b02018-04-27 17:54:46 -070063 public boolean connectAudio() {
Hall Liue74af082016-02-10 16:12:47 -080064 return mBluetoothHeadset.connectAudio();
65 }
66
Hall Liu67eb3b02018-04-27 17:54:46 -070067 public boolean setActiveDevice(BluetoothDevice device) {
68 return mBluetoothHeadset.setActiveDevice(device);
69 }
70
Hall Liucc742152018-05-09 17:48:40 -070071 public BluetoothDevice getActiveDevice() {
72 return mBluetoothHeadset.getActiveDevice();
73 }
74
Hall Liu67eb3b02018-04-27 17:54:46 -070075 public boolean isAudioOn() {
76 return mBluetoothHeadset.isAudioOn();
77 }
78
Hall Liue74af082016-02-10 16:12:47 -080079 public boolean disconnectAudio() {
80 return mBluetoothHeadset.disconnectAudio();
81 }
Jack Hef8c23ee2018-01-05 17:14:09 -080082
83 public boolean isInbandRingingEnabled() {
84 return mBluetoothHeadset.isInbandRingingEnabled();
85 }
Brad Ebinger53855132015-10-30 10:58:19 -070086}