diff options
author | Tyler Gunn <tgunn@google.com> | 2014-12-09 15:09:38 -0800 |
---|---|---|
committer | Natiq Ahmed <mnatiq@codeaurora.org> | 2015-03-13 15:00:30 +0530 |
commit | eedd00782207267f45f364470e7bd8808fbe0938 (patch) | |
tree | 12053e4fccf8ee5d6118ab8b4ffe5f1e09364669 | |
parent | 0dda771db2bcc717eb1747c84fd072c564ce6f29 (diff) | |
download | android_packages_apps_Dialer-eedd00782207267f45f364470e7bd8808fbe0938.tar.gz android_packages_apps_Dialer-eedd00782207267f45f364470e7bd8808fbe0938.tar.bz2 android_packages_apps_Dialer-eedd00782207267f45f364470e7bd8808fbe0938.zip |
Fix potential NPE when generating accessibility text.
Traced through the original bug report; the problem is that a call to
TextUtils.expandTemplate was being made with a null 2nd parameter.
I traced through the callers to find out where a null could be introduced
and I was unable to identify a potential source. This change introduces
a last-ditch null check to protect against problems upstream.
Bug: 18684529
Change-Id: I7b608dfedf052d6933e94d1f23a658763b66059a
-rw-r--r-- | src/com/android/dialer/calllog/CallLogListItemHelper.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/com/android/dialer/calllog/CallLogListItemHelper.java b/src/com/android/dialer/calllog/CallLogListItemHelper.java index f4ea07e84..4e30cfdef 100644 --- a/src/com/android/dialer/calllog/CallLogListItemHelper.java +++ b/src/com/android/dialer/calllog/CallLogListItemHelper.java @@ -20,6 +20,7 @@ import android.content.Context; import android.content.res.Resources; import android.provider.CallLog.Calls; import android.text.TextUtils; +import android.util.Log; import com.android.contacts.common.CallUtil; import com.android.dialer.PhoneCallDetails; @@ -30,6 +31,8 @@ import com.android.dialer.R; * Helper class to fill in the views of a call log entry. */ /* package */class CallLogListItemHelper { + private static final String TAG = "CallLogListItemHelper"; + /** Helper for populating the details of a phone call. */ private final PhoneCallDetailsHelper mPhoneCallDetailsHelper; /** Helper for handling phone numbers. */ @@ -78,17 +81,25 @@ import com.android.dialer.R; * @param views The views associated with the current call log entry. */ public void setActionContentDescriptions(CallLogListItemViews views) { + if (views.nameOrNumber == null) { + Log.e(TAG, "setActionContentDescriptions; name or number is null."); + } + + // Calling expandTemplate with a null parameter will cause a NullPointerException. + // Although we don't expect a null name or number, it is best to protect against it. + CharSequence nameOrNumber = views.nameOrNumber == null ? "" : views.nameOrNumber; + views.callBackButtonView.setContentDescription( - mResources.getString(R.string.description_call_back_action, views.nameOrNumber)); + mResources.getString(R.string.description_call_back_action, nameOrNumber)); views.videoCallButtonView.setContentDescription( - mResources.getString(R.string.description_video_call_action, views.nameOrNumber)); + mResources.getString(R.string.description_video_call_action, nameOrNumber)); views.voicemailButtonView.setContentDescription( - mResources.getString(R.string.description_voicemail_action, views.nameOrNumber)); + mResources.getString(R.string.description_voicemail_action, nameOrNumber)); views.detailsButtonView.setContentDescription( - mResources.getString(R.string.description_details_action, views.nameOrNumber)); + mResources.getString(R.string.description_details_action, nameOrNumber)); } /** |