To sync caller id ussd response vaule to caller id ss vaule.

The feature syncs the value to ss after user set caller id by ussd.

Bug: 112177857
Test: manual - test case as below :
Insert docomo sim and enable carrier config
(caller_id_ussd_enhance_bool), and then dial the caller id ussd
command to set activate/deactivate.
To check caller id's value in UI page is the same as value by
ussd. (PASS)
To check ussd response message is correct string.(PASS)

Change-Id: I9bc2b07ae59c8fc445352c779c2a1d9765bcd813
diff --git a/src/com/android/phone/PhoneUtils.java b/src/com/android/phone/PhoneUtils.java
index 3306d4b..9b118ff 100644
--- a/src/com/android/phone/PhoneUtils.java
+++ b/src/com/android/phone/PhoneUtils.java
@@ -19,16 +19,17 @@
 import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.ProgressDialog;
-import android.content.ActivityNotFoundException;
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.DialogInterface;
 import android.net.Uri;
 import android.os.Handler;
 import android.os.Message;
+import android.os.PersistableBundle;
 import android.telecom.PhoneAccount;
 import android.telecom.PhoneAccountHandle;
 import android.telecom.VideoProfile;
+import android.telephony.CarrierConfigManager;
 import android.telephony.PhoneNumberUtils;
 import android.telephony.SubscriptionManager;
 import android.text.TextUtils;
@@ -54,6 +55,7 @@
 import com.android.internal.telephony.PhoneFactory;
 import com.android.internal.telephony.TelephonyCapabilities;
 import com.android.phone.CallGatewayManager.RawGatewayInfo;
+import com.android.phone.settings.SuppServicesUiUtil;
 
 import java.util.Arrays;
 import java.util.List;
@@ -384,6 +386,22 @@
                 text = null;
                 break;
             case COMPLETE:
+                PersistableBundle b = null;
+                if (SubscriptionManager.isValidSubscriptionId(phone.getSubId())) {
+                    b = app.getCarrierConfigForSubId(
+                            phone.getSubId());
+                } else {
+                    b = app.getCarrierConfig();
+                }
+
+                if (b.getBoolean(CarrierConfigManager.KEY_USE_CALLER_ID_USSD_BOOL)) {
+                    text = SuppServicesUiUtil.handleCallerIdUssdResponse(app, context, phone,
+                            mmiCode);
+                    if (mmiCode.getMessage() != null && !text.equals(mmiCode.getMessage())) {
+                        break;
+                    }
+                }
+
                 if (app.getPUKEntryActivity() != null) {
                     // if an attempt to unPUK the device was made, we specify
                     // the title and the message here.
@@ -560,7 +578,15 @@
         }
     }
 
-    private static void createUssdDialog(PhoneGlobals app, Context context, CharSequence text,
+    /**
+     * It displays the message dialog for user about the mmi code result message.
+     *
+     * @param app This is {@link PhoneGlobals}
+     * @param context Context to get strings.
+     * @param text This is message's result.
+     * @param windowType The new window type. {@link WindowManager.LayoutParams}.
+     */
+    public static void createUssdDialog(PhoneGlobals app, Context context, CharSequence text,
             int windowType) {
         log("displayMMIComplete: MMI code has finished running.");