diff options
| author | Myles Watson <mylesgw@google.com> | 2022-01-21 10:15:31 -0800 |
|---|---|---|
| committer | Chienyuan Huang <chienyuanhuang@google.com> | 2022-01-27 04:13:37 +0000 |
| commit | e1d39b906f399f3663692f1af04d22a491fda94c (patch) | |
| tree | 212c1daf7e2050f780cdf33b21ae6fe3801676b0 /framework/java/android/bluetooth/BluetoothAdapter.java | |
| parent | d172303657c7b212a8d305642b00f2f05f8ca6a0 (diff) | |
Add getRemoteLeDevice to specify ADDRESS_TYPE
Bug: 215724286
Test: cts
Tag: #feature
Change-Id: Id6415cf5f0236a82cb294538c22b5dc22555a6ff
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothAdapter.java')
| -rw-r--r-- | framework/java/android/bluetooth/BluetoothAdapter.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/framework/java/android/bluetooth/BluetoothAdapter.java b/framework/java/android/bluetooth/BluetoothAdapter.java index 7b4cba2491..9bd4bdf0d4 100644 --- a/framework/java/android/bluetooth/BluetoothAdapter.java +++ b/framework/java/android/bluetooth/BluetoothAdapter.java @@ -31,6 +31,7 @@ import android.annotation.SuppressLint; import android.annotation.SystemApi; //import android.app.PropertyInvalidatedCache; import android.bluetooth.BluetoothDevice.Transport; import android.bluetooth.BluetoothFrameworkInitializer; +import android.bluetooth.BluetoothDevice.AddressType; import android.bluetooth.BluetoothProfile.ConnectionPolicy; import android.bluetooth.annotations.RequiresBluetoothAdvertisePermission; import android.bluetooth.annotations.RequiresBluetoothConnectPermission; @@ -851,6 +852,27 @@ 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). |
