Skip showing Call Forwarding fail-to-disable dialog

AT&T México's network returns active status even if disable
callforward succeeded, then the un-wanted error dialog will
be shown. So, skip showing the error dialog.

Test: manual - checked the call forwarding fail dialog was not shown
Bug: 35790386
Change-Id: Ib8021d308781d8c941c10d231d5bad8896bdb370
diff --git a/src/com/android/phone/CallForwardEditPreference.java b/src/com/android/phone/CallForwardEditPreference.java
index ef92349..9e153b2 100644
--- a/src/com/android/phone/CallForwardEditPreference.java
+++ b/src/com/android/phone/CallForwardEditPreference.java
@@ -12,6 +12,8 @@
 import android.os.AsyncResult;
 import android.os.Handler;
 import android.os.Message;
+import android.os.PersistableBundle;
+import android.telephony.CarrierConfigManager;
 import android.telephony.PhoneNumberUtils;
 import android.text.BidiFormatter;
 import android.text.SpannableString;
@@ -239,6 +241,13 @@
                             if (msg.arg2 == MESSAGE_SET_CF &&
                                     msg.arg1 == CommandsInterface.CF_ACTION_DISABLE &&
                                     info.status == 1) {
+                                // Skip showing error dialog since some operators return
+                                // active status even if disable call forward succeeded.
+                                // And they don't like the error dialog.
+                                if (isSkipCFFailToDisableDialog()) {
+                                    Log.d(LOG_TAG, "Skipped Callforwarding fail-to-disable dialog");
+                                    continue;
+                                }
                                 CharSequence s;
                                 switch (reason) {
                                     case CommandsInterface.CF_REASON_BUSY:
@@ -280,4 +289,22 @@
                     obtainMessage(MESSAGE_GET_CF, msg.arg1, MESSAGE_SET_CF, ar.exception));
         }
     }
+
+    /*
+     * Get the config of whether skip showing CF fail-to-disable dialog
+     * from carrier config manager.
+     *
+     * @return boolean value of the config
+     */
+    private boolean isSkipCFFailToDisableDialog() {
+        PersistableBundle carrierConfig =
+                PhoneGlobals.getInstance().getCarrierConfigForSubId(mPhone.getSubId());
+        if (carrierConfig != null) {
+            return carrierConfig.getBoolean(
+                    CarrierConfigManager.KEY_SKIP_CF_FAIL_TO_DISABLE_DIALOG_BOOL);
+        } else {
+            // by default we should not skip
+            return false;
+        }
+    }
 }