Set the preferred SIM when InCallActivity is not visible.

Bug: 109653872
Test: N/A (InCallActivity is not testable, similar to cl/194824783).
PiperOrigin-RevId: 199662982
Change-Id: I4effa2454246d852837d0878246898537f799980
diff --git a/java/com/android/incallui/InCallActivity.java b/java/com/android/incallui/InCallActivity.java
index a550dde..46affdf 100644
--- a/java/com/android/incallui/InCallActivity.java
+++ b/java/com/android/incallui/InCallActivity.java
@@ -380,12 +380,6 @@
         this,
         preferredAccountFuture,
         result -> {
-          if (!isVisible()) {
-            LogUtil.i(
-                "CallingAccountSelector.showPhoneAccountSelectionDialog",
-                "activity ended before result returned");
-            return;
-          }
           String callId = waitingForAccountCall.getId();
           if (result.getSelectedPhoneAccountHandle().isPresent()) {
             selectPhoneAccountListener.onPhoneAccountSelected(
@@ -393,6 +387,13 @@
             return;
           }
 
+          if (!isVisible()) {
+            LogUtil.i(
+                "InCallActivity.showPhoneAccountSelectionDialog",
+                "activity ended before result returned");
+            return;
+          }
+
           waitingForAccountCall.setPreferredAccountRecorder(
               new PreferredAccountRecorder(
                   waitingForAccountCall.getNumber(),