summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2020-03-25 13:35:10 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-03-25 13:35:10 +0000
commitfc099117fc647bed005ea07cf3fe3baa49a1dfdc (patch)
treef2120488d2df4b9e3d4fbe1168b5a2ad7d7de6a9 /core/java/android
parenta17d04545b5bf9f5bdb401493929c3cd28ca6dbb (diff)
parent4a55841ae506fd05f258f9d63bb8e0406e2658a6 (diff)
Merge "BluetoothHearingAid System APIs now throw an exception if a null BluetoothDevice is passed in" into rvc-dev
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/bluetooth/BluetoothHearingAid.java10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/java/android/bluetooth/BluetoothHearingAid.java b/core/java/android/bluetooth/BluetoothHearingAid.java
index e0674d75974a..fa62a02499e0 100644
--- a/core/java/android/bluetooth/BluetoothHearingAid.java
+++ b/core/java/android/bluetooth/BluetoothHearingAid.java
@@ -379,6 +379,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()
@@ -428,6 +429,7 @@ public final class BluetoothHearingAid implements BluetoothProfile {
@RequiresPermission(Manifest.permission.BLUETOOTH_PRIVILEGED)
public @ConnectionPolicy int getConnectionPolicy(@NonNull BluetoothDevice device) {
if (VDBG) log("getConnectionPolicy(" + device + ")");
+ verifyDeviceNotNull(device, "getConnectionPolicy");
final IBluetoothHearingAid service = getService();
try {
if (service != null && isEnabled()
@@ -504,6 +506,7 @@ public final class BluetoothHearingAid implements BluetoothProfile {
if (VDBG) {
log("getHiSyncId(" + device + ")");
}
+ verifyDeviceNotNull(device, "getConnectionPolicy");
final IBluetoothHearingAid service = getService();
try {
if (service == null) {
@@ -577,6 +580,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;