Partial revert of cl/170369554 to fix video call ringing screen

Tracking bug to fix the refactoring: http://b/67512378

Bug: 67470678
Test: manual
PiperOrigin-RevId: 171553078
Change-Id: Ib83e4240d6024347f97d246f9b526c3ccbf02057
diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java
index d393b42..2511bb8 100644
--- a/java/com/android/incallui/call/DialerCall.java
+++ b/java/com/android/incallui/call/DialerCall.java
@@ -153,7 +153,7 @@
   // Times when a second call is received but AnswerAndRelease button is not shown
   // since it's not supported.
   private int secondCallWithoutAnswerAndReleasedButtonTimes = 0;
-  private VideoTech videoTech = new EmptyVideoTech();
+  private VideoTech videoTech;
 
   private com.android.dialer.logging.VideoTech.Type selectedAvailableVideoTechType =
       com.android.dialer.logging.VideoTech.Type.NONE;
@@ -452,15 +452,10 @@
   private void update() {
     Trace.beginSection("DialerCall.update");
     int oldState = getState();
+    // Clear any cache here that could potentially change on update.
+    videoTech = null;
     // We want to potentially register a video call callback here.
     updateFromTelecomCall();
-    // Only store the first video tech type found to be available during the life of the call.
-    if (selectedAvailableVideoTechType == com.android.dialer.logging.VideoTech.Type.NONE) {
-      // Update the video tech.
-      videoTech = mVideoTechManager.findBestAvailableVideoTech();
-      videoTech.becomePrimary();
-      selectedAvailableVideoTechType = videoTech.getVideoTechType();
-    }
     if (oldState != getState() && getState() == DialerCall.State.DISCONNECTED) {
       for (DialerCallListener listener : mListeners) {
         listener.onDialerCallDisconnect();
@@ -1166,6 +1161,15 @@
   }
 
   public VideoTech getVideoTech() {
+    if (videoTech == null) {
+      videoTech = mVideoTechManager.getVideoTech();
+
+      // Only store the first video tech type found to be available during the life of the call.
+      if (selectedAvailableVideoTechType == com.android.dialer.logging.VideoTech.Type.NONE) {
+        // Update the video tech.
+        selectedAvailableVideoTechType = videoTech.getVideoTechType();
+      }
+    }
     return videoTech;
   }
 
@@ -1538,6 +1542,7 @@
     private final Context context;
     private final EmptyVideoTech emptyVideoTech = new EmptyVideoTech();
     private final List<VideoTech> videoTechs;
+    private VideoTech savedTech;
 
     VideoTechManager(DialerCall call) {
       this.context = call.mContext;
@@ -1570,10 +1575,17 @@
               phoneNumber));
     }
 
-    VideoTech findBestAvailableVideoTech() {
+    VideoTech getVideoTech() {
+      if (savedTech != null) {
+        return savedTech;
+      }
+
       for (VideoTech tech : videoTechs) {
         if (tech.isAvailable(context)) {
-          return tech;
+          // Remember the first VideoTech that becomes available and always use it
+          savedTech = tech;
+          savedTech.becomePrimary();
+          return savedTech;
         }
       }