From c53600a348cd3fbea985e33310cf3c0957894c10 Mon Sep 17 00:00:00 2001 From: Nancy Chen Date: Thu, 4 Feb 2016 17:47:33 -0800 Subject: Fix NPE caused by misplaced parenthesis. In onStateChange, this branch of logic should be not be followed if mPrimary is null. Bug: 27045730 Change-Id: Ia948313d4886475dd5966b209c19696cb594ed59 --- InCallUI/src/com/android/incallui/CallCardPresenter.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'InCallUI') diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index f54c633b3..21e8a674b 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -247,7 +247,6 @@ public class CallCardPresenter extends Presenter Call.areSameNumber(mPrimary, primary)); final boolean secondaryChanged = !(Call.areSame(mSecondary, secondary) && Call.areSameNumber(mSecondary, secondary)); - final boolean shouldShowCallSubject = shouldShowCallSubject(mPrimary); mSecondary = secondary; Call previousPrimary = mPrimary; @@ -260,9 +259,8 @@ public class CallCardPresenter extends Presenter // Refresh primary call information if either: // 1. Primary call changed. // 2. The call's ability to manage conference has changed. - if (mPrimary != null && (primaryChanged || - ui.isManageConferenceVisible() != shouldShowManageConference()) || - ui.isCallSubjectVisible() != shouldShowCallSubject) { + // 3. The call subject should be shown or hidden. + if (shouldRefreshPrimaryInfo(primaryChanged, ui, shouldShowCallSubject(mPrimary))) { // primary call has changed if (previousPrimary != null) { CallList.getInstance().removeCallUpdateListener(previousPrimary.getId(), this); @@ -394,6 +392,16 @@ public class CallCardPresenter extends Presenter updatePrimaryDisplayInfo(); } + private boolean shouldRefreshPrimaryInfo(boolean primaryChanged, CallCardUi ui, + boolean shouldShowCallSubject) { + if (mPrimary == null) { + return false; + } + return primaryChanged || + ui.isManageConferenceVisible() != shouldShowManageConference() || + ui.isCallSubjectVisible() != shouldShowCallSubject; + } + private String getSubscriptionNumber() { // If it's an emergency call, and they're not populating the callback number, // then try to fall back to the phone sub info (to hopefully get the SIM's -- cgit v1.2.3