Merge "Self-Managed Incoming Call Disambiguation UX."
diff --git a/src/com/android/server/telecom/RespondViaSmsManager.java b/src/com/android/server/telecom/RespondViaSmsManager.java
index 6b2a39e..a42513d 100644
--- a/src/com/android/server/telecom/RespondViaSmsManager.java
+++ b/src/com/android/server/telecom/RespondViaSmsManager.java
@@ -38,6 +38,7 @@
 import android.telephony.TelephonyManager;
 import android.text.Spannable;
 import android.text.SpannableString;
+import android.text.TextUtils;
 import android.widget.Toast;
 
 import java.util.ArrayList;
@@ -137,7 +138,7 @@
             int subId = mCallsManager.getPhoneAccountRegistrar().getSubscriptionIdForPhoneAccount(
                     call.getTargetPhoneAccount());
             rejectCallWithMessage(call.getContext(), call.getHandle().getSchemeSpecificPart(),
-                    textMessage, subId);
+                    textMessage, subId, call.getName());
         }
     }
 
@@ -176,8 +177,8 @@
      * Reject the call with the specified message. If message is null this call is ignored.
      */
     private void rejectCallWithMessage(Context context, String phoneNumber, String textMessage,
-            int subId) {
-        if (textMessage != null) {
+            int subId, String contactName) {
+        if (!TextUtils.isEmpty(textMessage)) {
             final ComponentName component =
                     SmsApplication.getDefaultRespondViaMessageApplication(context,
                             true /*updateIfNeeded*/);
@@ -191,7 +192,7 @@
                 }
 
                 SomeArgs args = SomeArgs.obtain();
-                args.arg1 = phoneNumber;
+                args.arg1 = !TextUtils.isEmpty(contactName) ? contactName : phoneNumber;
                 args.arg2 = context;
                 mHandler.obtainMessage(MSG_SHOW_SENT_TOAST, args).sendToTarget();
                 intent.setComponent(component);