Class ShadowBluetoothDevice


  • @Implements(android.bluetooth.BluetoothDevice.class)
    public class ShadowBluetoothDevice
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected android.bluetooth.BluetoothGatt connectGatt​(android.content.Context context, boolean autoConnect, android.bluetooth.BluetoothGattCallback callback)  
      protected android.bluetooth.BluetoothGatt connectGatt​(android.content.Context context, boolean autoConnect, android.bluetooth.BluetoothGattCallback callback, int transport)  
      protected android.bluetooth.BluetoothGatt connectGatt​(android.content.Context context, boolean autoConnect, android.bluetooth.BluetoothGattCallback callback, int transport, int phy, android.os.Handler handler)  
      protected boolean createBond()
      Returns whether this device has been bonded with.
      protected android.bluetooth.BluetoothSocket createRfcommSocketToServiceRecord​(java.util.UUID uuid)  
      protected boolean fetchUuidsWithSdp()
      Overrides behavior of BluetoothDevice.fetchUuidsWithSdp().
      protected java.lang.String getAlias()  
      protected java.lang.String getAliasName()  
      android.bluetooth.BluetoothClass getBluetoothClass()
      Overrides behavior of BluetoothDevice.getBluetoothClass() to return pre-set result.
      java.util.List<android.bluetooth.BluetoothGatt> getBluetoothGatts()
      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 java.lang.String getName()  
      java.lang.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 android.bluetooth.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 android.os.ParcelUuid[] getUuids()
      Overrides behavior of BluetoothDevice.getUuids() to return pre-set result.
      static android.bluetooth.BluetoothDevice newInstance​(java.lang.String address)  
      static void reset()  
      void setAlias​(java.lang.String alias)
      Sets the alias name of the device.
      void setBluetoothClass​(android.bluetooth.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​(java.lang.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​(android.os.ParcelUuid[] uuids)
      Sets the return value for BluetoothDevice.getUuids().
      void simulateGattConnectionChange​(int status, int newState)
      Causes to be called for every GATT client.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ShadowBluetoothDevice

        public ShadowBluetoothDevice()
    • Method Detail

      • newInstance

        public static android.bluetooth.BluetoothDevice newInstance​(java.lang.String address)
      • reset

        @Resetter
        public static void reset()
      • getService

        @Implementation
        protected static android.bluetooth.IBluetooth getService()
        Implements getService() in the same way the original method does, but ignores any Exceptions from invoking BluetoothAdapter.getBluetoothService(android.bluetooth.IBluetoothManagerCallback).
      • setName

        public void setName​(java.lang.String name)
      • setAlias

        public void setAlias​(java.lang.String alias)
        Sets the alias name of the device.

        Alias is the locally modified name of a remote device.

        Alias Name is not part of the supported SDK, and accessed via reflection.

        Parameters:
        alias - alias name.
      • setThrowOnGetAliasName

        public void setThrowOnGetAliasName​(boolean shouldThrow)
        Sets if a runtime exception is thrown when the alias name of the device is accessed.

        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.

        Parameters:
        shouldThrow - if getAliasName() should throw when called.
      • getName

        @Implementation
        protected java.lang.String getName()
      • getAlias

        @Implementation
        protected java.lang.String getAlias()
      • getAliasName

        @Implementation
        protected java.lang.String getAliasName()
                                         throws java.lang.ReflectiveOperationException
        Throws:
        java.lang.ReflectiveOperationException
      • setType

        public void setType​(int type)
        Sets the return value for BluetoothDevice.getType().
      • getType

        @Implementation(minSdk=18)
        protected int getType()
        Overrides behavior of BluetoothDevice.getType() to return pre-set result.
        Returns:
        Value set by calling setType(int). If setType has not previously been called, will return BluetoothDevice.DEVICE_TYPE_UNKNOWN.
      • setUuids

        public void setUuids​(android.os.ParcelUuid[] uuids)
        Sets the return value for BluetoothDevice.getUuids().
      • getUuids

        @Implementation
        protected android.os.ParcelUuid[] getUuids()
        Overrides behavior of BluetoothDevice.getUuids() to return pre-set result.
        Returns:
        Value set by calling setUuids(android.os.ParcelUuid[]). If setUuids has not previously been called, will return null.
      • setBondState

        public void setBondState​(int bondState)
        Sets value of bond state for BluetoothDevice.getBondState().
      • getBondState

        @Implementation
        protected int getBondState()
        Overrides behavior of BluetoothDevice.getBondState() to return pre-set result.
      • setCreatedBond

        public void setCreatedBond​(boolean createdBond)
        Sets whether this device has been bonded with.
      • createBond

        @Implementation
        protected boolean createBond()
        Returns whether this device has been bonded with.
      • setPin

        @Implementation
        protected boolean setPin​(byte[] pin)
      • getPin

        public byte[] getPin()
        Get the PIN previously set with a call to BluetoothDevice.setPin(byte[]), or null if no PIN has been set.
      • setPairingConfirmation

        @Implementation
        public boolean setPairingConfirmation​(boolean confirm)
      • getPairingConfirmation

        public java.lang.Boolean getPairingConfirmation()
        Get the confirmation value previously set with a call to BluetoothDevice.setPairingConfirmation(boolean), or null if no value is set.
      • createRfcommSocketToServiceRecord

        @Implementation
        protected android.bluetooth.BluetoothSocket createRfcommSocketToServiceRecord​(java.util.UUID uuid)
                                                                               throws java.io.IOException
        Throws:
        java.io.IOException
      • setFetchUuidsWithSdpResult

        public void setFetchUuidsWithSdpResult​(boolean fetchUuidsWithSdpResult)
        Sets value of the return result for BluetoothDevice.fetchUuidsWithSdp().
      • fetchUuidsWithSdp

        @Implementation
        protected boolean fetchUuidsWithSdp()
        Overrides behavior of BluetoothDevice.fetchUuidsWithSdp(). This method updates the counter which counts the number of invocations of this method.
      • getFetchUuidsWithSdpCount

        public int getFetchUuidsWithSdpCount()
        Returns the number of times fetchUuidsWithSdp has been called.
      • connectGatt

        @Implementation(minSdk=18)
        protected android.bluetooth.BluetoothGatt connectGatt​(android.content.Context context,
                                                              boolean autoConnect,
                                                              android.bluetooth.BluetoothGattCallback callback)
      • connectGatt

        @Implementation(minSdk=23)
        protected android.bluetooth.BluetoothGatt connectGatt​(android.content.Context context,
                                                              boolean autoConnect,
                                                              android.bluetooth.BluetoothGattCallback callback,
                                                              int transport)
      • connectGatt

        @Implementation(minSdk=26)
        protected android.bluetooth.BluetoothGatt connectGatt​(android.content.Context context,
                                                              boolean autoConnect,
                                                              android.bluetooth.BluetoothGattCallback callback,
                                                              int transport,
                                                              int phy,
                                                              android.os.Handler handler)
      • simulateGattConnectionChange

        public void simulateGattConnectionChange​(int status,
                                                 int newState)
        Causes to be called for every GATT client.
        Parameters:
        status - Status of the GATT operation
        newState - The new state of the GATT profile
      • getBluetoothClass

        @Implementation
        public android.bluetooth.BluetoothClass getBluetoothClass()
        Overrides behavior of BluetoothDevice.getBluetoothClass() to return pre-set result.
        Returns:
        Value set by calling setBluetoothClass(android.bluetooth.BluetoothClass). If setType has not previously been called, will return null.
      • setBluetoothClass

        public void setBluetoothClass​(android.bluetooth.BluetoothClass bluetoothClass)
        Sets the return value for BluetoothDevice.getBluetoothClass().