diff options
Diffstat (limited to 'framework/java/android/bluetooth/BluetoothDevice.java')
-rw-r--r-- | framework/java/android/bluetooth/BluetoothDevice.java | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/framework/java/android/bluetooth/BluetoothDevice.java b/framework/java/android/bluetooth/BluetoothDevice.java index 9ab823cece..d9ab7ecc0e 100644 --- a/framework/java/android/bluetooth/BluetoothDevice.java +++ b/framework/java/android/bluetooth/BluetoothDevice.java @@ -1201,28 +1201,46 @@ public final class BluetoothDevice implements Parcelable, Attributable { }; /** - * Create a new BluetoothDevice + * Create a new BluetoothDevice. * Bluetooth MAC address must be upper case, such as "00:11:22:33:AA:BB", * and is validated in this constructor. * * @param address valid Bluetooth MAC address - * @param attributionSource attribution for permission-protected calls + * @param addressType valid address type * @throws RuntimeException Bluetooth is not available on this platform - * @throws IllegalArgumentException address is invalid + * @throws IllegalArgumentException address or addressType is invalid * @hide */ - @UnsupportedAppUsage - /*package*/ BluetoothDevice(String address) { + /*package*/ BluetoothDevice(String address, int addressType) { getService(); // ensures sService is initialized if (!BluetoothAdapter.checkBluetoothAddress(address)) { throw new IllegalArgumentException(address + " is not a valid Bluetooth address"); } + if (addressType != ADDRESS_TYPE_PUBLIC && addressType != ADDRESS_TYPE_RANDOM) { + throw new IllegalArgumentException(addressType + " is not a Bluetooth address type"); + } + mAddress = address; - mAddressType = ADDRESS_TYPE_PUBLIC; + mAddressType = addressType; mAttributionSource = AttributionSource.myAttributionSource(); } + /** + * Create a new BluetoothDevice. + * Bluetooth MAC address must be upper case, such as "00:11:22:33:AA:BB", + * and is validated in this constructor. + * + * @param address valid Bluetooth MAC address + * @throws RuntimeException Bluetooth is not available on this platform + * @throws IllegalArgumentException address is invalid + * @hide + */ + @UnsupportedAppUsage + /*package*/ BluetoothDevice(String address) { + this(address, ADDRESS_TYPE_PUBLIC); + } + /** {@hide} */ public void setAttributionSource(@NonNull AttributionSource attributionSource) { mAttributionSource = attributionSource; |