Include phone number in incoming call intent

This CL includes a phone number when sending an incoming
call intent. This is used by Hangouts to detect when two
incoming calls are duplicate.

This is a work around for an underlying bug where Telecomm
incorrectly shows UI for connections that are in the state
INITIALIZING.

Previouly connectinos were created asynchronously and this
allowed the connection service to do several things before
returning a initialized connection. When we moved to synchronous
creation we never updated Telecomm to handle this new state.

This underlying issue should be fixed properly for MR1.

Bug: 17485366

Change-Id: Ifa72064e0f45d799370fb72e286c509bc39f29dc
diff --git a/src/com/android/services/telephony/PstnIncomingCallNotifier.java b/src/com/android/services/telephony/PstnIncomingCallNotifier.java
index 73bc3a9..c7fe084 100644
--- a/src/com/android/services/telephony/PstnIncomingCallNotifier.java
+++ b/src/com/android/services/telephony/PstnIncomingCallNotifier.java
@@ -21,11 +21,16 @@
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.net.Uri;
 import android.os.AsyncResult;
+import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
 import android.os.UserHandle;
+import android.telecomm.PhoneAccount;
 import android.telecomm.TelecommManager;
+import android.telephony.TelephonyManager;
+import android.text.TextUtils;
 
 import com.android.internal.telephony.Call;
 import com.android.internal.telephony.Connection;
@@ -186,7 +191,14 @@
      * Sends the incoming call intent to telecomm.
      */
     private void sendIncomingCallIntent(Connection connection) {
+        Bundle extras = null;
+        if (connection.getNumberPresentation() == TelecommManager.PRESENTATION_ALLOWED &&
+                !TextUtils.isEmpty(connection.getAddress())) {
+            extras = new Bundle();
+            Uri uri = Uri.fromParts(PhoneAccount.SCHEME_TEL, connection.getAddress(), null);
+            extras.putParcelable(TelephonyManager.EXTRA_INCOMING_NUMBER, uri);
+        }
         TelecommManager.from(mPhoneProxy.getContext()).addNewIncomingCall(
-                TelecommAccountRegistry.makePstnPhoneAccountHandle(mPhoneProxy), null);
+                TelecommAccountRegistry.makePstnPhoneAccountHandle(mPhoneProxy), extras);
     }
 }