From 9a5e351f3b795126bdb1b639da1647a0f0632735 Mon Sep 17 00:00:00 2001 From: Rahul Sabnis Date: Thu, 17 Mar 2022 23:37:38 -0700 Subject: BluetoothHeadset#getAudioState now throws a NullPointerException if the device param is null. Tag: #feature Bug: 222265808 Test: Manual Change-Id: Ifd4eab1c377c8d465d6b6b3f345873210bd44cb8 --- framework/java/android/bluetooth/BluetoothHeadset.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'framework/java/android/bluetooth/BluetoothHeadset.java') diff --git a/framework/java/android/bluetooth/BluetoothHeadset.java b/framework/java/android/bluetooth/BluetoothHeadset.java index 9532c1d3c0..b4819daff5 100644 --- a/framework/java/android/bluetooth/BluetoothHeadset.java +++ b/framework/java/android/bluetooth/BluetoothHeadset.java @@ -49,6 +49,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.concurrent.TimeoutException; /** @@ -930,7 +931,7 @@ public final class BluetoothHeadset implements BluetoothProfile { * * @param device is the Bluetooth device for which the audio state is being queried * @return the audio state of the device or an error code - * @throws IllegalArgumentException if the device is null + * @throws NullPointerException if the device is null * * @hide */ @@ -942,9 +943,7 @@ public final class BluetoothHeadset implements BluetoothProfile { }) public @GetAudioStateReturnValues int getAudioState(@NonNull BluetoothDevice device) { if (VDBG) log("getAudioState"); - if (device == null) { - throw new IllegalArgumentException("device cannot be null"); - } + Objects.requireNonNull(device); final IBluetoothHeadset service = mService; final int defaultValue = BluetoothHeadset.STATE_AUDIO_DISCONNECTED; if (service == null) { -- cgit v1.2.3