aboutsummaryrefslogtreecommitdiff
path: root/framework/java/android/bluetooth/BluetoothAdapter.java
diff options
context:
space:
mode:
authorMyles Watson <mylesgw@google.com>2022-01-21 10:15:31 -0800
committerMyles Watson <mylesgw@google.com>2022-01-28 19:08:11 +0000
commitb98c570d30403ea80f239ce22c9b25fe4b770b87 (patch)
treeb7678c44b27919a6c0fb43348dfa957646a7702a /framework/java/android/bluetooth/BluetoothAdapter.java
parent22c1d198b6135bc2aa2ef7c271e93dd52b872c74 (diff)
Add getRemoteLeDevice to specify ADDRESS_TYPE
Bug: 215724286 Test: cts Tag: #feature Change-Id: Id6415cf5f0236a82cb294538c22b5dc22555a6ff Merged-In: Id6415cf5f0236a82cb294538c22b5dc22555a6ff
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothAdapter.java')
-rw-r--r--framework/java/android/bluetooth/BluetoothAdapter.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java
index ff22c7614a..3cabde5e38 100644
--- a/framework/java/android/bluetooth/BluetoothAdapter.java
+++ b/framework/java/android/bluetooth/BluetoothAdapter.java
@@ -30,6 +30,7 @@ import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SuppressLint;
import android.annotation.SystemApi; //import android.app.PropertyInvalidatedCache;
import android.app.PendingIntent;
+import android.bluetooth.BluetoothDevice.AddressType;
import android.bluetooth.BluetoothDevice.Transport;
import android.bluetooth.BluetoothProfile.ConnectionPolicy;
import android.bluetooth.annotations.RequiresBluetoothAdvertisePermission;
@@ -864,6 +865,28 @@ public final class BluetoothAdapter {
/**
* Get a {@link BluetoothDevice} object for the given Bluetooth hardware
+ * address and addressType.
+ * <p>Valid Bluetooth hardware addresses must be upper case, in a format
+ * such as "00:11:22:33:AA:BB". The helper {@link #checkBluetoothAddress} is
+ * available to validate a Bluetooth address.
+ * <p>A {@link BluetoothDevice} will always be returned for a valid
+ * hardware address and type, even if this adapter has never seen that device.
+ *
+ * @param address valid Bluetooth MAC address
+ * @param addressType Bluetooth address type
+ * @throws IllegalArgumentException if address is invalid
+ */
+ @RequiresNoPermission
+ public
+ @NonNull BluetoothDevice getRemoteLeDevice(@NonNull String address,
+ @AddressType int addressType) {
+ final BluetoothDevice res = new BluetoothDevice(address, addressType);
+ res.setAttributionSource(mAttributionSource);
+ return res;
+ }
+
+ /**
+ * 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).