diff options
5 files changed, 45 insertions, 7 deletions
diff --git a/InCallUI/src/com/android/incallui/AnswerPresenter.java b/InCallUI/src/com/android/incallui/AnswerPresenter.java index fc75bf030..02dbfca83 100644 --- a/InCallUI/src/com/android/incallui/AnswerPresenter.java +++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java @@ -280,7 +280,7 @@ public class AnswerPresenter extends Presenter<AnswerPresenter.AnswerUi> // Only present the user with the option to answer as a video call if the incoming call is // a bi-directional video call. - if (VideoProfile.isBidirectional((call.getVideoState()))) { + if (CallUtils.isBidirectionalVideoCall(call)) { if (withSms) { getUi().showTargets(AnswerFragment.TARGET_SET_FOR_VIDEO_WITH_SMS); getUi().configureMessageDialog(textMsgs); diff --git a/InCallUI/src/com/android/incallui/CallCardFragment.java b/InCallUI/src/com/android/incallui/CallCardFragment.java index 75d13535b..1564d60ad 100644 --- a/InCallUI/src/com/android/incallui/CallCardFragment.java +++ b/InCallUI/src/com/android/incallui/CallCardFragment.java @@ -977,8 +977,7 @@ public class CallCardFragment extends BaseFragment<CallCardPresenter, CallCardPr callStateLabel = label; } else if (isAccount) { callStateLabel = context.getString(R.string.incoming_via_template, label); - } else if (VideoProfile.isTransmissionEnabled(videoState) || - VideoProfile.isReceptionEnabled(videoState)) { + } else if (CallUtils.isVideoCall(videoState)) { callStateLabel = context.getString(R.string.notification_incoming_video_call); } else { callStateLabel = context.getString(R.string.card_title_incoming_call); diff --git a/InCallUI/src/com/android/incallui/CallList.java b/InCallUI/src/com/android/incallui/CallList.java index bed1d607a..37ae14b1a 100644 --- a/InCallUI/src/com/android/incallui/CallList.java +++ b/InCallUI/src/com/android/incallui/CallList.java @@ -564,12 +564,14 @@ public class CallList { */ public void notifyCallsOfDeviceRotation(int rotation) { for (Call call : mCallById.values()) { - // First, ensure a VideoCall is set on the call so that the change can be sent to the + // First, ensure that the call videoState has video enabled (there is no need to set + // device orientation on a voice call which has not yet been upgraded to video). + // Second, ensure a VideoCall is set on the call so that the change can be sent to the // provider (a VideoCall can be present for a call that does not currently have video, // but can be upgraded to video). - // Second, ensure that the call videoState has video enabled (there is no need to set - // device orientation on a voice call which has not yet been upgraded to video). - if (call.getVideoCall() != null && CallUtils.isVideoCall(call)) { + // NOTE: is it necessary to use this order because getVideoCall references the class + // VideoProfile which is not available on APIs <23 (M). + if (CallUtils.isVideoCall(call) && call.getVideoCall() != null) { call.getVideoCall().setDeviceOrientation(rotation); } } diff --git a/InCallUI/src/com/android/incallui/CallUtils.java b/InCallUI/src/com/android/incallui/CallUtils.java index c69334ccf..6eb1a057f 100644 --- a/InCallUI/src/com/android/incallui/CallUtils.java +++ b/InCallUI/src/com/android/incallui/CallUtils.java @@ -30,6 +30,8 @@ package com.android.incallui; import android.telecom.VideoProfile; +import com.android.dialer.compat.DialerCompatUtils; + import com.google.common.base.Preconditions; public class CallUtils { @@ -39,10 +41,22 @@ public class CallUtils { } public static boolean isVideoCall(int videoState) { + if (!DialerCompatUtils.isVideoCompatible()) { + return false; + } + return VideoProfile.isTransmissionEnabled(videoState) || VideoProfile.isReceptionEnabled(videoState); } + public static boolean isBidirectionalVideoCall(Call call) { + if (!DialerCompatUtils.isVideoCompatible()) { + return false; + } + + return VideoProfile.isBidirectional(call.getVideoState()); + } + public static boolean isIncomingVideoCall(Call call) { if (!CallUtils.isVideoCall(call)) { return false; @@ -65,6 +79,10 @@ public class CallUtils { } public static boolean isAudioCall(Call call) { + if (!DialerCompatUtils.isVideoCompatible()) { + return true; + } + return call != null && VideoProfile.isAudioOnly(call.getVideoState()); } diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java index 12b718862..84d9c9781 100644 --- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java +++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java @@ -33,6 +33,7 @@ import android.view.Surface; import android.widget.ImageView; import com.android.contacts.common.ContactPhotoManager; +import com.android.dialer.compat.DialerCompatUtils; import com.android.incallui.InCallPresenter.InCallDetailsListener; import com.android.incallui.InCallPresenter.InCallOrientationListener; import com.android.incallui.InCallPresenter.InCallStateListener; @@ -225,6 +226,12 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi super.onUiReady(ui); Log.d(this, "onUiReady:"); + // Do not register any listeners if video calling is not compatible to safeguard against + // any accidental calls of video calling code. + if (!DialerCompatUtils.isVideoCompatible()) { + return; + } + // Register for call state changes last InCallPresenter.getInstance().addListener(this); InCallPresenter.getInstance().addDetailsListener(this); @@ -251,6 +258,10 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi super.onUiUnready(ui); Log.d(this, "onUiUnready:"); + if (!DialerCompatUtils.isVideoCompatible()) { + return; + } + InCallPresenter.getInstance().removeListener(this); InCallPresenter.getInstance().removeDetailsListener(this); InCallPresenter.getInstance().removeIncomingCallListener(this); @@ -798,6 +809,10 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi * @return {@code true} if the incoming video surface should be shown, {@code false} otherwise. */ public static boolean showIncomingVideo(int videoState, int callState) { + if (!DialerCompatUtils.isVideoCompatible()) { + return false; + } + boolean isPaused = VideoProfile.isPaused(videoState); boolean isCallActive = callState == Call.State.ACTIVE; @@ -813,6 +828,10 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi * otherwise. */ public static boolean showOutgoingVideo(int videoState) { + if (!DialerCompatUtils.isVideoCompatible()) { + return false; + } + return VideoProfile.isTransmissionEnabled(videoState); } |