Package org.robolectric.shadows
Class ShadowBluetoothHeadset
- java.lang.Object
-
- org.robolectric.shadows.ShadowBluetoothHeadset
-
@NotThreadSafe @Implements(android.bluetooth.BluetoothHeadset.class) public class ShadowBluetoothHeadset extends java.lang.ObjectShadow forBluetoothHeadset
-
-
Constructor Summary
Constructors Constructor Description ShadowBluetoothHeadset()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddConnectedDevice(android.bluetooth.BluetoothDevice device)Adds the given BluetoothDevice to the shadow's list of "connected devices"protected java.util.List<android.bluetooth.BluetoothDevice>getConnectedDevices()Overrides behavior ofgetConnectedDevices().protected intgetConnectionState(android.bluetooth.BluetoothDevice device)Overrides behavior ofgetConnectionState(android.bluetooth.BluetoothDevice).protected booleanisAudioConnected(android.bluetooth.BluetoothDevice bluetoothDevice)protected booleansendVendorSpecificResultCode(android.bluetooth.BluetoothDevice device, java.lang.String command, java.lang.String arg)voidsetAllowsSendVendorSpecificResultCode(boolean allowsSendVendorSpecificResultCode)Affects the behavior ofBluetoothHeadset.sendVendorSpecificResultCode(android.bluetooth.BluetoothDevice, java.lang.String, java.lang.String)protected booleanstartVoiceRecognition(android.bluetooth.BluetoothDevice bluetoothDevice)Overrides behavior ofstartVoiceRecognition(android.bluetooth.BluetoothDevice).protected booleanstopVoiceRecognition(android.bluetooth.BluetoothDevice bluetoothDevice)Overrides the behavior ofstopVoiceRecognition(android.bluetooth.BluetoothDevice).
-
-
-
Method Detail
-
getConnectedDevices
@Implementation protected java.util.List<android.bluetooth.BluetoothDevice> getConnectedDevices()
Overrides behavior ofgetConnectedDevices(). Returns list of devices that is set up by call(s) toaddConnectedDevice(android.bluetooth.BluetoothDevice). Returns an empty list by default.
-
addConnectedDevice
public void addConnectedDevice(android.bluetooth.BluetoothDevice device)
Adds the given BluetoothDevice to the shadow's list of "connected devices"
-
getConnectionState
@Implementation protected int getConnectionState(android.bluetooth.BluetoothDevice device)
Overrides behavior ofgetConnectionState(android.bluetooth.BluetoothDevice).- Returns:
BluetoothProfile.STATE_CONNECTEDif the given device has been previously added by a call toaddConnectedDevice(android.bluetooth.BluetoothDevice), andBluetoothProfile.STATE_DISCONNECTEDotherwise.
-
startVoiceRecognition
@Implementation protected boolean startVoiceRecognition(android.bluetooth.BluetoothDevice bluetoothDevice)
Overrides behavior ofstartVoiceRecognition(android.bluetooth.BluetoothDevice). Returns false if 'bluetoothDevice' is null or voice recognition is already started. Users can listen toACTION_AUDIO_STATE_CHANGED. If this function returns true, this intent will be broadcasted once withBluetoothProfile.EXTRA_STATEset toSTATE_AUDIO_CONNECTINGand once set toSTATE_AUDIO_CONNECTED.
-
stopVoiceRecognition
@Implementation protected boolean stopVoiceRecognition(android.bluetooth.BluetoothDevice bluetoothDevice)
Overrides the behavior ofstopVoiceRecognition(android.bluetooth.BluetoothDevice). Returns false if voice recognition was not started or voice recogntion has already ended on this headset. If this function returns true,ACTION_AUDIO_STATE_CHANGEDintent is broadcasted withBluetoothProfile.EXTRA_STATEset toSTATE_DISCONNECTED.
-
isAudioConnected
@Implementation protected boolean isAudioConnected(android.bluetooth.BluetoothDevice bluetoothDevice)
-
sendVendorSpecificResultCode
@Implementation(minSdk=19) protected boolean sendVendorSpecificResultCode(android.bluetooth.BluetoothDevice device, java.lang.String command, java.lang.String arg)Overrides behavior ofsendVendorSpecificResultCode(android.bluetooth.BluetoothDevice,java.lang.String,java.lang.String).- Returns:
- 'true' only if the given device has been previously added by a call to
addConnectedDevice(android.bluetooth.BluetoothDevice)andsetAllowsSendVendorSpecificResultCode(boolean)has not been called with 'false' argument. - Throws:
java.lang.IllegalArgumentException- if 'command' argument is null, per Android API
-
setAllowsSendVendorSpecificResultCode
public void setAllowsSendVendorSpecificResultCode(boolean allowsSendVendorSpecificResultCode)
Affects the behavior ofBluetoothHeadset.sendVendorSpecificResultCode(android.bluetooth.BluetoothDevice, java.lang.String, java.lang.String)- Parameters:
allowsSendVendorSpecificResultCode- can be set to 'false' to simulate the situation where the system is unable to send vendor-specific result codes to a device
-
-