@Implements(android.bluetooth.BluetoothDevice.class) public class ShadowBluetoothDevice extends Object
Constructor | Description |
---|---|
ShadowBluetoothDevice() |
Modifier and Type | Method | Description |
---|---|---|
protected BluetoothGatt |
connectGatt(Context context,
boolean autoConnect,
BluetoothGattCallback callback) |
|
protected BluetoothGatt |
connectGatt(Context context,
boolean autoConnect,
BluetoothGattCallback callback,
int transport) |
|
protected BluetoothGatt |
connectGatt(Context context,
boolean autoConnect,
BluetoothGattCallback callback,
int transport,
int phy,
Handler handler) |
|
protected boolean |
createBond() |
Returns whether this device has been bonded with.
|
protected BluetoothSocket |
createRfcommSocketToServiceRecord(UUID uuid) |
|
protected boolean |
fetchUuidsWithSdp() |
Overrides behavior of
BluetoothDevice.fetchUuidsWithSdp() . |
protected String |
getAlias() |
|
protected String |
getAliasName() |
|
BluetoothClass |
getBluetoothClass() |
Overrides behavior of
BluetoothDevice.getBluetoothClass() to return pre-set result. |
List<BluetoothGatt> |
getBluetoothGatts() |
Returns all
BluetoothGatt objects created by calling connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallback) . |
protected int |
getBondState() |
Overrides behavior of
BluetoothDevice.getBondState() to return pre-set result. |
int |
getFetchUuidsWithSdpCount() |
Returns the number of times fetchUuidsWithSdp has been called.
|
protected String |
getName() |
|
Boolean |
getPairingConfirmation() |
Get the confirmation value previously set with a call to
BluetoothDevice.setPairingConfirmation(boolean) , or null if no value is set. |
byte[] |
getPin() |
Get the PIN previously set with a call to
BluetoothDevice.setPin(byte[]) , or null if no
PIN has been set. |
protected static IBluetooth |
getService() |
Implements getService() in the same way the original method does, but ignores any Exceptions
from invoking
BluetoothAdapter.getBluetoothService(android.bluetooth.IBluetoothManagerCallback) . |
protected int |
getType() |
Overrides behavior of
BluetoothDevice.getType() to return pre-set result. |
protected ParcelUuid[] |
getUuids() |
Overrides behavior of
BluetoothDevice.getUuids() to return pre-set result. |
static BluetoothDevice |
newInstance(String address) |
|
static void |
reset() |
|
void |
setAlias(String alias) |
Sets the alias name of the device.
|
void |
setBluetoothClass(BluetoothClass bluetoothClass) |
Sets the return value for
BluetoothDevice.getBluetoothClass() . |
void |
setBondState(int bondState) |
Sets value of bond state for
BluetoothDevice.getBondState() . |
void |
setCreatedBond(boolean createdBond) |
Sets whether this device has been bonded with.
|
void |
setFetchUuidsWithSdpResult(boolean fetchUuidsWithSdpResult) |
Sets value of the return result for
BluetoothDevice.fetchUuidsWithSdp() . |
void |
setName(String name) |
|
boolean |
setPairingConfirmation(boolean confirm) |
|
protected boolean |
setPin(byte[] pin) |
|
void |
setThrowOnGetAliasName(boolean shouldThrow) |
Sets if a runtime exception is thrown when the alias name of the device is accessed.
|
void |
setType(int type) |
Sets the return value for
BluetoothDevice.getType() . |
void |
setUuids(ParcelUuid[] uuids) |
Sets the return value for
BluetoothDevice.getUuids() . |
void |
simulateGattConnectionChange(int status,
int newState) |
public static BluetoothDevice newInstance(String address)
@Resetter public static void reset()
@Implementation protected static IBluetooth getService()
BluetoothAdapter.getBluetoothService(android.bluetooth.IBluetoothManagerCallback)
.public void setName(String name)
public void setAlias(String alias)
Alias is the locally modified name of a remote device.
Alias Name is not part of the supported SDK, and accessed via reflection.
alias
- alias name.public void setThrowOnGetAliasName(boolean shouldThrow)
Intended to replicate what may happen if the unsupported SDK is changed.
Alias is the locally modified name of a remote device.
Alias Name is not part of the supported SDK, and accessed via reflection.
shouldThrow
- if getAliasName() should throw when called.@Implementation protected String getName()
@Implementation protected String getAlias()
@Implementation protected String getAliasName() throws ReflectiveOperationException
ReflectiveOperationException
public void setType(int type)
BluetoothDevice.getType()
.@Implementation(minSdk=18) protected int getType()
BluetoothDevice.getType()
to return pre-set result.setType(int)
. If setType has not
previously been called, will return BluetoothDevice.DEVICE_TYPE_UNKNOWN.public void setUuids(ParcelUuid[] uuids)
BluetoothDevice.getUuids()
.@Implementation protected ParcelUuid[] getUuids()
BluetoothDevice.getUuids()
to return pre-set result.setUuids(android.os.ParcelUuid[])
. If setUuids has not
previously been called, will return null.public void setBondState(int bondState)
BluetoothDevice.getBondState()
.@Implementation protected int getBondState()
BluetoothDevice.getBondState()
to return pre-set result.public void setCreatedBond(boolean createdBond)
@Implementation protected boolean createBond()
@Implementation protected boolean setPin(byte[] pin)
public byte[] getPin()
BluetoothDevice.setPin(byte[])
, or null if no
PIN has been set.@Implementation public boolean setPairingConfirmation(boolean confirm)
public Boolean getPairingConfirmation()
BluetoothDevice.setPairingConfirmation(boolean)
, or null if no value is set.@Implementation protected BluetoothSocket createRfcommSocketToServiceRecord(UUID uuid) throws IOException
IOException
public void setFetchUuidsWithSdpResult(boolean fetchUuidsWithSdpResult)
BluetoothDevice.fetchUuidsWithSdp()
.@Implementation protected boolean fetchUuidsWithSdp()
BluetoothDevice.fetchUuidsWithSdp()
. This method updates the
counter which counts the number of invocations of this method.public int getFetchUuidsWithSdpCount()
@Implementation(minSdk=18) protected BluetoothGatt connectGatt(Context context, boolean autoConnect, BluetoothGattCallback callback)
@Implementation(minSdk=23) protected BluetoothGatt connectGatt(Context context, boolean autoConnect, BluetoothGattCallback callback, int transport)
@Implementation(minSdk=26) protected BluetoothGatt connectGatt(Context context, boolean autoConnect, BluetoothGattCallback callback, int transport, int phy, Handler handler)
public List<BluetoothGatt> getBluetoothGatts()
BluetoothGatt
objects created by calling connectGatt(android.content.Context, boolean, android.bluetooth.BluetoothGattCallback)
.public void simulateGattConnectionChange(int status, int newState)
status
- Status of the GATT operationnewState
- The new state of the GATT profile@Implementation public BluetoothClass getBluetoothClass()
BluetoothDevice.getBluetoothClass()
to return pre-set result.setBluetoothClass(android.bluetooth.BluetoothClass)
. If setType has
not previously been called, will return null.public void setBluetoothClass(BluetoothClass bluetoothClass)
BluetoothDevice.getBluetoothClass()
.