diff options
| author | Rahul Sabnis <rahulsabnis@google.com> | 2020-03-24 17:22:15 -0700 |
|---|---|---|
| committer | Rahul Sabnis <rahulsabnis@google.com> | 2020-03-25 13:50:36 -0700 |
| commit | eb5712abd209dd51846bb53dc9203755e8b43bfb (patch) | |
| tree | 56895b37187445de4839625cfed8cb92580af26f /core/java/android/bluetooth | |
| parent | 3986bb5040ff67dbebaf919b97197dfbf1ed3c1b (diff) | |
BluetoothHearingAid System APIs now throw an exception if a null
BluetoothDevice is passed in
Bug: 149238489
Test: Manual
Merged-In: I594f558bfe1e286bf74dd8dc3db4c8497fd0a025
Change-Id: I594f558bfe1e286bf74dd8dc3db4c8497fd0a025
Diffstat (limited to 'core/java/android/bluetooth')
| -rw-r--r-- | core/java/android/bluetooth/BluetoothHearingAid.java | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothHearingAid.java b/core/java/android/bluetooth/BluetoothHearingAid.java index 5891072ec7c1..c52b3d4028b6 100644 --- a/core/java/android/bluetooth/BluetoothHearingAid.java +++ b/core/java/android/bluetooth/BluetoothHearingAid.java @@ -386,6 +386,7 @@ public final class BluetoothHearingAid implements BluetoothProfile { public boolean setConnectionPolicy(@NonNull BluetoothDevice device, @ConnectionPolicy int connectionPolicy) { if (DBG) log("setConnectionPolicy(" + device + ", " + connectionPolicy + ")"); + verifyDeviceNotNull(device, "setConnectionPolicy"); final IBluetoothHearingAid service = getService(); try { if (service != null && isEnabled() @@ -435,6 +436,7 @@ public final class BluetoothHearingAid implements BluetoothProfile { @RequiresPermission(Manifest.permission.BLUETOOTH) public @ConnectionPolicy int getConnectionPolicy(@NonNull BluetoothDevice device) { if (VDBG) log("getConnectionPolicy(" + device + ")"); + verifyDeviceNotNull(device, "getConnectionPolicy"); final IBluetoothHearingAid service = getService(); try { if (service != null && isEnabled() @@ -511,6 +513,7 @@ public final class BluetoothHearingAid implements BluetoothProfile { if (VDBG) { log("getHiSyncId(" + device + ")"); } + verifyDeviceNotNull(device, "getConnectionPolicy"); final IBluetoothHearingAid service = getService(); try { if (service == null) { @@ -584,6 +587,13 @@ public final class BluetoothHearingAid implements BluetoothProfile { return false; } + private void verifyDeviceNotNull(BluetoothDevice device, String methodName) { + if (device == null) { + Log.e(TAG, methodName + ": device param is null"); + throw new IllegalArgumentException("Device cannot be null"); + } + } + private boolean isValidDevice(BluetoothDevice device) { if (device == null) return false; |
