From 5bce75f0fbe5b1648ffdcdeb84e8bff2eb78cd72 Mon Sep 17 00:00:00 2001 From: Rahul Sabnis Date: Tue, 24 Mar 2020 18:03:13 -0700 Subject: [PATCH] Verify BluetoothDevice is not null before calling BluetoothHearingAid System APIs Bug: 149238489 Test: Manual Change-Id: Ic6de2ccd81dc66ce79afcd91f18e92e959c8b12b --- .../sound/HandsFreeProfileOutputPreferenceController.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java b/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java index d72f50314c5..d9d87375d4f 100644 --- a/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java +++ b/src/com/android/settings/sound/HandsFreeProfileOutputPreferenceController.java @@ -171,7 +171,8 @@ public class HandsFreeProfileOutputPreferenceController extends AudioSwitchPrefe 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);