Restart UI if it crashes

If the UI disconnects and we still have live calls, then restart the UI.

bug:1083649
Change-Id: I8d1677ce9b9f5e2a4150c5c9a114e837f7d2a462
diff --git a/src/com/android/phone/CallHandlerServiceProxy.java b/src/com/android/phone/CallHandlerServiceProxy.java
index 18b77ef..a3b393c 100644
--- a/src/com/android/phone/CallHandlerServiceProxy.java
+++ b/src/com/android/phone/CallHandlerServiceProxy.java
@@ -63,6 +63,7 @@
     private CallCommandService mCallCommandService;
     private CallModeler mCallModeler;
     private Context mContext;
+    private boolean mFullUpdateOnConnect;
 
     private ICallHandlerService mCallHandlerServiceGuarded;  // Guarded by mServiceAndQueueLock
     // Single queue to guarantee ordering
@@ -297,8 +298,7 @@
                 // always have an in call ui.
                 unbind();
 
-                // We were disconnected from the UI.  End all calls.
-                PhoneUtils.hangupAllCalls(PhoneGlobals.getInstance().getCallManager());
+                reconnectOnRemainingCalls();
             }
         }
     }
@@ -438,6 +438,21 @@
             makeInitialServiceCalls();
 
             processQueue();
+
+            if (mFullUpdateOnConnect) {
+                mFullUpdateOnConnect = false;
+                onUpdate(mCallModeler.getFullList());
+            }
+        }
+    }
+
+    /**
+     * Checks to see if there are any live calls left, and if so, try reconnecting the UI.
+     */
+    private void reconnectOnRemainingCalls() {
+        if (mCallModeler.hasLiveCall()) {
+            mFullUpdateOnConnect = true;
+            setupServiceConnection();
         }
     }