public class UnitTestBluetoothDevice extends java.lang.Object implements IBluetoothDevice
IBluetoothDevice.DefaultFactory, IBluetoothDevice.Factory
DEFAULT_FACTORY, NULL
Constructor and Description |
---|
UnitTestBluetoothDevice(IBleDevice device) |
Modifier and Type | Method and Description |
---|---|
boolean |
cancelBond()
Cancels an active bond attempt.
|
android.bluetooth.BluetoothGatt |
connect(android.content.Context context,
boolean useAutoConnect,
android.bluetooth.BluetoothGattCallback callback)
This always returns
null . |
boolean |
createBond()
Creates a bond with the device.
|
boolean |
createBondSneaky(java.lang.String methodName,
boolean loggingEnabled)
This method is effectively the same as
createBond() when running in a unit test. |
boolean |
equals(IBluetoothDevice device)
Referential equality check.
|
java.lang.String |
getAddress()
Returns the mac address for this device
|
BleDevice |
getBleDevice()
Returns the
BleDevice instance held by this class. |
int |
getBondState()
Returns the current bond state.
|
java.lang.String |
getName()
Returns the name of the device
|
android.bluetooth.BluetoothDevice |
getNativeDevice()
This will always return
null , as when unit testing, we don't have any actual native devices. |
void |
init()
This method is called internally.
|
boolean |
isConnected()
This is used internally as a "hack" fix.
|
boolean |
isDeviceNull()
Returns
true if the held device is null. |
boolean |
removeBond()
Removes the bond to this device.
|
void |
setNativeDevice(android.bluetooth.BluetoothDevice device,
P_DeviceHolder deviceHolder)
Internal method used to set the "native" device.
|
void |
setToBonded()
Called by
createBond() , and createBondSneaky(String, boolean) . |
void |
setToBonding()
Called by
createBond() , and createBondSneaky(String, boolean) . |
void |
setToUnBonded()
Called by
createBond() , and createBondSneaky(String, boolean) . |
void |
updateBleDevice(IBleDevice device)
Method called internally to update the instance of
IBleDevice held by this class. |
public UnitTestBluetoothDevice(IBleDevice device)
public void init()
init
in interface IBluetoothDevice
public final void setNativeDevice(android.bluetooth.BluetoothDevice device, P_DeviceHolder deviceHolder)
setNativeDevice
in interface IBluetoothDevice
public int getBondState()
getBondState
in interface IBluetoothDevice
public java.lang.String getAddress()
getAddress
in interface IBluetoothDevice
public java.lang.String getName()
getName
in interface IBluetoothDevice
public boolean createBond()
setToBonding()
, and setToBonded()
, in addition to updating
the bonded device list in the manager layer. You probably shouldn't override this method, but the setTo methods instead.createBond
in interface IBluetoothDevice
public void setToBonding()
createBond()
, and createBondSneaky(String, boolean)
. This updates the device's bond state (to BONDING), and posts
the success as a "native" callback.public void setToBonded()
createBond()
, and createBondSneaky(String, boolean)
. This updates the device's bond state (to BONDED), and posts
the success as a "native" callback.public boolean isConnected()
isConnected
in interface IBluetoothDevice
public boolean isDeviceNull()
true
if the held device is null. By default, this just returns false
as its assumed to be a valid device.isDeviceNull
in interface IBluetoothDevice
public boolean removeBond()
removeBond
in interface IBluetoothDevice
public void setToUnBonded()
createBond()
, and createBondSneaky(String, boolean)
. This updates the device's bond state (to BONDED), and posts
the success as a "native" callback.public boolean cancelBond()
cancelBond
in interface IBluetoothDevice
public boolean equals(IBluetoothDevice device)
equals
in interface IBluetoothDevice
public boolean createBondSneaky(java.lang.String methodName, boolean loggingEnabled)
createBond()
when running in a unit test.createBondSneaky
in interface IBluetoothDevice
public android.bluetooth.BluetoothDevice getNativeDevice()
null
, as when unit testing, we don't have any actual native devices.getNativeDevice
in interface IBluetoothDevice
public android.bluetooth.BluetoothGatt connect(android.content.Context context, boolean useAutoConnect, android.bluetooth.BluetoothGattCallback callback)
null
. This method also does nothing, as the connection logic is mainly handled
in UnitTestBluetoothGatt
.connect
in interface IBluetoothDevice
public final void updateBleDevice(IBleDevice device)
IBleDevice
held by this class.updateBleDevice
in interface IBluetoothDevice
public final BleDevice getBleDevice()
BleDevice
instance held by this class.getBleDevice
in interface IBluetoothDevice