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
diff --git a/java/com/android/incallui/videotech/ims/ImsVideoTech.java b/java/com/android/incallui/videotech/ims/ImsVideoTech.java
index 3d73e4e..4e74439 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.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 @@
       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;
+    }
 
-    return call.getVideoCall() != null
-        && (hasCapabilities || VideoProfile.isVideo(call.getDetails().getVideoState()));
+    // 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 true;
   }
 
   @Override