1 package com.xtremelabs.robolectric.shadows;
2 
3 import android.bluetooth.BluetoothAdapter;
4 import android.bluetooth.BluetoothDevice;
5 import com.xtremelabs.robolectric.Robolectric;
6 import com.xtremelabs.robolectric.internal.Implementation;
7 import com.xtremelabs.robolectric.internal.Implements;
8 
9 import java.util.Collections;
10 import java.util.HashSet;
11 import java.util.Set;
12 
13 import static com.xtremelabs.robolectric.Robolectric.shadowOf;
14 
15 @SuppressWarnings({"UnusedDeclaration"})
16 @Implements(BluetoothAdapter.class)
17 public class ShadowBluetoothAdapter {
18 
19     private Set<BluetoothDevice> bondedDevices = new HashSet<BluetoothDevice>();
20     private boolean isDiscovering;
21 
22     @Implementation
getDefaultAdapter()23     public static BluetoothAdapter getDefaultAdapter() {
24         return (BluetoothAdapter) shadowOf(Robolectric.application).getBluetoothAdapter();
25     }
26 
27     @Implementation
getBondedDevices()28     public Set<BluetoothDevice> getBondedDevices() {
29         return Collections.unmodifiableSet(bondedDevices);
30     }
31 
setBondedDevices(Set<BluetoothDevice> bluetoothDevices)32     public void setBondedDevices(Set<BluetoothDevice> bluetoothDevices) {
33         bondedDevices = bluetoothDevices;
34     }
35 
36     @Implementation
startDiscovery()37     public boolean startDiscovery() {
38         isDiscovering = true;
39         return true;
40     }
41 
42     @Implementation
cancelDiscovery()43     public boolean cancelDiscovery() {
44         isDiscovering = false;
45         return true;
46     }
47 
48     @Implementation
isDiscovering()49     public boolean isDiscovering() {
50         return isDiscovering;
51     }
52 
53 }
54