Associate calls with profile user.

When a secondary/guest user receives an incoming call and then places
an outgoing call on top of it, the incoming call should be held and the
outgoing call made active. However, due to the call user association
logic that was introduced in par with work profile support in U, note
that the associated user for outgoing calls will be the initiating user
while for incoming calls, this is derived from the target phone account
handle.

Hence, the user association for the MT and MO call would be different
when using an unassociated sim to call. There are no issues in the
initial binding with the 1st call but when we bind the 2nd call to the
ICS, we end up resetting the InCallAdapter because no associated ICS
were found for the incoming call. This, inadvertently, disregards the
initial binding so subsequent call updates sent on the incoming call
get ignored. We can disregard the request to reset the adapter
if it has already been set, though this is not a complete solution.

As is, because the services aren't considered connected for the MO call
initially, Telecom will try to reconnect to the service, where we will
send all active calls to the ICS (InCallController#onConnected). We
should not be hitting this part of the call flow and should instead add
the MO call directly to the available service (InCallService#addCall),
as is done in InCallController#onCallAdded.

We could copy the reference to the service available in the MT user over
to the MO user. Alternatively, we can have it so that the user
association for MT calls is dependent on whether the phone account has
the multi user capability, in which case, we will associate the user of
the call with the current user. If we're dealing with a SIM account, then
the user association will continue to use the phone account user handle.

This CL implements the latter approach as it offers a more robust
solution to the problem and allows the sim user association on phone
accounts to be respected in incoming calls if it's not a multi-user
account. In the case of unassociated sims, it makes sense to associate
the calls with the current user instead.

Bug: 294699269
Bug: 308856446
Test: Manual
Test: New unit test to verify that call updates are persevered when
MO/MT call are placed from the secondary/guest user. A unit test to
verify that the user to ICS connection mappings are properly removed in
multi user scenarios.
Test: atest TelecomUnitTests
Test: v2/android-platinum/telephony-platinum-tests-ATT

Change-Id: I47518ab5f3905991c16c0516ea87533b70827022
diff --git a/flags/Android.bp b/flags/Android.bp
index af8b683..6fa147a 100644
--- a/flags/Android.bp
+++ b/flags/Android.bp
@@ -35,6 +35,7 @@
       "telecom_calllog_flags.aconfig",
       "telecom_resolve_hidden_dependencies.aconfig",
       "telecom_bluetoothroutemanager_flags.aconfig",
+      "telecom_work_profile_flags.aconfig"
     ],
 }
 
diff --git a/flags/telecom_work_profile_flags.aconfig b/flags/telecom_work_profile_flags.aconfig
new file mode 100644
index 0000000..cc78b30
--- /dev/null
+++ b/flags/telecom_work_profile_flags.aconfig
@@ -0,0 +1,8 @@
+package: "com.android.server.telecom.flags"
+
+flag {
+  name: "work_profile_associated_user"
+  namespace: "telecom"
+  description: "Redefines the associated user for calls in the context of work profile support (U+)"
+  bug: "294699269"
+}
\ No newline at end of file