From d9c22d541f04eefc748c65c252353ab1395a7537 Mon Sep 17 00:00:00 2001 From: Jay Shrauner Date: Fri, 21 Mar 2014 10:08:20 -0700 Subject: Fix NPE in ConferenceManagerPresenter Fix NPE in ConferenceManagerPresenter Bug:13582463 Change-Id: I31ec7b72142828832b6b2edaa89bb2b499da966c --- .../incallui/ConferenceManagerPresenter.java | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'InCallUI/src/com/android/incallui') diff --git a/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java b/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java index 1ba88cbd7..6e73a69e0 100644 --- a/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java +++ b/InCallUI/src/com/android/incallui/ConferenceManagerPresenter.java @@ -35,7 +35,6 @@ public class ConferenceManagerPresenter private static final int MAX_CALLERS_IN_CONFERENCE = 5; - private int mNumCallersInConference; private Integer[] mCallerIds; private Context mContext; @@ -80,10 +79,15 @@ public class ConferenceManagerPresenter } private void update(CallList callList) { - mCallerIds = null; - mCallerIds = callList.getActiveOrBackgroundCall().getChildCallIds().toArray(new Integer[0]); - mNumCallersInConference = mCallerIds.length; - Log.v(this, "Number of calls is " + String.valueOf(mNumCallersInConference)); + // callList is non null, but getActiveOrBackgroundCall() may return null + final Call currentCall = callList.getActiveOrBackgroundCall(); + if (currentCall != null) { + // getChildCallIds() always returns a valid Set + mCallerIds = currentCall.getChildCallIds().toArray(new Integer[0]); + } else { + mCallerIds = new Integer[0]; + } + Log.d(this, "Number of calls is " + String.valueOf(mCallerIds.length)); // Users can split out a call from the conference call if there either the active call // or the holding call is empty. If both are filled at the moment, users can not split out @@ -93,7 +97,7 @@ public class ConferenceManagerPresenter boolean canSeparate = !(hasActiveCall && hasHoldingCall); for (int i = 0; i < MAX_CALLERS_IN_CONFERENCE; i++) { - if (i < mNumCallersInConference) { + if (i < mCallerIds.length) { // Fill in the row in the UI for this caller. final ContactCacheEntry contactCache = ContactInfoCache.getInstance(mContext). @@ -149,11 +153,15 @@ public class ConferenceManagerPresenter } public void separateConferenceConnection(int rowId) { - CallCommandClient.getInstance().separateCall(mCallerIds[rowId]); + if (rowId < mCallerIds.length) { + CallCommandClient.getInstance().separateCall(mCallerIds[rowId]); + } } public void endConferenceConnection(int rowId) { - CallCommandClient.getInstance().disconnectCall(mCallerIds[rowId]); + if (rowId < mCallerIds.length) { + CallCommandClient.getInstance().disconnectCall(mCallerIds[rowId]); + } } public interface ConferenceManagerUi extends Ui { -- cgit v1.2.3