summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNancy Chen <nancychen@google.com>2015-11-20 20:16:10 +0000
committerandroid-build-merger <android-build-merger@google.com>2015-11-20 20:16:10 +0000
commitbedb473d77d4fe7bc7c33bdbbfba2706141e6a9b (patch)
treecb9495bbe17c24b7c770f248e985c39c0a496f4f
parent5bcaa5f14a852dbce54a1989f0b325f48ddfdf56 (diff)
parent6a88bd1254cce257fa47b6a23bee0554b5c5b21d (diff)
Merge "Guard against framework calls to Video call APIs for backporting." into ub-contactsdialer-b-dev
am: 9a45c0cdf2 * commit '9a45c0cdf2ad426a6849351b77738f05301219c6': Guard against framework calls to Video call APIs for backporting.
-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 97f60c05f..2049e6cff 100644
--- a/InCallUI/src/com/android/incallui/AnswerPresenter.java
+++ b/InCallUI/src/com/android/incallui/AnswerPresenter.java
@@ -285,7 +285,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 d70b789ba..ad436816f 100644
--- a/InCallUI/src/com/android/incallui/CallList.java
+++ b/InCallUI/src/com/android/incallui/CallList.java
@@ -579,12 +579,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);
}