15385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger/* 25385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * Copyright (C) 2015 The Android Open Source Project 35385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * 45385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * Licensed under the Apache License, Version 2.0 (the "License"); 55385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * you may not use this file except in compliance with the License. 65385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * You may obtain a copy of the License at 75385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * 85385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * http://www.apache.org/licenses/LICENSE-2.0 95385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * 105385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * Unless required by applicable law or agreed to in writing, software 115385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * distributed under the License is distributed on an "AS IS" BASIS, 125385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * See the License for the specific language governing permissions and 145385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * limitations under the License 155385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger */ 165385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger 175385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebingerpackage com.android.server.telecom; 185385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger 19e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liuimport android.bluetooth.BluetoothDevice; 205385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebingerimport android.bluetooth.BluetoothHeadset; 215385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger 22e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liuimport java.util.List; 23e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu 245385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger/** 255385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * A proxy class that facilitates testing of the BluetoothPhoneServiceImpl class. 265385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * 275385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * This is necessary due to the "final" attribute of the BluetoothHeadset class. In order to 285385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * test the correct functioning of the BluetoothPhoneServiceImpl class, the final class must be put 295385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger * into a container that can be mocked correctly. 305385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger */ 315385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebingerpublic class BluetoothHeadsetProxy { 325385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger 335385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger private BluetoothHeadset mBluetoothHeadset; 345385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger 355385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger public BluetoothHeadsetProxy(BluetoothHeadset headset) { 365385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger mBluetoothHeadset = headset; 375385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger } 385385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger 395385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger public void clccResponse(int index, int direction, int status, int mode, boolean mpty, 405385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger String number, int type) { 415385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger 425385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger mBluetoothHeadset.clccResponse(index, direction, status, mode, mpty, number, type); 435385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger } 445385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger 455385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger public void phoneStateChanged(int numActive, int numHeld, int callState, String number, 465385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger int type) { 475385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger 485385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger mBluetoothHeadset.phoneStateChanged(numActive, numHeld, callState, number, type); 495385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger } 50e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu 51e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu public List<BluetoothDevice> getConnectedDevices() { 52e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu return mBluetoothHeadset.getConnectedDevices(); 53e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu } 54e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu 55e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu public int getConnectionState(BluetoothDevice device) { 56e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu return mBluetoothHeadset.getConnectionState(device); 57e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu } 58e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu 59e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu public boolean isAudioConnected(BluetoothDevice device) { 60e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu return mBluetoothHeadset.isAudioConnected(device); 61e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu } 62e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu 63e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu public boolean connectAudio() { 64e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu return mBluetoothHeadset.connectAudio(); 65e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu } 66e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu 67e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu public boolean disconnectAudio() { 68e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu return mBluetoothHeadset.disconnectAudio(); 69e74af084ac087f6af0f16ecbed5e74ce7183d254Hall Liu } 705385513ae43b4d5896245bf076a83b27dbf32a25Brad Ebinger}