summaryrefslogtreecommitdiff
path: root/InCallUI
diff options
context:
space:
mode:
authorBrandon Maxwell <maxwelb@google.com>2015-12-21 17:58:58 -0800
committerBrandon Maxwell <maxwelb@google.com>2015-12-22 11:08:21 -0800
commitacf06a5d427e4a7540576bed34c31312b59c6113 (patch)
tree692c1fc1eceb930413982486da8e39398a4b3d7e /InCallUI
parent4a759aac9e6a3047f254fc2c71076207f39b33b8 (diff)
Backporting usage of VideoProfile
Many of the VideoProfile methods in M came VideoProfile$VideoState previously. Due to the single line nature of most of the methods, the implementations are copied into the compat class to use in the event that the sdk is earlier than M. Bug=25776171 Change-Id: Ia597228a050e50f0efd4f79a458535ddb2925c83
Diffstat (limited to 'InCallUI')
-rw-r--r--InCallUI/src/com/android/incallui/VideoCallPresenter.java25
-rw-r--r--InCallUI/src/com/android/incallui/VideoUtils.java11
-rw-r--r--InCallUI/src/com/android/incallui/compat/telecom/VideoProfileCompat.java13
3 files changed, 32 insertions, 17 deletions
diff --git a/InCallUI/src/com/android/incallui/VideoCallPresenter.java b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
index 9f1f8f89c..ebdf82048 100644
--- a/InCallUI/src/com/android/incallui/VideoCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/VideoCallPresenter.java
@@ -39,6 +39,7 @@ import com.android.incallui.InCallPresenter.InCallStateListener;
import com.android.incallui.InCallPresenter.IncomingCallListener;
import com.android.incallui.InCallVideoCallCallbackNotifier.SurfaceChangeListener;
import com.android.incallui.InCallVideoCallCallbackNotifier.VideoEventListener;
+import com.android.incallui.compat.telecom.VideoProfileCompat;
import java.util.Objects;
@@ -487,8 +488,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
Log.d(this, "checkForVideoStateChange: isVideoCall= " + isVideoCall
+ " hasVideoStateChanged=" + hasVideoStateChanged + " isVideoMode="
+ isVideoMode() + " previousVideoState: " +
- VideoProfile.videoStateToString(mCurrentVideoState) + " newVideoState: "
- + VideoProfile.videoStateToString(call.getVideoState()));
+ VideoProfileCompat.videoStateToString(mCurrentVideoState) + " newVideoState: "
+ + VideoProfileCompat.videoStateToString(call.getVideoState()));
if (!hasVideoStateChanged) {
return;
@@ -658,12 +659,12 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
}
private static boolean isCameraRequired(int videoState) {
- return VideoProfile.isBidirectional(videoState) ||
- VideoProfile.isTransmissionEnabled(videoState);
+ return VideoProfileCompat.isBidirectional(videoState) ||
+ VideoProfileCompat.isTransmissionEnabled(videoState);
}
private boolean isCameraRequired() {
- return mPrimaryCall != null ? isCameraRequired(mPrimaryCall.getVideoState()) : false;
+ return mPrimaryCall != null && isCameraRequired(mPrimaryCall.getVideoState());
}
/**
@@ -760,7 +761,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
if (showIncomingVideo || showOutgoingVideo) {
ui.showVideoViews(showOutgoingVideo, showIncomingVideo);
- if (VideoProfile.isReceptionEnabled(videoState)) {
+ if (VideoProfileCompat.isReceptionEnabled(videoState)) {
loadProfilePhotoAsync();
}
} else {
@@ -768,7 +769,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
}
InCallPresenter.getInstance().enableScreenTimeout(
- VideoProfile.isAudioOnly(videoState));
+ VideoProfileCompat.isAudioOnly(videoState));
}
/**
@@ -785,10 +786,10 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
return false;
}
- boolean isPaused = VideoProfile.isPaused(videoState);
+ boolean isPaused = VideoProfileCompat.isPaused(videoState);
boolean isCallActive = callState == Call.State.ACTIVE;
- return !isPaused && isCallActive && VideoProfile.isReceptionEnabled(videoState);
+ return !isPaused && isCallActive && VideoProfileCompat.isReceptionEnabled(videoState);
}
/**
@@ -804,7 +805,7 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
return false;
}
- return VideoProfile.isTransmissionEnabled(videoState);
+ return VideoProfileCompat.isTransmissionEnabled(videoState);
}
/**
@@ -1231,8 +1232,8 @@ public class VideoCallPresenter extends Presenter<VideoCallPresenter.VideoCallUi
}
private static int toCameraDirection(int videoState) {
- return VideoProfile.isTransmissionEnabled(videoState) &&
- !VideoProfile.isBidirectional(videoState)
+ return VideoProfileCompat.isTransmissionEnabled(videoState) &&
+ !VideoProfileCompat.isBidirectional(videoState)
? Call.VideoSettings.CAMERA_DIRECTION_BACK_FACING
: Call.VideoSettings.CAMERA_DIRECTION_FRONT_FACING;
}
diff --git a/InCallUI/src/com/android/incallui/VideoUtils.java b/InCallUI/src/com/android/incallui/VideoUtils.java
index 8641d60ec..7e0926b46 100644
--- a/InCallUI/src/com/android/incallui/VideoUtils.java
+++ b/InCallUI/src/com/android/incallui/VideoUtils.java
@@ -19,6 +19,7 @@ package com.android.incallui;
import android.telecom.VideoProfile;
import com.android.contacts.common.compat.CompatUtils;
+import com.android.incallui.compat.telecom.VideoProfileCompat;
import com.google.common.base.Preconditions;
@@ -33,8 +34,8 @@ public class VideoUtils {
return false;
}
- return VideoProfile.isTransmissionEnabled(videoState)
- || VideoProfile.isReceptionEnabled(videoState);
+ return VideoProfileCompat.isTransmissionEnabled(videoState)
+ || VideoProfileCompat.isReceptionEnabled(videoState);
}
public static boolean isBidirectionalVideoCall(Call call) {
@@ -42,7 +43,7 @@ public class VideoUtils {
return false;
}
- return VideoProfile.isBidirectional(call.getVideoState());
+ return VideoProfileCompat.isBidirectional(call.getVideoState());
}
public static boolean isIncomingVideoCall(Call call) {
@@ -71,7 +72,7 @@ public class VideoUtils {
return true;
}
- return call != null && VideoProfile.isAudioOnly(call.getVideoState());
+ return call != null && VideoProfileCompat.isAudioOnly(call.getVideoState());
}
// TODO (ims-vt) Check if special handling is needed for CONF calls.
@@ -81,7 +82,7 @@ public class VideoUtils {
public static VideoProfile makeVideoPauseProfile(Call call) {
Preconditions.checkNotNull(call);
- Preconditions.checkState(!VideoProfile.isAudioOnly(call.getVideoState()));
+ Preconditions.checkState(!VideoProfileCompat.isAudioOnly(call.getVideoState()));
return new VideoProfile(getPausedVideoState(call.getVideoState()));
}
diff --git a/InCallUI/src/com/android/incallui/compat/telecom/VideoProfileCompat.java b/InCallUI/src/com/android/incallui/compat/telecom/VideoProfileCompat.java
index 54d8eed65..6e81bd79a 100644
--- a/InCallUI/src/com/android/incallui/compat/telecom/VideoProfileCompat.java
+++ b/InCallUI/src/com/android/incallui/compat/telecom/VideoProfileCompat.java
@@ -124,4 +124,17 @@ public class VideoProfileCompat {
private static boolean hasState(int videoState, int state) {
return (videoState & state) == state;
}
+
+ /**
+ * Indicates whether the video state is bi-directional.
+ *
+ * @param videoState The video state.
+ * @return {@code True} if the video is bi-directional, {@code false} otherwise.
+ */
+ public static boolean isBidirectional(int videoState) {
+ if (CompatUtils.isMarshmallowCompatible()) {
+ return VideoProfile.isBidirectional(videoState);
+ }
+ return hasState(videoState, VideoProfile.STATE_BIDIRECTIONAL);
+ }
}