diff options
author | Yorke Lee <yorkelee@google.com> | 2014-09-14 11:48:02 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2014-09-14 11:48:02 -0700 |
commit | d8018867dd543809840f65bbd67dbb667d114436 (patch) | |
tree | 60827ff39fc17a0250d1cd9aad54ee5b35ec7721 | |
parent | 4b293f0f08030c97e1bb54d2f79ac2fb1a6e29ae (diff) |
Fix for quick response option not showing up for call waiting
Text messages for a call are loaded by an asynchronous task and are
not populated immediately for a new call.
For the first incoming call, this is not an issue because they are
usually loaded by the time Telecomm binds to InCallService, and
the first call is added to InCallService.
For the second(and subsequent calls) however, they are added to
InCallService immediately before the text messages are loaded. This
means that onIncomingCall is called in AnswerPresenter with a null
list of text messages, which causes it to hide the quick response option.
This CL refactors AnswerPresenter to also update the displayed options
when a change in call state occurs, so that it shows the quick response
option when the list of text messages are eventually loaded and sent to
InCallService.
Bug: 17426049
Change-Id: Id5209b91013b52c5ede5a5dcd4db8a981664c285
-rw-r--r-- | InCallUI/src/com/android/incallui/AnswerPresenter.java | 57 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/CallList.java | 3 |
2 files changed, 36 insertions, 24 deletions
diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java index 2d861f2dd..e42f1fcae 100644 --- a/InCallUI/src/com/android/incallui/AnswerPresenter.java +++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java @@ -32,6 +32,7 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> private String mCallId; private Call mCall = null; + private boolean mHasTextMessages = false; @Override public void onUiReady(AnswerUi ui) { @@ -98,28 +99,7 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> Log.d(TAG, "Showing incoming for call id: " + mCallId + " " + this); final List<String> textMsgs = CallList.getInstance().getTextResponses(call.getId()); getUi().showAnswerUi(true); - - final Context context = getUi().getContext(); - final KeyguardManager km = - (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); - final boolean isLockScreenShowing = km.inKeyguardRestrictedInputMode(); - - boolean withSms = call.can(PhoneCapabilities.RESPOND_VIA_TEXT) && textMsgs != null; - if (call.isVideoCall(context)) { - if (withSms && !isLockScreenShowing) { - getUi().showTargets(AnswerFragment.TARGET_SET_FOR_VIDEO_WITH_SMS); - getUi().configureMessageDialog(textMsgs); - } else { - getUi().showTargets(AnswerFragment.TARGET_SET_FOR_VIDEO_WITHOUT_SMS); - } - } else { - if (withSms && !isLockScreenShowing) { - getUi().showTargets(AnswerFragment.TARGET_SET_FOR_AUDIO_WITH_SMS); - getUi().configureMessageDialog(textMsgs); - } else { - getUi().showTargets(AnswerFragment.TARGET_SET_FOR_AUDIO_WITHOUT_SMS); - } - } + configureAnswerTargetsForSms(call, textMsgs); } private void processVideoUpgradeRequestCall(Call call) { @@ -136,7 +116,7 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> @Override public void onCallChanged(Call call) { Log.d(this, "onCallStateChange() " + call + " " + this); - if (call.getState() != Call.State.INCOMING && call.getState() != Call.State.CALL_WAITING) { + if (call.getState() != Call.State.INCOMING) { // Stop listening for updates. CallList.getInstance().removeCallUpdateListener(mCallId, this); @@ -145,6 +125,12 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> // mCallId will hold the state of the call. We don't clear the mCall variable here as // it may be useful for sending text messages after phone disconnects. mCallId = null; + mHasTextMessages = false; + } else if (!mHasTextMessages) { + final List<String> textMsgs = CallList.getInstance().getTextResponses(call.getId()); + if (textMsgs != null) { + configureAnswerTargetsForSms(call, textMsgs); + } } } @@ -188,6 +174,31 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> InCallPresenter.getInstance().onDismissDialog(); } + private void configureAnswerTargetsForSms(Call call, List<String> textMsgs) { + final Context context = getUi().getContext(); + final KeyguardManager km = + (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE); + final boolean isLockScreenShowing = km.inKeyguardRestrictedInputMode(); + + mHasTextMessages = textMsgs != null; + boolean withSms = call.can(PhoneCapabilities.RESPOND_VIA_TEXT) && mHasTextMessages; + if (call.isVideoCall(context)) { + if (withSms && !isLockScreenShowing) { + getUi().showTargets(AnswerFragment.TARGET_SET_FOR_VIDEO_WITH_SMS); + getUi().configureMessageDialog(textMsgs); + } else { + getUi().showTargets(AnswerFragment.TARGET_SET_FOR_VIDEO_WITHOUT_SMS); + } + } else { + if (withSms && !isLockScreenShowing) { + getUi().showTargets(AnswerFragment.TARGET_SET_FOR_AUDIO_WITH_SMS); + getUi().configureMessageDialog(textMsgs); + } else { + getUi().showTargets(AnswerFragment.TARGET_SET_FOR_AUDIO_WITHOUT_SMS); + } + } + } + interface AnswerUi extends Ui { public void showAnswerUi(boolean show); public void showTargets(int targetSet); diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java index 7e3ec21e4..ea0448705 100644 --- a/InCallUI/src/com/android/incallui/CallList.java +++ b/InCallUI/src/com/android/incallui/CallList.java @@ -88,6 +88,7 @@ public class CallList implements InCallPhoneListener { if (updateCallInMap(call)) { Log.w(this, "Removing call not previously disconnected " + call.getId()); } + updateCallTextMap(call, null); } } }; @@ -380,7 +381,7 @@ public class CallList implements InCallPhoneListener { if (updateCallInMap(call)) { Log.i(this, "onUpdate - " + call); } - updateCallTextMap(call, null); + updateCallTextMap(call, call.getCannedSmsResponses()); notifyCallUpdateListeners(call); } |