public class UnitTestBluetoothManager extends java.lang.Object implements IBluetoothManager
IBluetoothManager.DefaultFactory, IBluetoothManager.Factory
DEFAULT_FACTORY, DEFAULT_INSTANCE
Constructor and Description |
---|
UnitTestBluetoothManager() |
Modifier and Type | Method and Description |
---|---|
void |
addBondedDevice(BleDevice device)
Called when the system wants to track a new device as being bonded.
|
boolean |
cancelDiscovery()
Called internally when the system wants to stop a classic scan.
|
boolean |
disable()
Called by the library when attempting to turn off the Bluetooth radio.
|
boolean |
enable()
Called by the system when the library wants to turn the Bluetooth radio on.
|
java.lang.String |
getAddress()
Returns the mac address of the "controller" (the phone/tablet).
|
int |
getBleState()
Returns the same as
getState() |
java.util.Set<P_DeviceHolder> |
getBondedDevices()
Returns a
Set of P_DeviceHolder representing the devices that are currently bonded to this manager/adaptor. |
int |
getConnectionState(IBluetoothDevice device,
int profile)
Returns the connection state of this device.
|
java.lang.String |
getName()
Returns the name of this manager/adaptor.
|
android.bluetooth.BluetoothAdapter |
getNativeAdaptor()
Returns
null as the adaptor is mocked. |
android.bluetooth.BluetoothManager |
getNativeManager()
Returns
null as the manager is mocked. |
android.bluetooth.BluetoothDevice |
getRemoteDevice(java.lang.String macAddress)
Default returns
null . |
int |
getState()
Returns the native state of the Bluetooth Adaptor
|
boolean |
isBluetooth5HighSpeedSupported()
Returns
true if bluetooth 5 high speed is supported. |
boolean |
isBluetooth5LongRangeSupported()
Returns
true if bluetooth 5 long range is supported. |
boolean |
isBluetoothEnabled()
Returns
true if the bluetooth radio is on. |
boolean |
isLocationEnabledForScanning_byOsServices()
Returns
true if location services are supported by the OS. |
boolean |
isLocationEnabledForScanning_byRuntimePermissions()
Returns
true if location service permissions have been granted. |
boolean |
isLocationEnabledForScanning()
Returns
true if location services have been enabled. |
boolean |
isManagerNull()
Returns
true if the manager instance is "null" (this is all just mocked) |
boolean |
isMultipleAdvertisementSupported()
Returns
true if multiple advertisement is supported (using an android device to advertise to other bluetooth controllers). |
protected void |
manuallySetState(int newState)
Allows you to manually set the native state of this manager/adaptor.
|
P_ServerHolder |
openGattServer(android.content.Context context,
IServerListener listeners)
Called by the library when a
BleServer is getting created. |
void |
removeBondedDevice(BleDevice device)
Called when a device is no longer bonded.
|
void |
resetManager(android.content.Context context)
Called by the library when it needs to instantiate the bluetooth manager.
|
void |
setIBleManager(IBleManager mgr)
Called internally to set the
IBleManager instance. |
boolean |
setName(java.lang.String name)
Sets the name of the bluetooth manager/adaptor.
|
protected void |
setToOff()
Called by
disable() . |
protected void |
setToOn()
Called by
enable() . |
protected void |
setToTurningOff()
Called by
disable() . |
protected void |
setToTurningOn()
Called by
enable() . |
void |
startAdvertising(android.bluetooth.le.AdvertiseSettings settings,
android.bluetooth.le.AdvertiseData adData,
L_Util.AdvertisingCallback callback)
Called by the system when the library wants the manager/adaptor to advertise over bluetooth.
|
boolean |
startDiscovery()
Called by the library when it wants to start bluetooth classic discovery.
|
boolean |
startLeScan(android.bluetooth.BluetoothAdapter.LeScanCallback callback)
Called when the library wants to start a pre-lollipop scan.
|
void |
startLScan(int scanMode,
Interval delay,
L_Util.ScanCallback callback)
Called when the library wants to start a post-lollipop scan (Lollipop only).
|
void |
startMScan(int scanMode,
Interval delay,
L_Util.ScanCallback callback)
Called when the library wants to start a post-lollipop scan on marshmallow or above.
|
boolean |
startPendingIntentScan(int scanMode,
Interval delay,
android.app.PendingIntent pendingIntent)
Called when the library wants to start a BLE scan using a PendingIntent to deliver scan results.
|
void |
stopAdvertising()
Called by the library when it wants to stop the
BleServer from advertising. |
void |
stopLeScan(android.bluetooth.BluetoothAdapter.LeScanCallback callback)
Called when the system wants to stop an LE scan.
|
void |
stopPendingIntentScan(android.app.PendingIntent pendingIntent)
Called when the system wants to stop a PendingIntent scan.
|
void |
updateDeviceState(IBleDevice device,
int state)
Called internally to update the state of a
BleDevice . |
public void setIBleManager(IBleManager mgr)
IBleManager
instance. There should be no reason to override this method.setIBleManager
in interface IBluetoothManager
public int getConnectionState(IBluetoothDevice device, int profile)
getConnectionState
in interface IBluetoothManager
public boolean startDiscovery()
startDiscovery
in interface IBluetoothManager
public boolean cancelDiscovery()
cancelDiscovery
in interface IBluetoothManager
public boolean isManagerNull()
true
if the manager instance is "null" (this is all just mocked)isManagerNull
in interface IBluetoothManager
public void updateDeviceState(IBleDevice device, int state)
BleDevice
.public boolean disable()
setToTurningOff()
and setToOff()
, which are
the methods you should override to change behavior.disable
in interface IBluetoothManager
public boolean enable()
setToTurningOn()
and setToOn()
,
which are the methods you should override to change behavior.enable
in interface IBluetoothManager
public boolean isMultipleAdvertisementSupported()
true
if multiple advertisement is supported (using an android device to advertise to other bluetooth controllers).
Default is true
isMultipleAdvertisementSupported
in interface IBluetoothManager
public boolean isBluetooth5LongRangeSupported()
true
if bluetooth 5 long range is supported.
Default is true
isBluetooth5LongRangeSupported
in interface IBluetoothManager
public boolean isBluetooth5HighSpeedSupported()
true
if bluetooth 5 high speed is supported.
Default is true
isBluetooth5HighSpeedSupported
in interface IBluetoothManager
public void resetManager(android.content.Context context)
resetManager
in interface IBluetoothManager
public int getState()
getState
in interface IBluetoothManager
public int getBleState()
getState()
getBleState
in interface IBluetoothManager
public java.lang.String getName()
getName
in interface IBluetoothManager
public boolean setName(java.lang.String name)
setName
in interface IBluetoothManager
public java.lang.String getAddress()
getAddress
in interface IBluetoothManager
public java.util.Set<P_DeviceHolder> getBondedDevices()
Set
of P_DeviceHolder
representing the devices that are currently bonded to this manager/adaptor.getBondedDevices
in interface IBluetoothManager
public void addBondedDevice(BleDevice device)
public void removeBondedDevice(BleDevice device)
public android.bluetooth.BluetoothAdapter getNativeAdaptor()
null
as the adaptor is mocked.getNativeAdaptor
in interface IBluetoothManager
public android.bluetooth.BluetoothManager getNativeManager()
null
as the manager is mocked.getNativeManager
in interface IBluetoothManager
public P_ServerHolder openGattServer(android.content.Context context, IServerListener listeners)
BleServer
is getting created.openGattServer
in interface IBluetoothManager
public void startAdvertising(android.bluetooth.le.AdvertiseSettings settings, android.bluetooth.le.AdvertiseData adData, L_Util.AdvertisingCallback callback)
startAdvertising
in interface IBluetoothManager
public void stopAdvertising()
BleServer
from advertising.stopAdvertising
in interface IBluetoothManager
public boolean isLocationEnabledForScanning_byOsServices()
true
if location services are supported by the OS.
Default is true
isLocationEnabledForScanning_byOsServices
in interface IBluetoothManager
public boolean isLocationEnabledForScanning_byRuntimePermissions()
true
if location service permissions have been granted.
Default is true
isLocationEnabledForScanning_byRuntimePermissions
in interface IBluetoothManager
public boolean isLocationEnabledForScanning()
true
if location services have been enabled.
Default is true
isLocationEnabledForScanning
in interface IBluetoothManager
public boolean isBluetoothEnabled()
true
if the bluetooth radio is on.isBluetoothEnabled
in interface IBluetoothManager
public void startLScan(int scanMode, Interval delay, L_Util.ScanCallback callback)
startLScan
in interface IBluetoothManager
public void startMScan(int scanMode, Interval delay, L_Util.ScanCallback callback)
startMScan
in interface IBluetoothManager
public boolean startLeScan(android.bluetooth.BluetoothAdapter.LeScanCallback callback)
true
.startLeScan
in interface IBluetoothManager
public void stopLeScan(android.bluetooth.BluetoothAdapter.LeScanCallback callback)
stopLeScan
in interface IBluetoothManager
public void stopPendingIntentScan(android.app.PendingIntent pendingIntent)
stopPendingIntentScan
in interface IBluetoothManager
public boolean startPendingIntentScan(int scanMode, Interval delay, android.app.PendingIntent pendingIntent)
true
.startPendingIntentScan
in interface IBluetoothManager
public android.bluetooth.BluetoothDevice getRemoteDevice(java.lang.String macAddress)
null
.getRemoteDevice
in interface IBluetoothManager
protected void manuallySetState(int newState)
protected void setToTurningOff()
disable()
. This sets the state to TURNING_OFF.protected void setToOff()
disable()
. This sets the state to OFF.protected void setToTurningOn()
enable()
. This sets the state to TURNING_ON.protected void setToOn()
enable()
. This sets the state to ON.