diff options
9 files changed, 54 insertions, 36 deletions
diff --git a/InCallUI/src/com/android/incallui/Call.java b/InCallUI/src/com/android/incallui/Call.java index 663c4120a..fd06e53b3 100644 --- a/InCallUI/src/com/android/incallui/Call.java +++ b/InCallUI/src/com/android/incallui/Call.java @@ -371,8 +371,12 @@ public final class Call { } public boolean isVideoCall(Context context) { - return CallUtil.isVideoEnabled(context) && - VideoProfile.VideoState.isBidirectional(getVideoState()); + // We want to show Video call buttons even if only one direction is enabled + // (That is what is happening when we receive a video call for example) + return CallUtil.isVideoEnabled(context) && ( + VideoProfile.VideoState.isBidirectional(getVideoState()) || + VideoProfile.VideoState.isReceptionEnabled(getVideoState()) || + VideoProfile.VideoState.isTransmissionEnabled(getVideoState())); } public void setSessionModificationState(int state) { diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index 9897d3744..9fedc95b1 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -258,7 +258,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto new VideoProfile(VideoProfile.VideoState.BIDIRECTIONAL); videoCall.sendSessionModifyRequest(videoProfile); - mCall.setSessionModificationState(Call.SessionModificationState.REQUEST_FAILED); + mCall.setSessionModificationState(Call.SessionModificationState.WAITING_FOR_RESPONSE); } /** diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 28f449b93..6550eecdc 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -796,16 +796,6 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr } /** - * Changes the visibility of the contact photo. - * - * @param isVisible {@code True} if the UI should show the contact photo. - */ - @Override - public void setPhotoVisible(boolean isVisible) { - mPhoto.setVisibility(isVisible ? View.VISIBLE : View.GONE); - } - - /** * Changes the visibility of the HD audio icon. * * @param visible {@code true} if the UI should show the HD audio icon. diff --git a/InCallUI/src/com/android/incallui/CallCardPresenter.java b/InCallUI/src/com/android/incallui/CallCardPresenter.java index d7e39d8c9..3a4c46a60 100644 --- a/InCallUI/src/com/android/incallui/CallCardPresenter.java +++ b/InCallUI/src/com/android/incallui/CallCardPresenter.java @@ -248,14 +248,6 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> getUi().showHdAudioIndicator(false); } - // Hide/show the contact photo based on the video state. - // If the primary call is a video call on hold, still show the contact photo. - // If the primary call is an active video call, hide the contact photo. - if (mPrimary != null) { - getUi().setPhotoVisible(!(mPrimary.isVideoCall(mContext) && - callState != Call.State.ONHOLD)); - } - maybeShowManageConferenceCallButton(); final boolean enableEndCallButton = Call.State.isConnectingOrConnected(callState) && @@ -334,9 +326,15 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> private void setCallbackNumber() { String callbackNumber = null; + // Show the emergency callback number if either: + // 1. This is an emergency call. + // 2. The phone is in Emergency Callback Mode, which means we should show the callback + // number. boolean isEmergencyCall = PhoneNumberUtils.isEmergencyNumber( getNumberFromHandle(mPrimary.getHandle())); - if (isEmergencyCall) { + boolean showCallbackNumber = mPrimary.can(Details.CAPABILITY_SHOW_CALLBACK_NUMBER); + + if (isEmergencyCall || showCallbackNumber) { callbackNumber = getSubscriptionNumber(); } else { StatusHints statusHints = mPrimary.getTelecommCall().getDetails().getStatusHints(); @@ -350,12 +348,13 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> TelecomManager mgr = InCallPresenter.getInstance().getTelecomManager(); String simNumber = mgr.getLine1Number(mPrimary.getAccountHandle()); - if (PhoneNumberUtils.compare(callbackNumber, simNumber)) { - Log.d(this, "Numbers are the same; not showing the callback number"); + if (!showCallbackNumber && PhoneNumberUtils.compare(callbackNumber, simNumber)) { + Log.d(this, "Numbers are the same (and callback number is not being forced to show);" + + " not showing the callback number"); callbackNumber = null; } - getUi().setCallbackNumber(callbackNumber, isEmergencyCall); + getUi().setCallbackNumber(callbackNumber, isEmergencyCall || showCallbackNumber); } public void updateCallTime() { @@ -746,7 +745,6 @@ public class CallCardPresenter extends Presenter<CallCardPresenter.CallCardUi> void setPrimaryLabel(String label); void setEndCallButtonEnabled(boolean enabled, boolean animate); void setCallbackNumber(String number, boolean isEmergencyCalls); - void setPhotoVisible(boolean isVisible); void setProgressSpinnerVisible(boolean visible); void showHdAudioIndicator(boolean visible); void showManageConferenceCallButton(boolean visible); diff --git a/InCallUI/src/com/android/incallui/GlowPadWrapper.java b/InCallUI/src/com/android/incallui/GlowPadWrapper.java index 47547125b..b50fdd8c2 100644 --- a/InCallUI/src/com/android/incallui/GlowPadWrapper.java +++ b/InCallUI/src/com/android/incallui/GlowPadWrapper.java @@ -124,6 +124,7 @@ public class GlowPadWrapper extends GlowPadView implements GlowPadView.OnTrigger mTargetTriggered = true; break; case R.drawable.ic_videocam: + case R.drawable.ic_lockscreen_answer_video: mAnswerListener.onAnswer(VideoProfile.VideoState.BIDIRECTIONAL, getContext()); mTargetTriggered = true; break; diff --git a/InCallUI/src/com/android/incallui/InCallVideoCallListener.java b/InCallUI/src/com/android/incallui/InCallVideoCallListener.java index 363bd4144..245fc7316 100644 --- a/InCallUI/src/com/android/incallui/InCallVideoCallListener.java +++ b/InCallUI/src/com/android/incallui/InCallVideoCallListener.java @@ -86,9 +86,14 @@ public class InCallVideoCallListener extends VideoCall.Listener { VideoProfile.VideoState.isBidirectional(responseProfile.getVideoState()); if (modifySucceeded && isVideoCall) { + // Local Upgrade success InCallVideoCallListenerNotifier.getInstance().upgradeToVideoSuccess(mCall); } else if (!modifySucceeded || status != Connection.VideoProvider.SESSION_MODIFY_REQUEST_SUCCESS) { + // Remote didn't accept invitation in bidirectional state or failure InCallVideoCallListenerNotifier.getInstance().upgradeToVideoFail(mCall); + } else if (modifySucceeded && !isVideoCall) { + // Local Downgrade success (should always be successful) + InCallVideoCallListenerNotifier.getInstance().downgradeToAudio(mCall); } } diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index 4a0216061..006339ce1 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -207,6 +207,14 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { (!isOutgoingWithoutIncallUi || mNotificationTimer.getState() == NotificationTimer.State.FIRED); + // For call upgrade + if ((call != null) + && (call.getSessionModificationState() + == Call.SessionModificationState.RECEIVED_UPGRADE_TO_VIDEO_REQUEST)) { + Log.d(this, "updateInCallNotification, notify of callupgrade to video!"); + showNotificationNow = true; + } + if (showNotificationNow) { showNotification(call); } else { @@ -556,16 +564,16 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener { Log.i(this, "Will show \"accept\" action in the incoming call Notification"); PendingIntent acceptVideoPendingIntent = createNotificationPendingIntent( - mContext, InCallApp.ACTION_ANSWER_VOICE_INCOMING_CALL); + mContext, InCallApp.ACTION_ACCEPT_VIDEO_UPGRADE_REQUEST); builder.addAction(0, mContext.getText(R.string.notification_action_accept), - acceptVideoPendingIntent); + acceptVideoPendingIntent); } private void addDismissUpgradeRequestAction(Notification.Builder builder) { Log.i(this, "Will show \"dismiss\" action in the incoming call Notification"); PendingIntent declineVideoPendingIntent = createNotificationPendingIntent( - mContext, InCallApp.ACTION_ANSWER_VOICE_INCOMING_CALL); + mContext, InCallApp.ACTION_DECLINE_VIDEO_UPGRADE_REQUEST); builder.addAction(0, mContext.getText(R.string.notification_action_dismiss), declineVideoPendingIntent); } diff --git a/InCallUI/src/com/android/incallui/VideoCallFragment.java b/InCallUI/src/com/android/incallui/VideoCallFragment.java index 0b5bb4b23..7859a17bc 100644 --- a/InCallUI/src/com/android/incallui/VideoCallFragment.java +++ b/InCallUI/src/com/android/incallui/VideoCallFragment.java @@ -164,7 +164,7 @@ public class VideoCallFragment extends BaseFragment<VideoCallPresenter, // orientation change. if (mSavedSurfaceTexture == null) { mSavedSurfaceTexture = surfaceTexture; - surfaceCreated = createSurface(); + surfaceCreated = createSurface(width, height); } else { // A saved SurfaceTexture was found. surfaceCreated = true; @@ -266,18 +266,20 @@ public class VideoCallFragment extends BaseFragment<VideoCallPresenter, mHeight = height; if (mSavedSurfaceTexture != null) { - createSurface(); + createSurface(width, height); } } /** * Creates the {@link Surface}, adjusting the {@link SurfaceTexture} buffer size. + * @param width The width of the surface to create. + * @param height The height of the surface to create. */ - private boolean createSurface() { - if (mWidth != DIMENSIONS_NOT_SET && mHeight != DIMENSIONS_NOT_SET && - mSavedSurfaceTexture != null) { + private boolean createSurface(int width, int height) { + if (width != DIMENSIONS_NOT_SET && height != DIMENSIONS_NOT_SET + && mSavedSurfaceTexture != null) { - mSavedSurfaceTexture.setDefaultBufferSize(mWidth, mHeight); + mSavedSurfaceTexture.setDefaultBufferSize(width, height); mSavedSurface = new Surface(mSavedSurfaceTexture); return true; } diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index ed0024126..38d7c9556 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -173,6 +173,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi InCallPresenter.getInstance().addListener(this); InCallPresenter.getInstance().addIncomingCallListener(this); InCallPresenter.getInstance().addOrientationListener(this); + // To get updates of video call details changes + InCallPresenter.getInstance().addDetailsListener(this); // Register for surface and video events from {@link InCallVideoCallListener}s. InCallVideoCallListenerNotifier.getInstance().addSurfaceChangeListener(this); @@ -256,6 +258,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi mVideoCall.setDisplaySurface(null); } else if (surface == VideoCallFragment.SURFACE_PREVIEW) { mVideoCall.setPreviewSurface(null); + // Also disable camera as preview is closed + mVideoCall.setCamera(null); } } @@ -441,6 +445,11 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi InCallPresenter.getInstance().setInCallAllowsOrientationChange(false); ui.showVideoUi(false); + if (mVideoCall != null) { + // Also disable camera otherwise it will be already in use for next upgrade + mVideoCall.setCamera(null); + } + if (mPreVideoAudioMode != AudioModeProvider.AUDIO_MODE_INVALID) { TelecomAdapter.getInstance().setAudioRoute(mPreVideoAudioMode); mPreVideoAudioMode = AudioModeProvider.AUDIO_MODE_INVALID; @@ -559,7 +568,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi @Override public void onDowngradeToAudio(Call call) { - // Implementing to satsify interface. + // exit video mode + exitVideoMode(); } /** |