diff options
author | NathanielWaggoner <nwaggoner@cyngn.com> | 2016-05-06 13:35:52 -0700 |
---|---|---|
committer | NathanielWaggoner <nwaggoner@cyngn.com> | 2016-05-09 11:31:10 -0700 |
commit | 7422ffba013e84dea25513bf209933f9068fbb68 (patch) | |
tree | f62aa7d6de6030525204b19c16a1dc7233f3e990 /src | |
parent | 9109b539d245ce94f5675e21c119a5f79cb89266 (diff) | |
download | packages_apps_InCallUI-7422ffba013e84dea25513bf209933f9068fbb68.tar.gz packages_apps_InCallUI-7422ffba013e84dea25513bf209933f9068fbb68.tar.bz2 packages_apps_InCallUI-7422ffba013e84dea25513bf209933f9068fbb68.zip |
Fixes a crash when trying to take a note in a Conference Call
We weren't populating the call data correctly during a conference
call and this was causing the DeepLinkAPI to throw an exception.
NOTES-94
Change-Id: Idbfe216e8e3b378358e765003c0e8148856c30b4
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/incallui/ModButtonPresenter.java | 70 |
1 files changed, 56 insertions, 14 deletions
diff --git a/src/com/android/incallui/ModButtonPresenter.java b/src/com/android/incallui/ModButtonPresenter.java index df350f54..d2d78e73 100644 --- a/src/com/android/incallui/ModButtonPresenter.java +++ b/src/com/android/incallui/ModButtonPresenter.java @@ -369,21 +369,29 @@ public class ModButtonPresenter extends Presenter<ModButtonPresenter.ModButtonUi } public void takeNote() { - if (mCall != null && mNoteDeepLink != null) { - Context ctx = getUi().getContext(); - - android.telecom.Call.Details details = mCall.getTelecommCall().getDetails(); - CallDeepLinkContent content = new CallDeepLinkContent(mNoteDeepLink); - content.setName(TextUtils.isEmpty(mPrimaryContactInfo.name) ? - ctx.getString(R.string.deeplink_unknown_caller) : mPrimaryContactInfo.name); - content.setNumber(mCall.getNumber()); - content.setUri(DeepLinkIntegrationManager.generateCallUri(mCall.getNumber(), - details.getCreateTimeMillis())); - DeepLinkIntegrationManager.getInstance().sendContentSentEvent(ctx, mNoteDeepLink, - new ComponentName(ctx, CallButtonPresenter.class)); - ctx.startActivity(content.build()); - + if (mCall == null || mNoteDeepLink == null || getUi() == null) { + return; + } + Context ctx = getUi().getContext(); + android.telecom.Call.Details details = mCall.getTelecommCall().getDetails(); + String name; + String number; + if (mCall.isConferenceCall()) { + NoteCallInfo noteCallInfo = getNoteCallInfoForConferenceCall(ctx); + name = noteCallInfo.mNames; + number = noteCallInfo.mNumbers; + } else { + name = getNormalizedName(ctx, mPrimaryContactInfo.name); + number = mCall.getNumber(); } + CallDeepLinkContent content = new CallDeepLinkContent(mNoteDeepLink); + content.setNumber(number); + content.setName(name); + content.setUri(DeepLinkIntegrationManager.generateCallUri(number, + details.getCreateTimeMillis())); + DeepLinkIntegrationManager.getInstance().sendContentSentEvent(ctx, mNoteDeepLink, + new ComponentName(ctx, CallButtonPresenter.class)); + ctx.startActivity(content.build()); } public void getPreferredLinks() { @@ -395,6 +403,31 @@ public class ModButtonPresenter extends Presenter<ModButtonPresenter.ModButtonUi } } + private NoteCallInfo getNoteCallInfoForConferenceCall(Context ctx) { + StringBuilder names = new StringBuilder(); + StringBuilder numbers = new StringBuilder(); + List<String> callIds = mCall.getChildCallIds(); + int len = callIds.size(); + for (int i = 0; i < len; i++) { + ContactCacheEntry callInfo = ContactInfoCache.getInstance( + getUi().getContext()).getInfo(callIds.get(i)); + if (callInfo != null) { + numbers.append(callInfo.number); + names.append(getNormalizedName(ctx, callInfo.name)); + if (i < len - 1) { + numbers.append(", "); + names.append(", "); + } + } + } + return new NoteCallInfo(numbers.toString(), names.toString()); + } + + private String getNormalizedName(Context ctx, String name) { + return TextUtils.isEmpty(name) ? + ctx.getString(R.string.deeplink_unknown_caller) : mPrimaryContactInfo.name; + } + private ResultCallback<DeepLink.DeepLinkResultList> mNoteDeepLinkCallback = new ResultCallback<DeepLink.DeepLinkResultList>() { @Override @@ -425,4 +458,13 @@ public class ModButtonPresenter extends Presenter<ModButtonPresenter.ModButtonUi (Settings.Global.getInt(context.getContentResolver(), Settings.Global.DEVICE_PROVISIONED, 0) != 0); } + + private class NoteCallInfo { + public NoteCallInfo(String numbers, String names) { + mNames = names; + mNumbers = numbers; + } + String mNames; + String mNumbers; + } } |