Expose ImsManager#setWfcNonPersistentForSlot

This API allows non-persistently update WFC on/off state and WFC mode
at the same time to avoid racing condition.

Bug: 32159037
Test: make
Change-Id: I6064eb42941a1f2cb3941f3be52dcdc0e91b78d0
diff --git a/src/java/com/android/ims/ImsManager.java b/src/java/com/android/ims/ImsManager.java
index 96e3cb8..03ecb89 100644
--- a/src/java/com/android/ims/ImsManager.java
+++ b/src/java/com/android/ims/ImsManager.java
@@ -728,12 +728,26 @@
         android.provider.Settings.Global.putInt(mContext.getContentResolver(),
                 android.provider.Settings.Global.WFC_IMS_ENABLED, value);
 
+        setWfcNonPersistentForSlot(enabled, getWfcModeForSlot());
+    }
+
+    /**
+     * Non-persistently change WFC enabled setting and WFC mode for slot
+     *
+     * @param wfcMode The WFC preference if WFC is enabled
+     */
+    public void setWfcNonPersistentForSlot(boolean enabled, int wfcMode) {
+        int imsFeatureValue =
+                enabled ? ImsConfig.FeatureValueConstants.ON : ImsConfig.FeatureValueConstants.OFF;
+        // Force IMS to register over LTE when turning off WFC
+        int imsWfcModeFeatureValue =
+                enabled ? wfcMode : ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED;
+
         try {
             ImsConfig config = getConfigInterface();
             config.setFeatureValue(ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_WIFI,
                     TelephonyManager.NETWORK_TYPE_IWLAN,
-                    enabled ? ImsConfig.FeatureValueConstants.ON
-                            : ImsConfig.FeatureValueConstants.OFF,
+                    imsFeatureValue,
                     mImsConfigListener);
 
             if (enabled) {
@@ -746,10 +760,7 @@
                 turnOffIms();
             }
 
-            // Force IMS to register over LTE when turning off WFC
-            setWfcModeInternalForSlot(enabled
-                    ? getWfcModeForSlot()
-                    : ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED);
+            setWfcModeInternalForSlot(imsWfcModeFeatureValue);
         } catch (ImsException e) {
             loge("setWfcSettingForSlot(): ", e);
         }