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 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 } 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 59 public boolean isAudioConnected(BluetoothDevice device) { 60 return mBluetoothHeadset.isAudioConnected(device); 61 } 62 63 public boolean connectAudio() { 64 return mBluetoothHeadset.connectAudio(); 65 } 66 67 public boolean disconnectAudio() { 68 return mBluetoothHeadset.disconnectAudio(); 69 } 70 }