diff options
author | Tyler Gunn <tgunn@google.com> | 2016-05-06 15:25:45 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-05-06 15:25:45 +0000 |
commit | 43fd36a1b2252814c3aa0768d140ede05c84ea16 (patch) | |
tree | cb50c4df5c9e7f52be3d363f9ea2435b15d36164 | |
parent | 55c30b2d7fb5e5341fef9dfb257aab6307e2ce59 (diff) | |
parent | 7c2e0ac9cf2290f76fb56bec37900f2e814d1e23 (diff) |
Merge "Fix issues with video auto-fullscreen mode." into nyc-mr1-dev
-rw-r--r-- | InCallUI/src/com/android/incallui/VideoCallFragment.java | 3 | ||||
-rw-r--r-- | InCallUI/src/com/android/incallui/VideoCallPresenter.java | 48 |
2 files changed, 29 insertions, 22 deletions
diff --git a/InCallUI/src/com/android/incallui/VideoCallFragment.java b/InCallUI/src/com/android/incallui/VideoCallFragment.java index cb8c6449b..2e65f81b4 100644 --- a/InCallUI/src/com/android/incallui/VideoCallFragment.java +++ b/InCallUI/src/com/android/incallui/VideoCallFragment.java @@ -499,6 +499,7 @@ public class VideoCallFragment extends BaseFragment<VideoCallPresenter, public void onPause() { super.onPause(); Log.d(this, "onPause:"); + getPresenter().cancelAutoFullScreen(); } @Override @@ -549,6 +550,7 @@ public class VideoCallFragment extends BaseFragment<VideoCallPresenter, * Hides and shows the incoming video view and changes the outgoing video view's state based on * whether outgoing view is enabled or not. */ + @Override public void showVideoViews(boolean previewPaused, boolean showIncoming) { inflateVideoUi(true); @@ -567,6 +569,7 @@ public class VideoCallFragment extends BaseFragment<VideoCallPresenter, /** * Hide all video views. */ + @Override public void hideVideoUi() { inflateVideoUi(false); } diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index 9a33d80eb..7617608d1 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; @@ -258,6 +260,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi return; } + cancelAutoFullScreen(); + InCallPresenter.getInstance().removeListener(this); InCallPresenter.getInstance().removeDetailsListener(this); InCallPresenter.getInstance().removeIncomingCallListener(this); @@ -495,7 +499,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi updateCameraSelection(call); if (isVideoCall) { - enterVideoMode(call); + adjustVideoMode(call); } else if (isVideoMode()) { exitVideoMode(); } @@ -555,7 +559,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi Log.d(this, "onPrimaryCallChanged: Entering video mode..."); updateCameraSelection(newPrimaryCall); - enterVideoMode(newPrimaryCall); + adjustVideoMode(newPrimaryCall); } } @@ -630,7 +634,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 +655,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 +669,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 +698,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 +1073,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 +1086,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 +1114,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)); |