diff options
Diffstat (limited to 'InCallUI/src/com/android/incallui/VideoCallPresenter.java')
-rw-r--r-- | InCallUI/src/com/android/incallui/VideoCallPresenter.java | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index 9a33d80eb..3494afa6d 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -81,7 +81,9 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi private Runnable mAutoFullscreenRunnable = new Runnable() { @Override public void run() { - if (mAutoFullScreenPending && !InCallPresenter.getInstance().isDialpadVisible()) { + if (mAutoFullScreenPending && !InCallPresenter.getInstance().isDialpadVisible() + && mIsVideoMode) { + Log.v(this, "Automatically entering fullscreen mode."); InCallPresenter.getInstance().setFullScreen(true); mAutoFullScreenPending = false; @@ -242,6 +244,10 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi InCallVideoCallCallbackNotifier.getInstance().addVideoEventListener(this); mCurrentVideoState = VideoProfile.STATE_AUDIO_ONLY; mCurrentCallState = Call.State.INVALID; + + final InCallPresenter.InCallState inCallState = + InCallPresenter.getInstance().getInCallState(); + onStateChange(inCallState, inCallState, CallList.getInstance()); } /** @@ -258,6 +264,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi return; } + cancelAutoFullScreen(); + InCallPresenter.getInstance().removeListener(this); InCallPresenter.getInstance().removeDetailsListener(this); InCallPresenter.getInstance().removeIncomingCallListener(this); @@ -495,7 +503,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi updateCameraSelection(call); if (isVideoCall) { - enterVideoMode(call); + adjustVideoMode(call); } else if (isVideoMode()) { exitVideoMode(); } @@ -555,7 +563,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi Log.d(this, "onPrimaryCallChanged: Entering video mode..."); updateCameraSelection(newPrimaryCall); - enterVideoMode(newPrimaryCall); + adjustVideoMode(newPrimaryCall); } } @@ -630,7 +638,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi * Handles a change to the video call. Sets the surfaces on the previous call to null and sets * the surfaces on the new video call accordingly. * - * @param videoCall The new video call. + * @param call The new video call. */ private void changeVideoCall(Call call) { final VideoCall videoCall = call.getTelecomCall().getVideoCall(); @@ -651,13 +659,13 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi } if (VideoUtils.isVideoCall(call) && hasChanged) { - enterVideoMode(call); + adjustVideoMode(call); } } private static boolean isCameraRequired(int videoState) { - return VideoProfile.isBidirectional(videoState) || - VideoProfile.isTransmissionEnabled(videoState); + return VideoProfile.isBidirectional(videoState) + || VideoProfile.isTransmissionEnabled(videoState); } private boolean isCameraRequired() { @@ -665,14 +673,16 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi } /** - * Enters video mode by showing the video surfaces and making other adjustments (eg. audio). + * Adjusts the current video mode by setting up the preview and display surfaces as necessary. + * Expected to be called whenever the video state associated with a call changes (e.g. a user + * turns their camera on or off) to ensure the correct surfaces are shown/hidden. * TODO(vt): Need to adjust size and orientation of preview surface here. */ - private void enterVideoMode(Call call) { + private void adjustVideoMode(Call call) { VideoCall videoCall = call.getVideoCall(); int newVideoState = call.getVideoState(); - Log.d(this, "enterVideoMode videoCall= " + videoCall + " videoState: " + newVideoState); + Log.d(this, "adjustVideoMode videoCall= " + videoCall + " videoState: " + newVideoState); VideoCallUi ui = getUi(); if (ui == null) { Log.e(this, "Error VideoCallUi is null so returning"); @@ -692,16 +702,15 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi videoCall.setDeviceOrientation(mDeviceOrientation); enableCamera(videoCall, isCameraRequired(newVideoState)); } + int previousVideoState = mCurrentVideoState; mCurrentVideoState = newVideoState; - mIsVideoMode = true; - maybeAutoEnterFullscreen(call); - } - - private static boolean isSpeakerEnabledForVideoCalls() { - // TODO: Make this a carrier configurable setting. For now this is always true. b/20090407 - return true; + // adjustVideoMode may be called if we are already in a 1-way video state. In this case + // we do not want to trigger auto-fullscreen mode. + if (!VideoUtils.isVideoCall(previousVideoState) && VideoUtils.isVideoCall(newVideoState)) { + maybeAutoEnterFullscreen(call); + } } private void enableCamera(VideoCall videoCall, boolean isCameraRequired) { @@ -1068,6 +1077,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi * 2. Call is not active * 3. Call is not video call * 4. Already in fullscreen mode + * 5. The current video state is not bi-directional (if the remote party stops transmitting, + * the user's contact photo would dominate in fullscreen mode). * * @param call The current call. */ @@ -1079,7 +1090,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi if (call == null || ( call != null && (call.getState() != Call.State.ACTIVE || !VideoUtils.isVideoCall(call)) || - InCallPresenter.getInstance().isFullscreen())) { + InCallPresenter.getInstance().isFullscreen()) || + !VideoUtils.isBidirectionalVideoCall(call)) { // Ensure any previously scheduled attempt to enter fullscreen is cancelled. cancelAutoFullScreen(); return; @@ -1106,10 +1118,6 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi mAutoFullScreenPending = false; } - private static boolean isAudioRouteEnabled(int audioRoute, int audioRouteMask) { - return ((audioRoute & audioRouteMask) != 0); - } - private static void updateCameraSelection(Call call) { Log.d(TAG, "updateCameraSelection: call=" + call); Log.d(TAG, "updateCameraSelection: call=" + toSimpleString(call)); |