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