Handle preferred SIM for ACTION_CALL

Previously preferred SIM is handled only by precall, which covers dialing with dialer or with the special receiver contacts uses. If a third party app uses ACTION_CALL or telecomManager.placeCall(), then the in call UI will be launched directly and the old account selection dialog will be used without preferred SIM support.

In this CL logic from CallingAccountSelector is refactored out so InCallActivity can use it for the dialog.

Bug: 73718976
Test: Unit tests, In call UI not covered.
PiperOrigin-RevId: 188214007
Change-Id: Ifaacf982a3e98601dc362b649c3501d4ee96e63e
diff --git a/java/com/android/incallui/call/DialerCall.java b/java/com/android/incallui/call/DialerCall.java
index 30d2bcb..5d2b147 100644
--- a/java/com/android/incallui/call/DialerCall.java
+++ b/java/com/android/incallui/call/DialerCall.java
@@ -71,6 +71,7 @@
 import com.android.dialer.logging.ContactLookupResult.Type;
 import com.android.dialer.logging.DialerImpression;
 import com.android.dialer.logging.Logger;
+import com.android.dialer.preferredsim.PreferredAccountRecorder;
 import com.android.dialer.telecom.TelecomCallUtil;
 import com.android.dialer.telecom.TelecomUtil;
 import com.android.dialer.theme.R;
@@ -181,6 +182,8 @@
 
   private volatile boolean feedbackRequested = false;
 
+  @Nullable private PreferredAccountRecorder preferredAccountRecorder;
+
   public static String getNumberFromHandle(Uri handle) {
     return handle == null ? "" : handle.getSchemeSpecificPart();
   }
@@ -1529,6 +1532,19 @@
   }
 
   /**
+   * If the in call UI has shown the phone account selection dialog for the call, the {@link
+   * PreferredAccountRecorder} to record the result from the dialog.
+   */
+  @Nullable
+  public PreferredAccountRecorder getPreferredAccountRecorder() {
+    return preferredAccountRecorder;
+  }
+
+  public void setPreferredAccountRecorder(PreferredAccountRecorder preferredAccountRecorder) {
+    this.preferredAccountRecorder = preferredAccountRecorder;
+  }
+
+  /**
    * Specifies whether a number is in the call history or not. {@link #CALL_HISTORY_STATUS_UNKNOWN}
    * means there is no result.
    */