Class ShadowBluetoothAdapter


  • @Implements(android.bluetooth.BluetoothAdapter.class)
    public class ShadowBluetoothAdapter
    extends java.lang.Object
    • Constructor Detail

      • ShadowBluetoothAdapter

        public ShadowBluetoothAdapter()
    • Method Detail

      • reset

        @Resetter
        public static void reset()
      • getDefaultAdapter

        @Implementation
        protected static android.bluetooth.BluetoothAdapter getDefaultAdapter()
      • setIsBluetoothSupported

        public static void setIsBluetoothSupported​(boolean supported)
        Determines if getDefaultAdapter() returns the default local adapter (true) or null (false).
      • getBluetoothLeScanner

        @Implementation(minSdk=21)
        protected android.bluetooth.le.BluetoothLeScanner getBluetoothLeScanner()
      • getBondedDevices

        @Implementation
        protected java.util.Set<android.bluetooth.BluetoothDevice> getBondedDevices()
      • setBondedDevices

        public void setBondedDevices​(java.util.Set<android.bluetooth.BluetoothDevice> bluetoothDevices)
      • listenUsingInsecureRfcommWithServiceRecord

        @Implementation
        protected android.bluetooth.BluetoothServerSocket listenUsingInsecureRfcommWithServiceRecord​(java.lang.String serviceName,
                                                                                                     java.util.UUID uuid)
      • listenUsingRfcommWithServiceRecord

        @Implementation
        protected android.bluetooth.BluetoothServerSocket listenUsingRfcommWithServiceRecord​(java.lang.String serviceName,
                                                                                             java.util.UUID uuid)
                                                                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • startDiscovery

        @Implementation
        protected boolean startDiscovery()
      • cancelDiscovery

        @Implementation
        protected boolean cancelDiscovery()
      • isBleScanAlwaysAvailable

        @Implementation(minSdk=23)
        protected boolean isBleScanAlwaysAvailable()
        When true, overrides the value of getLeState(). By default, this is false.
      • getLeState

        @Implementation(minSdk=23)
        public int getLeState()
        Decides the correct LE state. When off, BLE calls will fail or return null.

        LE is enabled if either Bluetooth or BLE scans are enabled. LE is always off if Airplane Mode is enabled.

      • startLeScan

        @Implementation(minSdk=18)
        protected boolean startLeScan​(android.bluetooth.BluetoothAdapter.LeScanCallback callback)
      • startLeScan

        @Implementation(minSdk=18)
        protected boolean startLeScan​(java.util.UUID[] serviceUuids,
                                      android.bluetooth.BluetoothAdapter.LeScanCallback callback)
      • stopLeScan

        @Implementation(minSdk=18)
        protected void stopLeScan​(android.bluetooth.BluetoothAdapter.LeScanCallback callback)
      • getLeScanCallbacks

        public java.util.Set<android.bluetooth.BluetoothAdapter.LeScanCallback> getLeScanCallbacks()
      • getSingleLeScanCallback

        public android.bluetooth.BluetoothAdapter.LeScanCallback getSingleLeScanCallback()
      • isDiscovering

        @Implementation
        protected boolean isDiscovering()
      • isEnabled

        @Implementation
        protected boolean isEnabled()
      • enable

        @Implementation
        protected boolean enable()
      • disable

        @Implementation
        protected boolean disable()
      • getAddress

        @Implementation
        protected java.lang.String getAddress()
      • getState

        @Implementation
        protected int getState()
      • getName

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

        @Implementation
        protected boolean setName​(java.lang.String name)
      • setScanMode

        @Implementation
        protected boolean setScanMode​(int scanMode)
      • setScanMode

        @Implementation
        protected boolean setScanMode​(int scanMode,
                                      int discoverableTimeout)
      • getScanMode

        @Implementation
        protected int getScanMode()
      • getDiscoverableTimeout

        @Implementation
        protected int getDiscoverableTimeout()
      • setDiscoverableTimeout

        @Implementation
        protected void setDiscoverableTimeout​(int timeout)
      • isMultipleAdvertisementSupported

        @Implementation(minSdk=21)
        protected boolean isMultipleAdvertisementSupported()
      • checkBluetoothAddress

        @Implementation
        protected static boolean checkBluetoothAddress​(java.lang.String address)
        Validate a Bluetooth address, such as "00:43:A8:23:10:F0" Alphabetic characters must be uppercase to be valid.
        Parameters:
        address - Bluetooth address as string
        Returns:
        true if the address is valid, false otherwise
      • getProfileConnectionState

        @Implementation
        protected int getProfileConnectionState​(int profile)
        Returns the connection state for the given Bluetooth profile, defaulting to BluetoothProfile.STATE_DISCONNECTED if the profile's connection state was never set.

        Set a Bluetooth profile's connection state via setProfileConnectionState(int, int).

      • setAddress

        public void setAddress​(java.lang.String address)
      • setState

        public void setState​(int state)
      • setEnabled

        public void setEnabled​(boolean enabled)
      • setBleScanAlwaysAvailable

        public void setBleScanAlwaysAvailable​(boolean alwaysAvailable)
        Sets the value for isBleScanAlwaysAvailable. If true, getLeState() will always return true.
      • setIsMultipleAdvertisementSupported

        public void setIsMultipleAdvertisementSupported​(boolean supported)
      • setProfileConnectionState

        public void setProfileConnectionState​(int profile,
                                              int state)
        Sets the connection state state for the given BluetoothProfile profile
      • setProfileProxy

        public void setProfileProxy​(int profile,
                                    @Nullable
                                    android.bluetooth.BluetoothProfile proxy)
        Sets the active BluetoothProfile proxy for the given profile. Will always affect behavior of BluetoothAdapter.getProfileProxy(android.content.Context, android.bluetooth.BluetoothProfile.ServiceListener, int) and BluetoothAdapter.closeProfileProxy(int, android.bluetooth.BluetoothProfile). Call to BluetoothAdapter.closeProfileProxy(int, android.bluetooth.BluetoothProfile) can remove the set active proxy.
        Parameters:
        proxy - can be 'null' to simulate the situation where BluetoothAdapter.getProfileProxy(android.content.Context, android.bluetooth.BluetoothProfile.ServiceListener, int) would return 'false'. This can happen on older Android versions for Bluetooth profiles introduced in later Android versions.
      • setIsLeExtendedAdvertisingSupported

        public void setIsLeExtendedAdvertisingSupported​(boolean supported)
        Sets the isLeExtendedAdvertisingSupported to enable/disable LE extended advertisements feature