From 04b127e4dc8526de22809d3a83a6920511391ee3 Mon Sep 17 00:00:00 2001
From: Rupesh Tatiya <rtatiya@codeaurora.org>
Date: Mon, 6 Jun 2016 19:34:29 +0530
Subject: [PATCH] Check size of connected devices array for A2DP

A2dp can return array of size 0, if no A2DP devices is connected.
Without this check,A2DP status is set to true.
This results in FM audio failure.

Change-Id: Ib5976a50a4477f60339a954ed923d0719924b1ca
---
 fmapp2/src/com/caf/fmradio/FMRadioService.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fmapp2/src/com/caf/fmradio/FMRadioService.java b/fmapp2/src/com/caf/fmradio/FMRadioService.java
index 6554c90..0b7a366 100644
--- a/fmapp2/src/com/caf/fmradio/FMRadioService.java
+++ b/fmapp2/src/com/caf/fmradio/FMRadioService.java
@@ -3741,11 +3741,11 @@ public class FMRadioService extends Service
        public void onServiceConnected(int profile, BluetoothProfile proxy) {
            mA2dpProfile = (BluetoothA2dp) proxy;
            mA2dpDeviceList = mA2dpProfile.getConnectedDevices();
-
-           if (mA2dpDeviceList.isEmpty())
+           if (mA2dpDeviceList == null || mA2dpDeviceList.size() == 0)
                mA2dpConnected = false;
            else
                mA2dpConnected = true;
+
            mA2dpDisconnected = !mA2dpConnected;
            mSpeakerPhoneOn = mA2dpConnected;
            Log.d(LOGTAG, "A2DP Status: " + mA2dpConnected);
-- 
GitLab