Merge "Dont clear serviceConnections on subsequent bind() calls." into lmp-dev
diff --git a/src/com/android/server/telecom/CallActivity.java b/src/com/android/server/telecom/CallActivity.java
index b249788..69da7e4 100644
--- a/src/com/android/server/telecom/CallActivity.java
+++ b/src/com/android/server/telecom/CallActivity.java
@@ -112,11 +112,20 @@
         }
 
         intent.putExtra(CallReceiver.KEY_IS_DEFAULT_DIALER, isDefaultDialer());
-        sendBroadcastToReceiver(intent, false /* isIncoming */);
+
+        if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
+            CallReceiver.processOutgoingCallIntent(getApplicationContext(), intent);
+        } else {
+            sendBroadcastToReceiver(intent, false /* isIncoming */);
+        }
     }
 
     private void processIncomingCallIntent(Intent intent) {
-        sendBroadcastToReceiver(intent, true /* isIncoming */);
+        if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
+            CallReceiver.processIncomingCallIntent(intent);
+        } else {
+            sendBroadcastToReceiver(intent, true /* isIncoming */);
+        }
     }
 
     private boolean isDefaultDialer() {
diff --git a/src/com/android/server/telecom/CallReceiver.java b/src/com/android/server/telecom/CallReceiver.java
index fe82b67..c8fdeb4 100644
--- a/src/com/android/server/telecom/CallReceiver.java
+++ b/src/com/android/server/telecom/CallReceiver.java
@@ -19,6 +19,7 @@
  * the primary user.
  */
 public class CallReceiver extends BroadcastReceiver {
+    private static final String TAG = CallReceiver.class.getName();
 
     static final String KEY_IS_INCOMING_CALL = "is_incoming_call";
     static final String KEY_IS_DEFAULT_DIALER =
@@ -27,7 +28,7 @@
     @Override
     public void onReceive(Context context, Intent intent) {
         final boolean isIncomingCall = intent.getBooleanExtra(KEY_IS_INCOMING_CALL, false);
-        Log.d(this, "onReceive - isIncomingCall: %s", isIncomingCall);
+        Log.i(TAG, "onReceive - isIncomingCall: %s", isIncomingCall);
 
         if (isIncomingCall) {
             processIncomingCallIntent(intent);
@@ -41,7 +42,7 @@
      *
      * @param intent Call intent containing data about the handle to call.
      */
-    private void processOutgoingCallIntent(Context context, Intent intent) {
+    static void processOutgoingCallIntent(Context context, Intent intent) {
         Uri handle = intent.getData();
         String scheme = handle.getScheme();
         String uriString = handle.getSchemeSpecificPart();
@@ -84,16 +85,16 @@
         }
     }
 
-    private void processIncomingCallIntent(Intent intent) {
+    static void processIncomingCallIntent(Intent intent) {
         PhoneAccountHandle phoneAccountHandle = intent.getParcelableExtra(
                 TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE);
 
         if (phoneAccountHandle == null) {
-            Log.w(this, "Rejecting incoming call due to null phone account");
+            Log.w(TAG, "Rejecting incoming call due to null phone account");
             return;
         }
         if (phoneAccountHandle.getComponentName() == null) {
-            Log.w(this, "Rejecting incoming call due to null component name");
+            Log.w(TAG, "Rejecting incoming call due to null component name");
             return;
         }
 
@@ -105,16 +106,17 @@
             clientExtras = Bundle.EMPTY;
         }
 
-        Log.d(this, "Processing incoming call from connection service [%s]",
+        Log.d(TAG, "Processing incoming call from connection service [%s]",
                 phoneAccountHandle.getComponentName());
         getCallsManager().processIncomingCallIntent(phoneAccountHandle, clientExtras);
     }
 
-    CallsManager getCallsManager() {
+    static CallsManager getCallsManager() {
         return CallsManager.getInstance();
     }
 
-    private void disconnectCallAndShowErrorDialog(Context context, Call call, int errorCode) {
+    private static void disconnectCallAndShowErrorDialog(
+            Context context, Call call, int errorCode) {
         call.disconnect();
         final Intent errorIntent = new Intent(context, ErrorDialogActivity.class);
         int errorMessageId = -1;