Adding support for dialer to bring incallUI to foreground.

Previously, the Dialer relied on
TelephonyManager.showCallScreenWithDialpad to bring the UI to the
foreground after the user selected "return to call in progress." This
was not updated for the split in-call-ui.

The fix adds a new API to CallHandlerService to bring the incallui to
the foreground.  This new API now gets called as part of
showCallScreenWithDialpad().

bug:10313347
Change-Id: Id95a1e266471970cf1295423ea720b0e1926325b
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index c65c4f8..c37fe07 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -72,6 +72,7 @@
     CallManager mCM;
     AppOpsManager mAppOps;
     MainThreadHandler mMainThreadHandler;
+    CallHandlerServiceProxy mCallHandlerService;
 
     /**
      * A request object for use with {@link MainThreadHandler}. Requesters should wait() on the
@@ -218,10 +219,11 @@
      * Initialize the singleton PhoneInterfaceManager instance.
      * This is only done once, at startup, from PhoneApp.onCreate().
      */
-    /* package */ static PhoneInterfaceManager init(PhoneGlobals app, Phone phone) {
+    /* package */ static PhoneInterfaceManager init(PhoneGlobals app, Phone phone,
+            CallHandlerServiceProxy callHandlerService) {
         synchronized (PhoneInterfaceManager.class) {
             if (sInstance == null) {
-                sInstance = new PhoneInterfaceManager(app, phone);
+                sInstance = new PhoneInterfaceManager(app, phone, callHandlerService);
             } else {
                 Log.wtf(LOG_TAG, "init() called multiple times!  sInstance = " + sInstance);
             }
@@ -230,12 +232,14 @@
     }
 
     /** Private constructor; @see init() */
-    private PhoneInterfaceManager(PhoneGlobals app, Phone phone) {
+    private PhoneInterfaceManager(PhoneGlobals app, Phone phone,
+            CallHandlerServiceProxy callHandlerService) {
         mApp = app;
         mPhone = phone;
         mCM = PhoneGlobals.getInstance().mCM;
         mAppOps = (AppOpsManager)app.getSystemService(Context.APP_OPS_SERVICE);
         mMainThreadHandler = new MainThreadHandler();
+        mCallHandlerService = callHandlerService;
         publish();
     }
 
@@ -303,26 +307,10 @@
         }
         // If the phone isn't idle then go to the in-call screen
         long callingId = Binder.clearCallingIdentity();
-        try {
-            Intent intent;
-            if (specifyInitialDialpadState) {
-                intent = PhoneGlobals.createInCallIntent(initialDialpadState);
-            } else {
-                intent = PhoneGlobals.createInCallIntent();
-            }
-            try {
-                //mApp.startActivity(intent);
-            } catch (ActivityNotFoundException e) {
-                // It's possible that the in-call UI might not exist
-                // (like on non-voice-capable devices), although we
-                // shouldn't be trying to bring up the InCallScreen on
-                // devices like that in the first place!
-                Log.w(LOG_TAG, "showCallScreenInternal: "
-                      + "transition to InCallScreen failed; intent = " + intent);
-            }
-        } finally {
-            Binder.restoreCallingIdentity(callingId);
-        }
+
+        mCallHandlerService.bringToForeground();
+
+        Binder.restoreCallingIdentity(callingId);
         return true;
     }