Merge "Verify BluetoothDevice is not null before calling BluetoothHearingAid System APIs" into rvc-dev am: 32ec718cfa am: f07ee55a4a
Change-Id: I0c7c481bb49d7d942fb4652bda7842c449ae3631
diff --git a/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java b/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java
index d72f503..d9d8737 100644
--- a/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java
+++ b/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java
@@ -171,7 +171,8 @@
if (hapProfile != null && hfpProfile != null && device == null) {
hfpProfile.setActiveDevice(null);
hapProfile.setActiveDevice(null);
- } else if (hapProfile != null && hapProfile.getHiSyncId(device) != HI_SYNC_ID_INVALID) {
+ } else if (hapProfile != null && device != null
+ && hapProfile.getHiSyncId(device) != HI_SYNC_ID_INVALID) {
hapProfile.setActiveDevice(device);
} else if (hfpProfile != null) {
hfpProfile.setActiveDevice(device);