FileDocCategorySizeDatePackage
BluetoothLeUtils.javaAPI DocAndroid 5.1 API4153Thu Mar 12 22:22:10 GMT 2015android.bluetooth.le

BluetoothLeUtils

public class BluetoothLeUtils extends Object
Helper class for Bluetooth LE utils.
hide

Fields Summary
Constructors Summary
Methods Summary
static voidcheckAdapterStateOn(android.bluetooth.BluetoothAdapter adapter)
Ensure Bluetooth is turned on.

throws
IllegalStateException If {@code adapter} is null or Bluetooth state is not {@link BluetoothAdapter#STATE_ON}.

        if (adapter == null || adapter.getState() != BluetoothAdapter.STATE_ON) {
            throw new IllegalStateException("BT Adapter is not turned ON");
        }
    
static booleanequals(android.util.SparseArray array, android.util.SparseArray otherArray)
Check whether two {@link SparseArray} equal.

        if (array == otherArray) {
            return true;
        }
        if (array == null || otherArray == null) {
            return false;
        }
        if (array.size() != otherArray.size()) {
            return false;
        }

        // Keys are guaranteed in ascending order when indices are in ascending order.
        for (int i = 0; i < array.size(); ++i) {
            if (array.keyAt(i) != otherArray.keyAt(i) ||
                    !Arrays.equals(array.valueAt(i), otherArray.valueAt(i))) {
                return false;
            }
        }
        return true;
    
static booleanequals(java.util.Map map, java.util.Map otherMap)
Check whether two {@link Map} equal.

        if (map == otherMap) {
            return true;
        }
        if (map == null || otherMap == null) {
            return false;
        }
        if (map.size() != otherMap.size()) {
            return false;
        }
        Set<T> keys = map.keySet();
        if (!keys.equals(otherMap.keySet())) {
            return false;
        }
        for (T key : keys) {
            if (!Objects.deepEquals(map.get(key), otherMap.get(key))) {
                return false;
            }
        }
        return true;
    
static java.lang.StringtoString(android.util.SparseArray array)
Returns a string composed from a {@link SparseArray}.

        if (array == null) {
            return "null";
        }
        if (array.size() == 0) {
            return "{}";
        }
        StringBuilder buffer = new StringBuilder();
        buffer.append('{");
        for (int i = 0; i < array.size(); ++i) {
            buffer.append(array.keyAt(i)).append("=").append(Arrays.toString(array.valueAt(i)));
        }
        buffer.append('}");
        return buffer.toString();
    
static java.lang.StringtoString(java.util.Map map)
Returns a string composed from a {@link Map}.

        if (map == null) {
            return "null";
        }
        if (map.isEmpty()) {
            return "{}";
        }
        StringBuilder buffer = new StringBuilder();
        buffer.append('{");
        Iterator<Map.Entry<T, byte[]>> it = map.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<T, byte[]> entry = it.next();
            Object key = entry.getKey();
            buffer.append(key).append("=").append(Arrays.toString(map.get(key)));
            if (it.hasNext()) {
                buffer.append(", ");
            }
        }
        buffer.append('}");
        return buffer.toString();