Class ShadowBluetoothDevice

    • Constructor Detail

      • ShadowBluetoothDevice

        public ShadowBluetoothDevice()
    • Method Detail

      • reset

        @Resetter
        public static void reset()
      • setName

        public void setName​(String name)
      • setAlias

        public void setAlias​(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.
      • setShouldThrowSecurityExceptions

        public void setShouldThrowSecurityExceptions​(boolean shouldThrow)
        Sets if a runtime exception is thrown when bluetooth methods with BLUETOOTH_CONNECT permission pre-requisites are accessed.

        Intended to replicate what may happen if user has not enabled nearby device permissions.

        Parameters:
        shouldThrow - if methods should throw SecurityExceptions without enabled permissions when called.
      • getName

        @Implementation
        protected String getName()
      • getAlias

        @Implementation
        protected String getAlias()
      • 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.
      • 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.
      • removeBond

        @Implementation
        protected boolean removeBond()
      • setPin

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

        @Implementation
        public boolean setPairingConfirmation​(boolean confirm)
      • 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.
      • simulateGattConnectionChange

        public void simulateGattConnectionChange​(int status,
                                                 int newState)
        Parameters:
        status - Status of the GATT operation
        newState - The new state of the GATT profile
      • setMetadata

        @Implementation(minSdk=29)
        protected boolean setMetadata​(int key,
                                      byte[] value)
      • getMetadata

        @Implementation(minSdk=29)
        protected byte[] getMetadata​(int key)
      • setBatteryLevel

        public void setBatteryLevel​(int batteryLevel)
      • getBatteryLevel

        @Implementation(minSdk=27)
        protected int getBatteryLevel()
      • setSilenceMode

        @Implementation(minSdk=29)
        public boolean setSilenceMode​(boolean isInSilenceMode)
      • isInSilenceMode

        @Implementation(minSdk=29)
        protected boolean isInSilenceMode()