diff options
author | Rekha Kumar <rekhak@codeaurora.org> | 2015-03-18 09:55:55 -0700 |
---|---|---|
committer | Rekha Kumar <rekhak@quicinc.com> | 2015-03-26 22:56:33 +0000 |
commit | 18c0feda76fe333f3db1bf7bd307458a9e6b6005 (patch) | |
tree | 61c6fcc9baa269a3c81298ae13c8e4a9ac909144 /InCallUI/src/com/android/incallui/VideoPauseController.java | |
parent | 22875bb1d3fa4f023e6ca127a77159ab42bbbabc (diff) |
IMS-VT: Add support for video calls
IMS-VT: Upgrade downgrade and hold resume video calls
-Add support for upgrade downgrade video calls.
-Add support for hold resume and call waiting
IMS-VT: Fixed surface caching.
Fixed surface caching.
IMS-VT: Fixes InCallUI/Dialer crash when there is a VT call.
-Fixes InCallUI/Dialer crash when UE is rotated.
-Fixes InCallUI/Dialer crash when UE VoLTE call
is upgraded to VT.
Don't default to speaker phone for VT when speaker is disabled
- The adb property persist.radio.ims.audio.output indicates
whether speaker is disabled explicitly or not.
- If the above property is set to 1, don't enable speaker
phone by default in VT call.
IMS-VT: Fix CVO, surface and resource related issues.
- Send initial orientation to VT Service.
- Detect if Activity is being destroyed due to
confugration changes.
- Close the camera when InCallUI is pushed to background.
- Fix surface and VT service related issues when Fragment
and Presenter gets destroyed.
IMS-VT: Peer Resolution Feature Implementation
Change display video size based on peer resolution values
received from far end.
IMS-VT: Answering calls and upgrade requests as VT_TX and VT_RX
-Support for showing one way options for incoming upgrade request
-Fix issue where incoming video popup stays on screen even after
rejecting the request.
-Fix issue where incoming video popup stays on even after it has
been timed out by lower layers.
- Answer with different calltypes support.
Notify listeners of video quality changed event and display message on UI
- Add methods to notify listeners of type VideoEventListener
when video quality changes.
- Display a notification on the UI when video quality changes.
IMS-VT: Enable SIP based video multitasking.
Enable SIP based video multitasking.
IMS-VT: Call data usage feature
- Add support for call data usage callback
- Request for call data usage stats
- Log call data usage stats when IMS layers send update
Change-Id: I3f0dde0d82698085fa5d3f110720f10326eca768
IMS-VT: When TTY is ON, do not allow upgrade to VT call
When TTY mode is ON, the user SHOULD NOT be allowed to upgrade
a call from VOLTE to VT/VT-TX/VT-RX and an UI alert message will
be displayed explaining upgrade to VT call cannot be initiated.
IMS-VT: Add null check in call upgrade fail scenario
Crash is observed if call is ended in the interval wherein
handler is started to change state from REQUEST_FAILED to NO_REQUEST
after an interval. Added null check to change state only when call
exists
Propagate call substate message and display a notification on the UI
Ims: Reject upgrade request
1. If there is waiting call that is pending user action and
2. Before offering a waiting call
IMS-VT: Provide Player State indication to user.
Change to display "player started/stopped" toast message
whenever video starts/stops flowing
IMS-VT: Cleanup video views when not required
- Hide video views when not required.
Set display size as per current TextureView size
- Using TextureView height and width to calculate the display size.
- When ever there is change in display make sure that center the display.
IMS-VT: Exit VT call full screen mode.
If the call is no longer a VT call, then exit full screen mode
Change-Id: Ibc4ad8f9a4c38e467820028cdc2c7e68d65fd93c
CRs-Fixed: 760925
IMS-VT: Upgrade button fix
-Show upgrade/downgrade button only when call is in ACTIVE or
ONHOLD state
IMS-VT: Show correct call types during video pause
-In paused state, upgrade downgrade button does not list the
calltypes dropdown box
-Remove the paused bit to calculate call type during video paused
state.
IMS-VT: Move strings for video quality changed indication to resource files
IMS-VT: Clean up the showCallSubstateChanged API
- Make the code more readable.
IMS-VT: Set audio route to Speaker if current route is not bluetooth or headset
- We always set the audio route to speaker when we enter video mode.
- That is not correct. We should check if headset or bluetooth is
connected before defaulting to speaker.
IMS-VT: Turn speaker on/off for video calls based on call state changes
- Turn speaker on only when video call is active or dialing
- Switch back to the previous audio mode when there are no
more calls
- Make the previous audio mode static so that information
persists when the class is recreated (e.g. when UE is
rotated or multitasking happens)
IMS-VT: Use back camera instead of front camera for VT-TX
Set back camera for below cases
1) VOLTE to VT-TX
2) VT to VT-TX
3) Waiting call over Vt-TX call.
IMS-VT: Fix upgrade in call waiting scenarios
-When one VoLTE call is active and another VoLTE call is on hold
and upgrade button is hit, call ends. Fix this upgrade issue.
IMS-VT: Enter video mode when the primary video call changes
- We only enter video mode when we have any video state changes
- Enter video mode should also be called when the video call
changes. e.g. When we have a second call with the same video
state, we don't enter video mode which is incorrect. This
change fixes the issue
Add null check for InCallActivity in setInCallAllowsOrientationChange
- In some cases, this API is called when InCallActivity is null.
This causes a null pointer exception. Fix is to add a null check.
IMS-VT: Fix check for VOLTE call (AND to OR) when turning speaker on
IMS-VT: Check if call is video before enabling speaker in updateAudioMode
- Moved the video call check to the correct block where we
are enabling speaker
IMS-VT: Get call substate values correctly from the bit mask
- We were getting the call substate incorrectly as an int.
- Fixed that by getting it from the bit mask and using the
possible multiple values to display the call substate message.
IMS-VT: Keep the screen on during video calls.
UI screens times out after some time. During
video calls the screen must be kept on.
Change-Id: Icaa8662210b2dd323b29f4a472869a9ed1e01d00
IMS-VT: Open front facing camera for VT calls.
Open front facing camera for VT calls.
IMS-VT: Show manage conference button for Video Call
- We show the manage conference in a separate section for
VOLTE Calls.
- In the case of Video Call, the entire screen is occupied
by the far end video. So we display manage conference in
the overflow section of the call button fragment.
IMS-VT: Fix camera preview freeze for CONF video calls.
Fix camera preview freeze for CONF video calls.
IMS-VT: Move persist.radio.ims.audio.output to frameworks
Move persist.radio.ims.audio.output and related constants to
TelephonyProperties and PhoneConstants so that these can be accessed
from multiple git projects instead of redefining.
IMS-VT: Multiple video call fixes/optimizations.
-Current implementation clears primary call cache upon exiting
video mode. This will remove video call provider interface as
well, which will prevent further communication with the backend.
Don't clear primary call cache upon exiting video mode.
-Unregister call details listener when UI transitions into
unready state
-Send surface of incoming video to video call provider before
opening camera.
IMS: Cleanup all listener objects
Clean all stale listener objects to avoid the memory leak.
IMS: Fix speaker icon display issue in Call UI.
In few devices, InCall UI can show upto five buttons
in a row. Modify code to display at most five buttons
in a row. Show overflow menu if number of buttons is
more than five.
IMS-VT: Show glowpad view with accept/reject for most video upgrade cases
- Show the glowpad view with all options only when upgrading
from Volte to VT
- For all other cases, show the glowpad with accept/reject only
Change-Id: I41ecbda40db7c3c69428fc4272f8bfbd258e2980
Diffstat (limited to 'InCallUI/src/com/android/incallui/VideoPauseController.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/VideoPauseController.java | 389 |
1 files changed, 389 insertions, 0 deletions
diff --git a/InCallUI/src/com/android/incallui/VideoPauseController.java b/InCallUI/src/com/android/incallui/VideoPauseController.java new file mode 100644 index 000000000..727780e8f --- /dev/null +++ b/InCallUI/src/com/android/incallui/VideoPauseController.java @@ -0,0 +1,389 @@ +/* Copyright (c) 2014, The Linux Foundation. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of The Linux Foundation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN + * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package com.android.incallui; + +import android.os.SystemProperties; +import android.telecom.VideoProfile; +import com.android.incallui.Call.State; +import com.android.incallui.InCallPresenter.InCallState; +import com.android.incallui.InCallPresenter.InCallStateListener; +import com.android.incallui.InCallPresenter.IncomingCallListener; +import com.android.incallui.InCallVideoCallListenerNotifier.SessionModificationListener; +import com.android.internal.util.Preconditions; + +/** + * The class is responsible for generating video pause/resume request. + */ +class VideoPauseController implements InCallStateListener, IncomingCallListener, + SessionModificationListener { + private static final String TAG = "VideoCallPauseController:"; + + private class CallContext { + public CallContext(Call call) { + Preconditions.checkNotNull(call); + update(call); + } + + public void update(Call call) { + mCall = Preconditions.checkNotNull(call); + mState = call.getState(); + mId = call.getId(); + mVideoState = call.getVideoState(); + } + + public int getState() { + return mState; + } + + public String getId() { + return mId; + } + + public int getVideoState() { + return mVideoState; + } + + public String toString() { + return String.format("CallContext {CallId=%s, State=%s, VideoState=", + mId, mState, mVideoState); + } + + public Call getCall() { + return mCall; + } + + private int mState = State.INVALID; + private String mId; + private int mVideoState; + private Call mCall; + } + + private InCallPresenter mInCallPresenter; + private static VideoPauseController sVideoPauseController; + + private CallContext mPrimaryCallContext = null; // Context of primary call, if any. + private boolean mIsInBackground = false; // True if UI is not visible, false otherwise. + private int mVideoPauseMode = VIDEO_PAUSE_MODE_DISABLED; + + /** + * Stores current video pause mode. + * 0 - Video Pause is disabled. + * 1 - Video Pause is enabled. + */ + private static final String PROPERTY_VIDEO_PAUSE_MODE = "persist.radio.videopause.mode"; + private static int VIDEO_PAUSE_MODE_DISABLED = 0; + private static int VIDEO_PAUSE_MODE_ENABLED = 1; + + private VideoPauseController() { + mVideoPauseMode = SystemProperties.getInt(PROPERTY_VIDEO_PAUSE_MODE, + VIDEO_PAUSE_MODE_DISABLED); + if (mVideoPauseMode != VIDEO_PAUSE_MODE_ENABLED) { // Validate the mode before using. + mVideoPauseMode = VIDEO_PAUSE_MODE_DISABLED; + } + } + + /*package*/ + static synchronized VideoPauseController getInstance() { + if (sVideoPauseController == null) { + sVideoPauseController = new VideoPauseController(); + } + return sVideoPauseController; + } + + public void setUp(InCallPresenter inCallPresenter) { + if (!isVideoPausedEnabled()) { + return; + } + + log("setUp..."); + mInCallPresenter = Preconditions.checkNotNull(inCallPresenter); + mInCallPresenter.addListener(this); + mInCallPresenter.addIncomingCallListener(this); + InCallVideoCallListenerNotifier.getInstance().addSessionModificationListener(this); + } + + public void tearDown() { + if (!isVideoPausedEnabled()) { + return; + } + + log("tearDown..."); + InCallVideoCallListenerNotifier.getInstance().removeSessionModificationListener(this); + mInCallPresenter.removeListener(this); + mInCallPresenter.removeIncomingCallListener(this); + clear(); + } + + private void clear() { + mInCallPresenter = null; + mPrimaryCallContext = null; + mIsInBackground = false; + } + + /** + * The function gets called when call state changes. + * @param state Phone state. + * @param callList List of current call. + */ + @Override + public void onStateChange(InCallState oldState, InCallState newState, CallList callList) { + log("onStateChange, OldState=" + oldState + " NewState=" + newState); + + Call call = null; + if (newState == InCallState.INCOMING) { + call = callList.getIncomingCall(); + } else if (newState == InCallState.WAITING_FOR_ACCOUNT) { + call = callList.getWaitingForAccountCall(); + } else if (newState == InCallState.PENDING_OUTGOING) { + call = callList.getPendingOutgoingCall(); + } else if (newState == InCallState.OUTGOING) { + call = callList.getOutgoingCall(); + } else { + call = callList.getActiveCall(); + } + + boolean hasPrimaryCallChanged = !areSame(call, mPrimaryCallContext); + boolean canVideoPause = CallUtils.canVideoPause(call); + log("onStateChange, hasPrimaryCallChanged=" + hasPrimaryCallChanged); + log("onStateChange, canVideoPause=" + canVideoPause); + log("onStateChange, IsInBackground=" + mIsInBackground); + + if (hasPrimaryCallChanged) { + onPrimaryCallChanged(call); + return; + } + + if (isOutgoing(mPrimaryCallContext) && canVideoPause && mIsInBackground) { + // Bring UI to foreground if outgoing request becomes active while UI is in + // background. + bringToForeground(); + } else if (!isVideoCall(mPrimaryCallContext) && canVideoPause && mIsInBackground) { + // Bring UI to foreground if VoLTE call becomes active while UI is in + // background. + bringToForeground(); + } + + updatePrimaryCallContext(call); + } + + private void onPrimaryCallChanged(Call call) { + log("onPrimaryCallChanged: New call = " + call); + log("onPrimaryCallChanged: Old call = " + mPrimaryCallContext); + log("onPrimaryCallChanged, IsInBackground=" + mIsInBackground); + + Preconditions.checkState(!areSame(call, mPrimaryCallContext)); + final boolean canVideoPause = CallUtils.canVideoPause(call); + + if (isWaitingCall(mPrimaryCallContext) && canVideoPause && !mIsInBackground) { + // Send resume request for the active call, if user rejects incoming + // call and UI is in foreground. + sendRequest(call, true); + } else if (isWaitingCall(call) && canVideoPause(mPrimaryCallContext)) { + // Send pause request if there is an active video call, and we just received a new + // incoming call. + sendRequest(mPrimaryCallContext.getCall(), false); + } else if (isOutgoing(mPrimaryCallContext) && canVideoPause && !mIsInBackground) { + // Send resume request for the active call, if user ends outgoing call + // and UI is in foreground. + sendRequest(call, true); + } + + updatePrimaryCallContext(call); + } + + /** + * The function gets called when InCallUI receives a new incoming call. + */ + @Override + public void onIncomingCall(InCallState oldState, InCallState newState, Call call) { + log("onIncomingCall, OldState=" + oldState + " NewState=" + newState + " Call=" + call); + + if (areSame(call, mPrimaryCallContext)) { + return; + } + + onPrimaryCallChanged(call); + } + + private void updatePrimaryCallContext(Call call) { + if (call == null) { + mPrimaryCallContext = null; + } else if (mPrimaryCallContext != null) { + mPrimaryCallContext.update(call); + } else { + mPrimaryCallContext = new CallContext(call); + } + } + + /** + * Called when UI goes in/out of the foreground. + * @param showing true if UI is in the foreground, false otherwise. + */ + public void onUiShowing(boolean showing) { + if (!isVideoPausedEnabled() || mInCallPresenter == null) { + return; + } + + final boolean notify = mInCallPresenter.getInCallState() == InCallState.INCALL; + if (showing) { + onResume(notify); + } else { + onPause(notify); + } + } + + @Override + public void onUpgradeToVideoRequest(Call call, int videoState) { + } + + @Override + public void onUpgradeToVideoSuccess(Call call) { + } + + @Override + public void onUpgradeToVideoFail(int status, Call call) { + // TODO (ims-vt) Automatically bring in call ui to foreground. + } + + @Override + public void onDowngradeToAudio(Call call) { + } + + /** + * Called when UI becomes visible. This will send resume request for current video call, if any. + */ + private void onResume(boolean notify) { + log("onResume: notify=" + notify); + + mIsInBackground = false; + if (canVideoPause(mPrimaryCallContext) && notify) { + sendRequest(mPrimaryCallContext.getCall(), true); + } else { + log("onResume. Ignoring..."); + } + } + + /** + * Called when UI becomes invisible. This will send pause request for current video call, if any. + */ + private void onPause(boolean notify) { + log("onPause: notify=" + notify); + + mIsInBackground = true; + if (canVideoPause(mPrimaryCallContext) && notify) { + sendRequest(mPrimaryCallContext.getCall(), false); + } else { + log("onPause, Ignoring..."); + } + } + + private void bringToForeground() { + if (mInCallPresenter != null) { + log("Bringing UI to foreground"); + mInCallPresenter.bringToForeground(false); + } else { + loge("InCallPresenter is null. Cannot bring UI to foreground"); + } + } + + /** + * Sends Pause/Resume request. + * @param call Call to be paused/resumed. + * @param resume If true resume request will be sent, otherwise pause request. + */ + private void sendRequest(Call call, boolean resume) { + if (resume) { + log("sending resume request, call=" + call); + call.getVideoCall().sendSessionModifyRequest(CallUtils.makeVideoUnPauseProfile(call)); + } else { + log("sending pause request, call=" + call); + call.getVideoCall().sendSessionModifyRequest(CallUtils.makeVideoPauseProfile(call)); + } + } + + private boolean isVideoPausedEnabled() { + return mVideoPauseMode != VIDEO_PAUSE_MODE_DISABLED; + } + + private static boolean areSame(Call call, CallContext callContext) { + if (call == null && callContext == null) { + return true; + } else if (call == null || callContext == null) { + return false; + } + return call.getId().equals(callContext.getId()); + } + + private static boolean areSame(CallContext callContext, Call call) { + return areSame(call, callContext); + } + + private static boolean canVideoPause(CallContext callContext) { + return isVideoCall(callContext) && callContext.getState() == Call.State.ACTIVE; + } + + private static boolean isVideoCall(CallContext callContext) { + return callContext != null && VideoProfile.VideoState.isVideo(callContext.getVideoState()); + } + + /** + * Returns true if call is in incoming/waiting state, false otherwise. + */ + private static boolean isWaitingCall(CallContext call) { + return call != null && (call.getState() == Call.State.CALL_WAITING + || call.getState() == Call.State.INCOMING); + } + + private static boolean isWaitingCall(Call call) { + return call != null && (call.getState() == Call.State.CALL_WAITING + || call.getState() == Call.State.INCOMING); + } + + /** + * Returns true if the call is outgoing, false otherwise + */ + private static boolean isOutgoing(CallContext call) { + return call != null && Call.State.isDialing(call.getState()); + } + + /** + * Returns true if the call is on hold, false otherwise + */ + private static boolean isHolding(CallContext call) { + return call != null && call.getState() == Call.State.ONHOLD; + } + + private void log(String msg) { + Log.d(this, TAG + msg); + } + + private void loge(String msg) { + Log.e(this, TAG + msg); + } +} |