Snap for 4577102 from 2a2cbc13ccca4f36f0713e5535c48c05cdf7e7bc to pi-release

Change-Id: Id19d7dcabd106eb4cb0e74803f2f5a30d846098d
diff --git a/src/com/android/server/telecom/CallIntentProcessor.java b/src/com/android/server/telecom/CallIntentProcessor.java
index fdd4ebc..d90cba4 100644
--- a/src/com/android/server/telecom/CallIntentProcessor.java
+++ b/src/com/android/server/telecom/CallIntentProcessor.java
@@ -127,10 +127,17 @@
                 VideoProfile.STATE_AUDIO_ONLY);
         clientExtras.putInt(TelecomManager.EXTRA_START_CALL_WITH_VIDEO_STATE, videoState);
 
-        boolean fixedInitiatingUser = fixInitiatingUserIfNecessary(context, intent);
-        // Show the toast to warn user that it is a personal call though initiated in work profile.
-        if (fixedInitiatingUser) {
-            Toast.makeText(context, R.string.toast_personal_call_msg, Toast.LENGTH_LONG).show();
+        if (!callsManager.isSelfManaged(phoneAccountHandle,
+                (UserHandle) intent.getParcelableExtra(KEY_INITIATING_USER))) {
+            boolean fixedInitiatingUser = fixInitiatingUserIfNecessary(context, intent);
+            // Show the toast to warn user that it is a personal call though initiated in work
+            // profile.
+            if (fixedInitiatingUser) {
+                Toast.makeText(context, R.string.toast_personal_call_msg, Toast.LENGTH_LONG).show();
+            }
+        } else {
+            Log.i(CallIntentProcessor.class,
+                    "processOutgoingCallIntent: skip initiating user check");
         }
 
         UserHandle initiatingUser = intent.getParcelableExtra(KEY_INITIATING_USER);
@@ -182,6 +189,9 @@
                         userManager.getProfileParent(
                                 initiatingUser.getIdentifier()).getUserHandle();
                 intent.putExtra(KEY_INITIATING_USER, parentUserHandle);
+
+                Log.i(CallIntentProcessor.class, "fixInitiatingUserIfNecessary: no dialer installed"
+                        + " for current user; setting initiator to parent %s" + parentUserHandle);
                 return true;
             }
         }
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index 5fa6da5..4ce0ff9 100644
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -1293,7 +1293,13 @@
         return accounts;
     }
 
-    private boolean isSelfManaged(PhoneAccountHandle targetPhoneAccountHandle,
+    /**
+     * Determines if a {@link PhoneAccountHandle} is for a self-managed ConnectionService.
+     * @param targetPhoneAccountHandle The phone account to check.
+     * @param initiatingUser The user associated with the account.
+     * @return {@code true} if the phone account is self-managed, {@code false} otherwise.
+     */
+    public boolean isSelfManaged(PhoneAccountHandle targetPhoneAccountHandle,
             UserHandle initiatingUser) {
         PhoneAccount targetPhoneAccount = mPhoneAccountRegistrar.getPhoneAccount(
                 targetPhoneAccountHandle, initiatingUser);