summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNancy Chen <nancychen@google.com>2015-11-19 17:31:02 -0800
committerNancy Chen <nancychen@google.com>2015-11-19 17:41:55 -0800
commit35403e80a4976362b517ed552c965924699456df (patch)
tree3f2bf02c6e18257917a00770fe7da28a7bfbc7ff
parent471f63aa71568456b368b80d38a5e43f7051d28d (diff)
Guard against framework calls to Video call APIs for backporting.
Check compatibility verson before making method calls to VideoProfile or VideoCall. Use CallUtils for any method call that is using VideoProfile to determine if video calling is available or not. Bug: 25776171 Change-Id: I24fa049c0003547f9027bed8fabfb81d0fde6374
-rw-r--r--InCallUI/src/com/android/incallui/AnswerPresenter.java2
-rw-r--r--InCallUI/src/com/android/incallui/CallCardFragment.java3
-rw-r--r--InCallUI/src/com/android/incallui/CallList.java10
-rw-r--r--InCallUI/src/com/android/incallui/CallUtils.java18
-rw-r--r--InCallUI/src/com/android/incallui/VideoCallPresenter.java19
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);
}