ImsManager: add wfc roaming mode getter/setter
Meng Wang [Tue, 20 Sep 2016 16:59:56 +0000 (09:59 -0700)]
Bug: 31492826
Change-Id: Ia13c59bb1aba892759da2184bf570011ebe0876f

src/java/com/android/ims/ImsManager.java

index 22e0f44..5630af1 100644 (file)
@@ -456,7 +456,7 @@ public class ImsManager {
     }
 
     /**
-     * Returns the user configuration of WFC modem setting
+     * Returns the user configuration of WFC preference setting
      */
     public static int getWfcMode(Context context) {
         int setting = android.provider.Settings.Global.getInt(context.getContentResolver(),
@@ -467,7 +467,7 @@ public class ImsManager {
     }
 
     /**
-     * Returns the user configuration of WFC modem setting
+     * Change persistent WFC preference setting
      */
     public static void setWfcMode(Context context, int wfcMode) {
         if (DBG) log("setWfcMode - setting=" + wfcMode);
@@ -477,6 +477,51 @@ public class ImsManager {
         setWfcModeInternal(context, wfcMode);
     }
 
+    /**
+     * Returns the user configuration of WFC preference setting
+     *
+     * @param roaming {@code false} for home network setting, {@code true} for roaming  setting
+     */
+    public static int getWfcMode(Context context, boolean roaming) {
+        int setting = 0;
+        if (!roaming) {
+            setting = android.provider.Settings.Global.getInt(context.getContentResolver(),
+                    android.provider.Settings.Global.WFC_IMS_MODE, getIntCarrierConfig(context,
+                            CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_MODE_INT));
+            if (DBG) log("getWfcMode - setting=" + setting);
+        } else {
+            setting = android.provider.Settings.Global.getInt(context.getContentResolver(),
+                    android.provider.Settings.Global.WFC_IMS_ROAMING_MODE,
+                    getIntCarrierConfig(context,
+                            CarrierConfigManager.KEY_CARRIER_DEFAULT_WFC_IMS_ROAMING_MODE_INT));
+            if (DBG) log("getWfcMode (roaming) - setting=" + setting);
+        }
+        return setting;
+    }
+
+    /**
+     * Change persistent WFC preference setting
+     *
+     * @param roaming {@code false} for home network setting, {@code true} for roaming setting
+     */
+    public static void setWfcMode(Context context, int wfcMode, boolean roaming) {
+        if (!roaming) {
+            if (DBG) log("setWfcMode - setting=" + wfcMode);
+            android.provider.Settings.Global.putInt(context.getContentResolver(),
+                    android.provider.Settings.Global.WFC_IMS_MODE, wfcMode);
+        } else {
+            if (DBG) log("setWfcMode (roaming) - setting=" + wfcMode);
+            android.provider.Settings.Global.putInt(context.getContentResolver(),
+                    android.provider.Settings.Global.WFC_IMS_ROAMING_MODE, wfcMode);
+        }
+
+        TelephonyManager tm = (TelephonyManager)
+                context.getSystemService(Context.TELEPHONY_SERVICE);
+        if (roaming == tm.isNetworkRoaming()) {
+            setWfcModeInternal(context, wfcMode);
+        }
+    }
+
     private static void setWfcModeInternal(Context context, int wfcMode) {
         final ImsManager imsManager = ImsManager.getInstance(context,
                 SubscriptionManager.getDefaultVoicePhoneId());