From 47414b4f26a7c25ea8413d7df9194fd4a9c82699 Mon Sep 17 00:00:00 2001 From: Yuzhou Date: Thu, 14 Jun 2018 18:40:02 -0700 Subject: Fix NPE in UiCallManager which will happen if Bluetooth is not supported. Test: build and load the app. Bug: 109894902 Change-Id: I67ab9ef3bb8d9f67183c6d01e2448bec1d06e8a2 --- .../android/car/dialer/telecom/UiCallManager.java | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/com/android/car/dialer/telecom/UiCallManager.java b/src/com/android/car/dialer/telecom/UiCallManager.java index 0e9c2a1a..be424872 100644 --- a/src/com/android/car/dialer/telecom/UiCallManager.java +++ b/src/com/android/car/dialer/telecom/UiCallManager.java @@ -134,18 +134,20 @@ public class UiCallManager { context.bindService(intent, mInCallServiceConnection, Context.BIND_AUTO_CREATE); BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter(); - adapter.getProfileProxy(mContext, new BluetoothProfile.ServiceListener() { - @Override - public void onServiceConnected(int profile, BluetoothProfile proxy) { - if (profile == BluetoothProfile.HEADSET_CLIENT) { - mBluetoothHeadsetClient = (BluetoothHeadsetClient) proxy; + if (adapter != null) { + adapter.getProfileProxy(mContext, new BluetoothProfile.ServiceListener() { + @Override + public void onServiceConnected(int profile, BluetoothProfile proxy) { + if (profile == BluetoothProfile.HEADSET_CLIENT) { + mBluetoothHeadsetClient = (BluetoothHeadsetClient) proxy; + } } - } - @Override - public void onServiceDisconnected(int profile) { - } - }, BluetoothProfile.HEADSET_CLIENT); + @Override + public void onServiceDisconnected(int profile) { + } + }, BluetoothProfile.HEADSET_CLIENT); + } } private final ServiceConnection mInCallServiceConnection = new ServiceConnection() { -- cgit v1.2.3