Brad Ebinger | 5385513 | 2015-10-30 10:58:19 -0700 | [diff] [blame] | 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 | |
Hall Liu | e74af08 | 2016-02-10 16:12:47 -0800 | [diff] [blame] | 19 | import android.bluetooth.BluetoothDevice; |
Brad Ebinger | 5385513 | 2015-10-30 10:58:19 -0700 | [diff] [blame] | 20 | import android.bluetooth.BluetoothHeadset; |
| 21 | |
Hall Liu | e74af08 | 2016-02-10 16:12:47 -0800 | [diff] [blame] | 22 | import java.util.List; |
| 23 | |
Brad Ebinger | 5385513 | 2015-10-30 10:58:19 -0700 | [diff] [blame] | 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 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 Liu | e74af08 | 2016-02-10 16:12:47 -0800 | [diff] [blame] | 50 | |
| 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 Liu | 7409895 | 2018-05-18 16:46:26 -0700 | [diff] [blame] | 59 | public int getAudioState(BluetoothDevice device) { |
| 60 | return mBluetoothHeadset.getAudioState(device); |
Hall Liu | e74af08 | 2016-02-10 16:12:47 -0800 | [diff] [blame] | 61 | } |
| 62 | |
Hall Liu | 67eb3b0 | 2018-04-27 17:54:46 -0700 | [diff] [blame] | 63 | public boolean connectAudio() { |
Hall Liu | e74af08 | 2016-02-10 16:12:47 -0800 | [diff] [blame] | 64 | return mBluetoothHeadset.connectAudio(); |
| 65 | } |
| 66 | |
Hall Liu | 67eb3b0 | 2018-04-27 17:54:46 -0700 | [diff] [blame] | 67 | public boolean setActiveDevice(BluetoothDevice device) { |
| 68 | return mBluetoothHeadset.setActiveDevice(device); |
| 69 | } |
| 70 | |
Hall Liu | cc74215 | 2018-05-09 17:48:40 -0700 | [diff] [blame] | 71 | public BluetoothDevice getActiveDevice() { |
| 72 | return mBluetoothHeadset.getActiveDevice(); |
| 73 | } |
| 74 | |
Hall Liu | 67eb3b0 | 2018-04-27 17:54:46 -0700 | [diff] [blame] | 75 | public boolean isAudioOn() { |
| 76 | return mBluetoothHeadset.isAudioOn(); |
| 77 | } |
| 78 | |
Hall Liu | e74af08 | 2016-02-10 16:12:47 -0800 | [diff] [blame] | 79 | public boolean disconnectAudio() { |
| 80 | return mBluetoothHeadset.disconnectAudio(); |
| 81 | } |
Jack He | f8c23ee | 2018-01-05 17:14:09 -0800 | [diff] [blame] | 82 | |
| 83 | public boolean isInbandRingingEnabled() { |
| 84 | return mBluetoothHeadset.isInbandRingingEnabled(); |
| 85 | } |
Brad Ebinger | 5385513 | 2015-10-30 10:58:19 -0700 | [diff] [blame] | 86 | } |