Skip to content

Commit

Permalink
Fixing Null Pointer exception due to uninitialized view reference.
Browse files Browse the repository at this point in the history
Bug indicates a crash occurred when trying to separate a call from a
conference call.  The exception thrown was due to calling "setText" on
mSecondaryCallProviderLabel when it was null.

Although I was not able to reproduce this situation, it appears it would
be possible for showAndInitializeSecondaryCallInfo to not set the
mSecondaryCallProviderLabel reference when then mSecondaryCallName is
initially set if the hasProvider flag is false at the time.  If
hasProvider becomes true in the future since mSecondaryCallName is already
initialized, the code to initialize mSecondaryCallProviderLabel would not
run, causing the NPE.

I have restructured the code to ensure that this type of scenario is
handled appropriately.

Bug: 18917883
Change-Id: I837d96aad7ed98729490d95beb897b08e1b08365
  • Loading branch information
Tyler Gunn committed Jan 8, 2015
1 parent 179f49b commit fec0d0b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/com/android/incallui/CallCardFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -727,11 +727,12 @@ private void showAndInitializeSecondaryCallInfo(boolean hasProvider) {
mSecondaryCallName = (TextView) getView().findViewById(R.id.secondaryCallName);
mSecondaryCallConferenceCallIcon =
getView().findViewById(R.id.secondaryCallConferenceCallIcon);
if (hasProvider) {
mSecondaryCallProviderInfo.setVisibility(View.VISIBLE);
mSecondaryCallProviderLabel = (TextView) getView()
.findViewById(R.id.secondaryCallProviderLabel);
}
}

if (mSecondaryCallProviderLabel == null && hasProvider) {
mSecondaryCallProviderInfo.setVisibility(View.VISIBLE);
mSecondaryCallProviderLabel = (TextView) getView()
.findViewById(R.id.secondaryCallProviderLabel);
}
}

Expand Down

0 comments on commit fec0d0b

Please sign in to comment.