From 9b9fcc08d21054fc322f0936aebc90c31b51389c Mon Sep 17 00:00:00 2001 From: roldenburg Date: Fri, 23 Jun 2017 10:50:03 -0700 Subject: Ensure IMS video calling is enabled before offering video upgrade By not checking CallUtil.isVideoEnabled, we were offering upgrading even after the user had disabled it. I also tried to make the isAvailable method a bit more readable. PiperOrigin-RevId: 159966735 Change-Id: Ibf828a561654e0e9521a6d86ad18269da426bba4 --- .../incallui/videotech/ims/ImsVideoTech.java | 30 ++++++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'java') diff --git a/java/com/android/incallui/videotech/ims/ImsVideoTech.java b/java/com/android/incallui/videotech/ims/ImsVideoTech.java index 3d73e4e7d..4e7443960 100644 --- a/java/com/android/incallui/videotech/ims/ImsVideoTech.java +++ b/java/com/android/incallui/videotech/ims/ImsVideoTech.java @@ -27,6 +27,7 @@ import com.android.dialer.common.Assert; import com.android.dialer.common.LogUtil; import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.LoggingBindings; +import com.android.dialer.util.CallUtil; import com.android.incallui.video.protocol.VideoCallScreen; import com.android.incallui.video.protocol.VideoCallScreenDelegate; import com.android.incallui.videotech.VideoTech; @@ -56,12 +57,31 @@ public class ImsVideoTech implements VideoTech { return false; } - boolean hasCapabilities = - call.getDetails().can(Call.Details.CAPABILITY_SUPPORTS_VT_LOCAL_TX) - && call.getDetails().can(Call.Details.CAPABILITY_SUPPORTS_VT_REMOTE_RX); + if (call.getVideoCall() == null) { + return false; + } + + // We are already in an IMS video call + if (VideoProfile.isVideo(call.getDetails().getVideoState())) { + return true; + } + + // The user has disabled IMS video calling in system settings + if (!CallUtil.isVideoEnabled(context)) { + return false; + } + + // The current call doesn't support transmitting video + if (!call.getDetails().can(Call.Details.CAPABILITY_SUPPORTS_VT_LOCAL_TX)) { + return false; + } + + // The current call remote device doesn't support receiving video + if (!call.getDetails().can(Call.Details.CAPABILITY_SUPPORTS_VT_REMOTE_RX)) { + return false; + } - return call.getVideoCall() != null - && (hasCapabilities || VideoProfile.isVideo(call.getDetails().getVideoState())); + return true; } @Override -- cgit v1.2.3