diff options
author | Ravi Paluri <rpaluri@codeaurora.org> | 2014-11-14 17:52:25 +0530 |
---|---|---|
committer | Arne Coucheron <arco68@gmail.com> | 2014-12-13 01:45:45 +0100 |
commit | 0139d9b0a6e62b387ea39d8359cfe2e825b29626 (patch) | |
tree | 5dab41caf0c9e1afcba3648d8b34e53149412b24 | |
parent | e8ea374284066d144896051100173a4ab04546be (diff) | |
download | packages_apps_InCallUI-0139d9b0a6e62b387ea39d8359cfe2e825b29626.tar.gz packages_apps_InCallUI-0139d9b0a6e62b387ea39d8359cfe2e825b29626.tar.bz2 packages_apps_InCallUI-0139d9b0a6e62b387ea39d8359cfe2e825b29626.zip |
Ims: Reject upgrade request
1. If there is waiting call that is pending user action and
2. Before offering a waiting call
Change-Id: Ic52340de09d71b6d43291b69a1757e717a787370
CRs-Fixed: 748298
-rw-r--r-- | src/com/android/incallui/AnswerPresenter.java | 56 | ||||
-rw-r--r-- | src/com/android/incallui/Call.java | 5 | ||||
-rw-r--r-- | src/com/android/incallui/VideoCallPresenter.java | 23 |
3 files changed, 61 insertions, 23 deletions
diff --git a/src/com/android/incallui/AnswerPresenter.java b/src/com/android/incallui/AnswerPresenter.java index 5e8cd554..90dcff84 100644 --- a/src/com/android/incallui/AnswerPresenter.java +++ b/src/com/android/incallui/AnswerPresenter.java @@ -42,7 +42,12 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> super.onUiReady(ui); final CallList calls = CallList.getInstance(); - Call call; + Call call = calls.getVideoUpgradeRequestCall(); + Log.d(this, "getVideoUpgradeRequestCall call =" + call); + + if (call != null && calls.getIncomingCall() == null) { + processVideoUpgradeRequestCall(call); + } for (int i = 0; i < CallList.PHONE_COUNT; i++) { long[] subId = CallList.getInstance().getSubId(i); call = calls.getCallWithState(Call.State.INCOMING, 0, subId[0]); @@ -53,11 +58,6 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> processIncomingCall(call); } } - call = calls.getVideoUpgradeRequestCall(); - Log.d(this, "getVideoUpgradeRequestCall call=" + call); - if (call != null) { - processVideoUpgradeRequestCall(call); - } // Listen for incoming calls. calls.addListener(this); @@ -99,6 +99,14 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> // getting updates here. Log.d(this, "onIncomingCall: " + this); if (getUi() != null) { + Call modifyCall = CallList.getInstance().getVideoUpgradeRequestCall(); + if (modifyCall != null) { + getUi().showAnswerUi(false); + int modifyPhoneId = CallList.getInstance().getPhoneId(modifyCall.getSubId()); + Log.d(this, "declining upgrade request id: " + modifyPhoneId); + CallList.getInstance().removeCallUpdateListener(mCallId[modifyPhoneId], this); + InCallPresenter.getInstance().declineUpgradeRequest(getUi().getContext()); + } if (!call.getId().equals(mCallId[phoneId])) { // A new call is coming in. processIncomingCall(call); @@ -106,6 +114,15 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> } } + private boolean isVideoUpgradePending(Call call) { + boolean isUpgradePending = false; + if (call.getSessionModificationState() + == Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) { + isUpgradePending = true; + } + return isUpgradePending; + } + @Override public void onUpgradeToVideo(Call call) { Log.d(this, "onUpgradeToVideo: " + this + " call=" + call); @@ -113,8 +130,14 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> Log.d(this, "onUpgradeToVideo ui is null"); return; } - if (call.getSessionModificationState() - == Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) { + boolean isUpgradePending = isVideoUpgradePending(call); + InCallPresenter inCallPresenter = InCallPresenter.getInstance(); + if (isUpgradePending + && inCallPresenter.getInCallState() == InCallPresenter.InCallState.INCOMING) { + Log.d(this, "declining upgrade request"); + inCallPresenter.declineUpgradeRequest(getUi().getContext()); + } else if (isUpgradePending) { + Log.d(this, "process upgrade request as no MT call"); processVideoUpgradeRequestCall(call); } } @@ -153,13 +176,15 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> if (call.getState() != Call.State.INCOMING) { long subId = call.getSubId(); int phoneId = CallList.getInstance().getPhoneId(subId); - // Stop listening for updates. - CallList.getInstance().removeCallUpdateListener(mCallId[phoneId], this); + + boolean isUpgradePending = isVideoUpgradePending(call); + if (!isUpgradePending) { + // Stop listening for updates. + CallList.getInstance().removeCallUpdateListener(mCallId[phoneId], this); + } final Call incall = CallList.getInstance().getIncomingCall(); - if (incall != null - || call.getSessionModificationState() - == Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) { + if (incall != null || isUpgradePending) { getUi().showAnswerUi(true); } else { getUi().showAnswerUi(false); @@ -175,11 +200,6 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> configureAnswerTargetsForSms(call, textMsgs); } } - if (getUi() != null - && call.getSessionModificationState() - == Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST) { - processVideoUpgradeRequestCall(call); - } } // get active phoneId, for which call is visible to user diff --git a/src/com/android/incallui/Call.java b/src/com/android/incallui/Call.java index d9fbcac0..cabdec29 100644 --- a/src/com/android/incallui/Call.java +++ b/src/com/android/incallui/Call.java @@ -492,13 +492,14 @@ public final class Call { @Override public String toString() { return String.format(Locale.US, - "[%s, %s, %s, children:%s, parent:%s, videoState:%d, mIsActivSub:%b]", + "[%s, %s, %s, children:%s, parent:%s, videoState:%d, mIsActivSub:%b," + + " " + "callSubState:%d, mSessionModificationState:%d]", mId, State.toString(getState()), PhoneCapabilities.toString(mTelecommCall.getDetails().getCallCapabilities()), mChildCallIds, getParentId(), mTelecommCall.getDetails().getVideoState(), mIsActiveSub, - mTelecommCall.getDetails().getCallSubstate()); + mTelecommCall.getDetails().getCallSubstate(), mSessionModificationState); } } diff --git a/src/com/android/incallui/VideoCallPresenter.java b/src/com/android/incallui/VideoCallPresenter.java index 68e5a354..9b408866 100644 --- a/src/com/android/incallui/VideoCallPresenter.java +++ b/src/com/android/incallui/VideoCallPresenter.java @@ -724,28 +724,45 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi @Override public void onUpgradeToVideoRequest(Call call) { Log.d(this, "onUpgradeToVideoRequest call=" + call); - mPrimaryCall.setSessionModificationState( + if (mPrimaryCall == null || !Call.areSame(mPrimaryCall, call)) { + Log.w(this, "UpgradeToVideoRequest received for non-primary call"); + } + + if (call == null) { + return; + } + + call.setSessionModificationState( Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST); } @Override public void onUpgradeToVideoSuccess(Call call) { + Log.d(this, "onUpgradeToVideoSuccess call=" + call); if (mPrimaryCall == null || !Call.areSame(mPrimaryCall, call)) { + Log.w(this, "UpgradeToVideoSuccess received for non-primary call"); + } + + if (call == null) { return; } - mPrimaryCall.setSessionModificationState(Call.SessionModificationState.NO_REQUEST); + call.setSessionModificationState(Call.SessionModificationState.NO_REQUEST); } @Override public void onUpgradeToVideoFail(int status, Call call) { Log.d(this, "onUpgradeToVideoFail call=" + call); if (mPrimaryCall == null || !Call.areSame(mPrimaryCall, call)) { + Log.w(this, "UpgradeToVideoFail received for non-primary call"); + } + + if (call == null) { return; } if (status == VideoProvider.SESSION_MODIFY_REQUEST_TIMED_OUT) { - mPrimaryCall.setSessionModificationState( + call.setSessionModificationState( Call.SessionModificationState.UPGRADE_TO_VIDEO_REQUEST_TIMED_OUT); } else { call.setSessionModificationState(Call.SessionModificationState.REQUEST_FAILED); |