summaryrefslogtreecommitdiffstats
path: root/core/java/android/bluetooth
diff options
context:
space:
mode:
authorNick Pelly <npelly@google.com>2011-12-07 15:03:55 -0800
committerNick Pelly <npelly@google.com>2011-12-09 14:35:38 -0800
commit75596b4545da36fa7592bd4a2ae680e5b336ee47 (patch)
tree32325499de5525e76b15eb8a153714ff6bc11248 /core/java/android/bluetooth
parent09588f64a280b98eefc22d05fd5ff7916ba9203e (diff)
downloadframeworks_base-75596b4545da36fa7592bd4a2ae680e5b336ee47.zip
frameworks_base-75596b4545da36fa7592bd4a2ae680e5b336ee47.tar.gz
frameworks_base-75596b4545da36fa7592bd4a2ae680e5b336ee47.tar.bz2
Add BluetoothAdapter.getRemoteDevice(byte[])
This is useful for NFC->BT hand-over, where we are already working with bytes. Change-Id: I2fff0b4fa0cefe9bfdf9a13f7ec6f557776a8a03
Diffstat (limited to 'core/java/android/bluetooth')
-rw-r--r--core/java/android/bluetooth/BluetoothAdapter.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/core/java/android/bluetooth/BluetoothAdapter.java b/core/java/android/bluetooth/BluetoothAdapter.java
index 5f5ba50..e420bfd 100644
--- a/core/java/android/bluetooth/BluetoothAdapter.java
+++ b/core/java/android/bluetooth/BluetoothAdapter.java
@@ -399,6 +399,25 @@ public final class BluetoothAdapter {
}
/**
+ * Get a {@link BluetoothDevice} object for the given Bluetooth hardware
+ * address.
+ * <p>Valid Bluetooth hardware addresses must be 6 bytes. This method
+ * expects the address in network byte order (MSB first).
+ * <p>A {@link BluetoothDevice} will always be returned for a valid
+ * hardware address, even if this adapter has never seen that device.
+ *
+ * @param address Bluetooth MAC address (6 bytes)
+ * @throws IllegalArgumentException if address is invalid
+ */
+ public BluetoothDevice getRemoteDevice(byte[] address) {
+ if (address == null || address.length != 6) {
+ throw new IllegalArgumentException("Bluetooth address must have 6 bytes");
+ }
+ return new BluetoothDevice(String.format("%02X:%02X:%02X:%02X:%02X:%02X",
+ address[0], address[1], address[2], address[3], address[4], address[5]));
+ }
+
+ /**
* Return true if Bluetooth is currently enabled and ready for use.
* <p>Equivalent to:
* <code>getBluetoothState() == STATE_ON</code>
@@ -1281,7 +1300,7 @@ public final class BluetoothAdapter {
}
/**
- * Validate a Bluetooth address, such as "00:43:A8:23:10:F0"
+ * Validate a String Bluetooth address, such as "00:43:A8:23:10:F0"
* <p>Alphabetic characters must be uppercase to be valid.
*
* @param address Bluetooth address as string