Revert "Associate calls with profile user."

Revert submission 24838577-cherrypick-MT-MO-secondaryUserCallUpdateFix-udc-qpr-dev-70l1hzdwrmf

Reason for revert: Probable culprit for b/311270644.

Reverted changes: /q/submissionid:24838577-cherrypick-MT-MO-secondaryUserCallUpdateFix-udc-qpr-dev-70l1hzdwrmf

Change-Id: Ie7d0466292b7514733dc0f666386940fa4b09f09
diff --git a/flags/Android.bp b/flags/Android.bp
index 6fa147a..af8b683 100644
--- a/flags/Android.bp
+++ b/flags/Android.bp
@@ -35,7 +35,6 @@
       "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
deleted file mode 100644
index cc78b30..0000000
--- a/flags/telecom_work_profile_flags.aconfig
+++ /dev/null
@@ -1,8 +0,0 @@
-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
diff --git a/src/com/android/server/telecom/Call.java b/src/com/android/server/telecom/Call.java
index 59399b3..6e4dc3c 100644
--- a/src/com/android/server/telecom/Call.java
+++ b/src/com/android/server/telecom/Call.java
@@ -72,7 +72,6 @@
 import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telecom.IVideoProvider;
 import com.android.internal.util.Preconditions;
-import com.android.server.telecom.flags.FeatureFlags;
 import com.android.server.telecom.stats.CallFailureCause;
 import com.android.server.telecom.stats.CallStateChangedAtomWriter;
 import com.android.server.telecom.ui.ToastFactory;
@@ -787,8 +786,6 @@
      */
     private CompletableFuture<Boolean> mDisconnectFuture;
 
-    private FeatureFlags mFlags;
-
     /**
      * Persists the specified parameters and initializes the new instance.
      * @param context The context.
@@ -820,12 +817,11 @@
             boolean shouldAttachToExistingConnection,
             boolean isConference,
             ClockProxy clockProxy,
-            ToastFactory toastFactory,
-            FeatureFlags featureFlags) {
+            ToastFactory toastFactory) {
         this(callId, context, callsManager, lock, repository, phoneNumberUtilsAdapter,
                handle, null, gatewayInfo, connectionManagerPhoneAccountHandle,
                targetPhoneAccountHandle, callDirection, shouldAttachToExistingConnection,
-               isConference, clockProxy, toastFactory, featureFlags);
+               isConference, clockProxy, toastFactory);
 
     }
 
@@ -845,10 +841,8 @@
             boolean shouldAttachToExistingConnection,
             boolean isConference,
             ClockProxy clockProxy,
-            ToastFactory toastFactory,
-            FeatureFlags featureFlags) {
+            ToastFactory toastFactory) {
 
-        mFlags = featureFlags;
         mId = callId;
         mConnectionId = callId;
         mState = (isConference && callDirection != CALL_DIRECTION_INCOMING &&
@@ -898,7 +892,6 @@
      * connection, regardless of whether it's incoming or outgoing.
      * @param connectTimeMillis The connection time of the call.
      * @param clockProxy
-     * @param featureFlags
      */
     Call(
             String callId,
@@ -917,13 +910,11 @@
             long connectTimeMillis,
             long connectElapsedTimeMillis,
             ClockProxy clockProxy,
-            ToastFactory toastFactory,
-            FeatureFlags featureFlags) {
+            ToastFactory toastFactory) {
         this(callId, context, callsManager, lock, repository,
                 phoneNumberUtilsAdapter, handle, gatewayInfo,
                 connectionManagerPhoneAccountHandle, targetPhoneAccountHandle, callDirection,
-                shouldAttachToExistingConnection, isConference, clockProxy, toastFactory,
-                featureFlags);
+                shouldAttachToExistingConnection, isConference, clockProxy, toastFactory);
 
         mConnectTimeMillis = connectTimeMillis;
         mConnectElapsedTimeMillis = connectElapsedTimeMillis;
@@ -1775,14 +1766,8 @@
                     accountHandle.getComponentName().getPackageName(),
                     mContext.getPackageManager());
             // Set the associated user for the call for MT calls based on the target phone account.
-            UserHandle associatedUser = mFlags.workProfileAssociatedUser()
-                    ? UserUtil.getAssociatedUserForCall(
-                    mCallsManager.getPhoneAccountRegistrar(),
-                    mCallsManager.getCurrentUserHandle(),
-                    accountHandle)
-                    : accountHandle.getUserHandle();
-            if (isIncoming() && !associatedUser.equals(mAssociatedUser)) {
-                setAssociatedUser(associatedUser);
+            if (isIncoming() && !accountHandle.getUserHandle().equals(mAssociatedUser)) {
+                setAssociatedUser(accountHandle.getUserHandle());
             }
         }
     }
@@ -4107,7 +4092,7 @@
      * @param associatedUser
      */
     public void setAssociatedUser(UserHandle associatedUser) {
-        Log.i(this, "Setting associated user for call: %s", associatedUser);
+        Log.i(this, "Setting associated user for call");
         Preconditions.checkNotNull(associatedUser);
         mAssociatedUser = associatedUser;
     }
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index 9179faf..f85a809 100755
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -1482,8 +1482,7 @@
                 false /* forceAttachToExistingConnection */,
                 isConference, /* isConference */
                 mClockProxy,
-                mToastFactory,
-                mFeatureFlags);
+                mToastFactory);
         // Ensure new calls related to self-managed calls/connections are set as such. This will
         // be overridden when the actual connection is returned in startCreateConnection, however
         // doing this now ensures the logs and any other logic will treat this call as self-managed
@@ -1510,11 +1509,7 @@
                 }
             }
             // Incoming address was set via EXTRA_INCOMING_CALL_ADDRESS above.
-            UserHandle associatedUser = mFeatureFlags.workProfileAssociatedUser()
-                    ? UserUtil.getAssociatedUserForCall(getPhoneAccountRegistrar(),
-                    getCurrentUserHandle(), phoneAccountHandle)
-                    : phoneAccountHandle.getUserHandle();
-            call.setAssociatedUser(associatedUser);
+            call.setAssociatedUser(phoneAccountHandle.getUserHandle());
         }
 
         if (phoneAccount != null) {
@@ -1634,19 +1629,15 @@
         // Check if the target phone account is possibly in ECBM.
         call.setIsInECBM(getEmergencyCallHelper()
                 .isLastOutgoingEmergencyCallPAH(call.getTargetPhoneAccount()));
-
-        // Check if call is visible to the current user.
-        boolean isCallHiddenFromProfile = !isCallVisibleForUser(call, mCurrentUserHandle);
-        // For admins, we should check if the work profile is paused in order to reject
-        // the call.
-        if (mUserManager.isUserAdmin(mCurrentUserHandle.getIdentifier())) {
-            isCallHiddenFromProfile &= mUserManager.isQuietModeEnabled(
-                call.getAssociatedUser());
-        }
-
-        // We should always allow emergency calls and also allow non-emergency calls when ECBM
-        // is active for the phone account.
-        if (isCallHiddenFromProfile && !call.isEmergencyCall() && !call.isInECBM()) {
+        // If the phone account user profile is paused or the call isn't visible to the secondary/
+        // guest user, reject the non-emergency incoming call. When the current user is the admin,
+        // we need to allow the calls to go through if the work profile isn't paused. We should
+        // always allow emergency calls and also allow non-emergency calls when ECBM is active for
+        // the phone account.
+        if ((mUserManager.isQuietModeEnabled(call.getAssociatedUser())
+                || (!mUserManager.isUserAdmin(mCurrentUserHandle.getIdentifier())
+                && !isCallVisibleForUser(call, mCurrentUserHandle)))
+                && !call.isEmergencyCall() && !call.isInECBM()) {
             Log.d(TAG, "Rejecting non-emergency call because the owner %s is not running.",
                     phoneAccountHandle.getUserHandle());
             call.setMissedReason(USER_MISSED_NOT_RUNNING);
@@ -1719,16 +1710,11 @@
                 true /* forceAttachToExistingConnection */,
                 false, /* isConference */
                 mClockProxy,
-                mToastFactory,
-                mFeatureFlags);
+                mToastFactory);
         call.initAnalytics();
 
         // For unknown calls, base the associated user off of the target phone account handle.
-        UserHandle associatedUser = mFeatureFlags.workProfileAssociatedUser()
-                ? UserUtil.getAssociatedUserForCall(getPhoneAccountRegistrar(),
-                getCurrentUserHandle(), phoneAccountHandle)
-                : phoneAccountHandle.getUserHandle();
-        call.setAssociatedUser(associatedUser);
+        call.setAssociatedUser(phoneAccountHandle.getUserHandle());
         setIntentExtrasAndStartTime(call, extras);
         call.addListener(this);
         notifyStartCreateConnection(call);
@@ -1842,8 +1828,7 @@
                     false /* forceAttachToExistingConnection */,
                     isConference, /* isConference */
                     mClockProxy,
-                    mToastFactory,
-                    mFeatureFlags);
+                    mToastFactory);
 
             if (extras.containsKey(TelecomManager.TRANSACTION_CALL_ID_KEY)) {
                 call.setIsTransactionalCall(true);
@@ -4250,8 +4235,7 @@
                 connectTime,
                 connectElapsedTime,
                 mClockProxy,
-                mToastFactory,
-                mFeatureFlags);
+                mToastFactory);
 
         // Unlike connections, conferences are not created first and then notified as create
         // connection complete from the CS.  They originate from the CS and are reported directly to
@@ -4269,11 +4253,7 @@
         call.setStatusHints(parcelableConference.getStatusHints());
         call.putConnectionServiceExtras(parcelableConference.getExtras());
         // For conference calls, set the associated user from the target phone account user handle.
-        UserHandle associatedUser = mFeatureFlags.workProfileAssociatedUser()
-                ? UserUtil.getAssociatedUserForCall(getPhoneAccountRegistrar(),
-                getCurrentUserHandle(), phoneAccount)
-                : phoneAccount.getUserHandle();
-        call.setAssociatedUser(associatedUser);
+        call.setAssociatedUser(phoneAccount.getUserHandle());
         // In case this Conference was added via a ConnectionManager, keep track of the original
         // Connection ID as created by the originating ConnectionService.
         Bundle extras = parcelableConference.getExtras();
@@ -5311,8 +5291,7 @@
                 connection.getConnectTimeMillis() /* connectTimeMillis */,
                 connection.getConnectElapsedTimeMillis(), /* connectElapsedTimeMillis */
                 mClockProxy,
-                mToastFactory,
-                mFeatureFlags);
+                mToastFactory);
 
         call.initAnalytics();
         call.getAnalytics().setCreatedFromExistingConnection(true);
@@ -5327,11 +5306,7 @@
                 connection.getCallerDisplayNamePresentation());
         // For existing connections, use the phone account user handle to determine the user
         // association with the call.
-        UserHandle associatedUser = mFeatureFlags.workProfileAssociatedUser()
-                ? UserUtil.getAssociatedUserForCall(getPhoneAccountRegistrar(),
-                getCurrentUserHandle(), connection.getPhoneAccount())
-                : connection.getPhoneAccount().getUserHandle();
-        call.setAssociatedUser(associatedUser);
+        call.setAssociatedUser(connection.getPhoneAccount().getUserHandle());
         call.addListener(this);
         call.putConnectionServiceExtras(connection.getExtras());
 
@@ -5976,7 +5951,7 @@
                 handoverFromCall.getHandle(), null,
                 null, null,
                 Call.CALL_DIRECTION_OUTGOING, false,
-                false, mClockProxy, mToastFactory, mFeatureFlags);
+                false, mClockProxy, mToastFactory);
         call.initAnalytics();
 
         // Set self-managed and voipAudioMode if destination is self-managed CS
@@ -6183,8 +6158,7 @@
                 false /* forceAttachToExistingConnection */,
                 false, /* isConference */
                 mClockProxy,
-                mToastFactory,
-                mFeatureFlags);
+                mToastFactory);
 
         if (fromCall == null || isHandoverInProgress() ||
                 !isHandoverFromPhoneAccountSupported(fromCall.getTargetPhoneAccount()) ||
diff --git a/src/com/android/server/telecom/InCallController.java b/src/com/android/server/telecom/InCallController.java
index 1aee25c..184eadd 100644
--- a/src/com/android/server/telecom/InCallController.java
+++ b/src/com/android/server/telecom/InCallController.java
@@ -82,7 +82,6 @@
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 /**
  * Binds to {@link IInCallService} and provides the service to {@link CallsManager} through which it
@@ -1407,31 +1406,17 @@
     @Override
     public void onCallRemoved(Call call) {
         Log.i(this, "onCallRemoved: %s", call);
-        // Instead of checking if there are no active calls, we should check if there any calls with
-        // the same associated user returned from getUserFromCall. For instance, it's possible to
-        // have calls coexist on the personal profile and work profile, in which case, we would only
-        // remove the ICS connection for the user associated with the call to be disconnected.
-        UserHandle userFromCall = getUserFromCall(call);
-        Stream<Call> callsAssociatedWithUserFromCall = mCallsManager.getCalls().stream()
-                .filter((c) -> getUserFromCall(c).equals(userFromCall));
-        boolean isCallCountZero = mFeatureFlags.workProfileAssociatedUser()
-                ? callsAssociatedWithUserFromCall.count() == 0
-                : mCallsManager.getCalls().isEmpty();
-        if (isCallCountZero) {
+        if (mCallsManager.getCalls().isEmpty()) {
             /** Let's add a 2 second delay before we send unbind to the services to hopefully
              *  give them enough time to process all the pending messages.
              */
             mHandler.postDelayed(new Runnable("ICC.oCR", mLock) {
                 @Override
                 public void loggedRun() {
-                    // Check again to make sure there are no active calls for the associated user.
-                    Stream<Call> callsAssociatedWithUserFromCall = mCallsManager.getCalls().stream()
-                            .filter((c) -> getUserFromCall(c).equals(userFromCall));
-                    boolean isCallCountZero = mFeatureFlags.workProfileAssociatedUser()
-                            ? callsAssociatedWithUserFromCall.count() == 0
-                            : mCallsManager.getCalls().isEmpty();
-                    if (isCallCountZero) {
-                        unbindFromServices(userFromCall);
+                    // Check again to make sure there are no active calls.
+                    if (mCallsManager.getCalls().isEmpty()) {
+                        unbindFromServices(getUserFromCall(call));
+
                         mEmergencyCallHelper.maybeRevokeTemporaryLocationPermission();
                     }
                 }
@@ -1847,7 +1832,6 @@
      * Unbinds an existing bound connection to the in-call app.
      */
     public void unbindFromServices(UserHandle userHandle) {
-        Log.i(this, "Unbinding from services for user %s", userHandle);
         try {
             mContext.unregisterReceiver(mPackageChangedReceiver);
         } catch (IllegalArgumentException e) {
@@ -2336,9 +2320,7 @@
         }
 
         // Upon successful connection, send the state of the world to the service.
-        List<Call> calls = orderCallsWithChildrenFirst(mCallsManager.getCalls().stream().filter(
-                call -> getUserFromCall(call).equals(userHandle))
-                .collect(Collectors.toUnmodifiableList()));
+        List<Call> calls = orderCallsWithChildrenFirst(mCallsManager.getCalls());
         Log.i(this, "Adding %s calls to InCallService after onConnected: %s, including external " +
                 "calls", calls.size(), info.getComponentName());
         int numCallsSent = 0;
@@ -2481,9 +2463,6 @@
                 }
             }
             Log.i(this, "Components updated: %s", componentsUpdated);
-        } else {
-            Log.i(this,
-                    "Unable to update call. InCallService not found for user: %s", userFromCall);
         }
     }
 
@@ -2922,11 +2901,8 @@
         } else {
             UserHandle userFromCall = call.getAssociatedUser();
             UserManager userManager = mContext.getSystemService(UserManager.class);
-            // Emergency call should never be blocked, so if the user associated with the target
-            // phone account handle user is in quiet mode, use the current user for the ecall.
-            // Note, that this only applies to incoming calls that are received on assigned
-            // sims (i.e. work sim), where the associated user would be the target phone account
-            // handle user.
+            // Emergency call should never be blocked, so if the user associated with call is in
+            // quite mode, use the primary user for the emergency call.
             if ((call.isEmergencyCall() || call.isInECBM())
                     && (userManager.isQuietModeEnabled(userFromCall)
                     // We should also account for secondary/guest users where the profile may not
diff --git a/src/com/android/server/telecom/Ringer.java b/src/com/android/server/telecom/Ringer.java
index e32cd63..5b86b82 100644
--- a/src/com/android/server/telecom/Ringer.java
+++ b/src/com/android/server/telecom/Ringer.java
@@ -721,12 +721,8 @@
         boolean letDialerHandleRinging = mInCallController.doesConnectedDialerSupportRinging(
                 call.getAssociatedUser());
         timer.record("letDialerHandleRinging");
-        UserHandle profileUser = call.getTargetPhoneAccount() != null
-                && mFlags.workProfileAssociatedUser()
-                ? call.getTargetPhoneAccount().getUserHandle()
-                : call.getAssociatedUser();
         boolean isWorkProfileInQuietMode =
-                isProfileInQuietMode(profileUser);
+                isProfileInQuietMode(call.getAssociatedUser());
         timer.record("isWorkProfileInQuietMode");
 
         Log.i(this, "startRinging timings: " + timer);
diff --git a/src/com/android/server/telecom/UserUtil.java b/src/com/android/server/telecom/UserUtil.java
index 657f189..d0a561a 100644
--- a/src/com/android/server/telecom/UserUtil.java
+++ b/src/com/android/server/telecom/UserUtil.java
@@ -24,8 +24,6 @@
 import android.os.UserHandle;
 import android.os.UserManager;
 import android.telecom.Log;
-import android.telecom.PhoneAccount;
-import android.telecom.PhoneAccountHandle;
 
 import com.android.server.telecom.components.ErrorDialogActivity;
 
@@ -101,28 +99,4 @@
         }
         return false;
     }
-
-    /**
-     * Gets the associated user for the given call. Note: this is applicable to all calls except
-     * outgoing calls as the associated user is already based off of the user placing the
-     * call.
-     *
-     * @return current user if it isn't the admin or if the work profile is paused for the target
-     * phone account handle user, otherwise return the target phone account handle user.
-     */
-    public static UserHandle getAssociatedUserForCall(PhoneAccountRegistrar phoneAccountRegistrar,
-            UserHandle currentUser, PhoneAccountHandle targetPhoneAccount) {
-        // For multi-user phone accounts, associate the call with the profile receiving/placing
-        // the call. For SIM accounts (that are assigned to specific users), the user association
-        // will be placed on the target phone account handle user.
-        PhoneAccount account = phoneAccountRegistrar.getPhoneAccountUnchecked(targetPhoneAccount);
-        if (account != null) {
-            return account.hasCapabilities(PhoneAccount.CAPABILITY_MULTI_USER)
-                    ? currentUser
-                    : targetPhoneAccount.getUserHandle();
-        }
-        // If target phone account handle is null or account cannot be found,
-        // return the current user.
-        return currentUser;
-    }
 }
diff --git a/tests/src/com/android/server/telecom/tests/BasicCallTests.java b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
index d2937e2..14065ca 100644
--- a/tests/src/com/android/server/telecom/tests/BasicCallTests.java
+++ b/tests/src/com/android/server/telecom/tests/BasicCallTests.java
@@ -69,8 +69,6 @@
 import androidx.test.filters.SmallTest;
 
 import com.android.internal.telecom.IInCallAdapter;
-import com.android.server.telecom.InCallController;
-
 import android.telecom.CallerInfo;
 
 import com.google.common.base.Predicate;
@@ -626,48 +624,6 @@
 
     @LargeTest
     @Test
-    public void testIncomingThenOutgoingCalls_AssociatedUsersNotEqual() throws Exception {
-        when(mFeatureFlags.workProfileAssociatedUser()).thenReturn(true);
-        InCallServiceFixture.setIgnoreOverrideAdapterFlag(true);
-
-        // Receive incoming call via mPhoneAccountMultiUser
-        IdPair incoming = startAndMakeActiveIncomingCall("650-555-2323",
-                mPhoneAccountMultiUser.getAccountHandle(), mConnectionServiceFixtureA);
-        waitForHandlerAction(mConnectionServiceFixtureA.mConnectionServiceDelegate.getHandler(),
-                TEST_TIMEOUT);
-        // Make outgoing call on mPhoneAccountMultiUser (unassociated sim to simulate guest/
-        // secondary user scenario where both MO/MT calls exist).
-        IdPair outgoing = startAndMakeActiveOutgoingCall("650-555-1212",
-                mPhoneAccountMultiUser.getAccountHandle(), mConnectionServiceFixtureA);
-        waitForHandlerAction(mConnectionServiceFixtureA.mConnectionServiceDelegate.getHandler(),
-                TEST_TIMEOUT);
-
-        // Outgoing call should be on hold while incoming call is made active
-        mConnectionServiceFixtureA.mConnectionById.get(incoming.mConnectionId).state =
-                Connection.STATE_HOLDING;
-
-        // Swap calls and verify that outgoing call is now the active call while the incoming call
-        // is the held call.
-        mConnectionServiceFixtureA.sendSetOnHold(outgoing.mConnectionId);
-        waitForHandlerAction(mConnectionServiceFixtureA.mConnectionServiceDelegate.getHandler(),
-                TEST_TIMEOUT);
-        assertEquals(Call.STATE_HOLDING,
-                mInCallServiceFixtureX.getCall(outgoing.mCallId).getState());
-        assertEquals(Call.STATE_ACTIVE,
-                mInCallServiceFixtureX.getCall(incoming.mCallId).getState());
-
-        // Ensure no issues with call disconnect.
-        mInCallServiceFixtureX.mInCallAdapter.disconnectCall(incoming.mCallId);
-        mInCallServiceFixtureX.mInCallAdapter.disconnectCall(outgoing.mCallId);
-        assertEquals(Call.STATE_DISCONNECTING,
-                mInCallServiceFixtureX.getCall(incoming.mCallId).getState());
-        assertEquals(Call.STATE_DISCONNECTING,
-                mInCallServiceFixtureX.getCall(outgoing.mCallId).getState());
-        InCallServiceFixture.setIgnoreOverrideAdapterFlag(false);
-    }
-
-    @LargeTest
-    @Test
     public void testAudioManagerOperations() throws Exception {
         AudioManager audioManager = (AudioManager) mComponentContextFixture.getTestDouble()
                 .getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
diff --git a/tests/src/com/android/server/telecom/tests/CallAnomalyWatchdogTest.java b/tests/src/com/android/server/telecom/tests/CallAnomalyWatchdogTest.java
index 86d24f9..7e197fe 100644
--- a/tests/src/com/android/server/telecom/tests/CallAnomalyWatchdogTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallAnomalyWatchdogTest.java
@@ -27,7 +27,6 @@
 
 import android.content.ComponentName;
 import android.net.Uri;
-import android.os.UserHandle;
 import android.telecom.DisconnectCause;
 import android.telecom.PhoneAccount;
 import android.telecom.PhoneAccountHandle;
@@ -124,7 +123,6 @@
         mCallAnomalyWatchdog = new CallAnomalyWatchdog(mTestScheduledExecutorService, mLock,
                 mTimeouts, mMockClockProxy, mMockEmergencyCallDiagnosticLogger);
         mCallAnomalyWatchdog.setAnomalyReporterAdapter(mAnomalyReporterAdapter);
-        when(mMockCallsManager.getCurrentUserHandle()).thenReturn(UserHandle.CURRENT);
     }
 
     @Override
@@ -864,7 +862,6 @@
                 false /* shouldAttachToExistingConnection*/,
                 false /* isConference */,
                 mMockClockProxy,
-                mMockToastProxy,
-                mFeatureFlags);
+                mMockToastProxy);
     }
 }
\ No newline at end of file
diff --git a/tests/src/com/android/server/telecom/tests/CallTest.java b/tests/src/com/android/server/telecom/tests/CallTest.java
index 2933345..997e7dd 100644
--- a/tests/src/com/android/server/telecom/tests/CallTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallTest.java
@@ -38,7 +38,6 @@
 import android.graphics.drawable.ColorDrawable;
 import android.net.Uri;
 import android.os.Bundle;
-import android.os.UserHandle;
 import android.telecom.CallAttributes;
 import android.telecom.CallerInfo;
 import android.telecom.Connection;
@@ -118,7 +117,6 @@
         doReturn(new ComponentName(mContext, CallTest.class))
                 .when(mMockConnectionService).getComponentName();
         doReturn(mMockToast).when(mMockToastProxy).makeText(any(), anyInt(), anyInt());
-        doReturn(UserHandle.CURRENT).when(mMockCallsManager).getCurrentUserHandle();
     }
 
     @After
@@ -202,8 +200,7 @@
                 false /* shouldAttachToExistingConnection*/,
                 false /* isConference */,
                 mMockClockProxy,
-                mMockToastProxy,
-                mFeatureFlags);
+                mMockToastProxy);
 
         // To start with connection creation isn't complete.
         assertFalse(call.isCreateConnectionComplete());
@@ -341,8 +338,7 @@
                 false /* shouldAttachToExistingConnection*/,
                 true /* isConference */,
                 mMockClockProxy,
-                mMockToastProxy,
-                mFeatureFlags);
+                mMockToastProxy);
 
         assertFalse(call.wasDndCheckComputedForCall());
         assertFalse(call.isCallSuppressedByDoNotDisturb());
@@ -368,8 +364,7 @@
                 false /* shouldAttachToExistingConnection*/,
                 true /* isConference */,
                 mMockClockProxy,
-                mMockToastProxy,
-                mFeatureFlags);
+                mMockToastProxy);
 
         assertNull(call.getConnectionServiceWrapper());
         assertFalse(call.isTransactionalCall());
@@ -399,8 +394,7 @@
                 false /* shouldAttachToExistingConnection*/,
                 true /* isConference */,
                 mMockClockProxy,
-                mMockToastProxy,
-                mFeatureFlags);
+                mMockToastProxy);
 
         // setup
         call.setIsTransactionalCall(true);
@@ -754,7 +748,6 @@
                 false,
                 false,
                 mMockClockProxy,
-                mMockToastProxy,
-                mFeatureFlags);
+                mMockToastProxy);
     }
 }
diff --git a/tests/src/com/android/server/telecom/tests/CallsManagerTest.java b/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
index 649f435..c02a0a8 100644
--- a/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
+++ b/tests/src/com/android/server/telecom/tests/CallsManagerTest.java
@@ -415,8 +415,7 @@
                 false /* shouldAttachToExistingConnection*/,
                 false /* isConference */,
                 mClockProxy,
-                mToastFactory,
-                mFeatureFlags);
+                mToastFactory);
         ongoingCall.setState(CallState.ACTIVE, "just cuz");
         return ongoingCall;
     }
@@ -2589,7 +2588,9 @@
                 WORK_HANDLE.getUserHandle(), service);
 
         UserManager um = mContext.getSystemService(UserManager.class);
-        when(um.isUserAdmin(anyInt())).thenReturn(false);
+        UserHandle newUser = new UserHandle(11);
+        when(mCallsManager.getCurrentUserHandle()).thenReturn(newUser);
+        when(um.isUserAdmin(eq(newUser.getIdentifier()))).thenReturn(false);
         when(um.isQuietModeEnabled(eq(WORK_HANDLE.getUserHandle()))).thenReturn(false);
         when(mPhoneAccountRegistrar.getPhoneAccountUnchecked(eq(WORK_HANDLE)))
                 .thenReturn(WORK_ACCOUNT);
@@ -2605,17 +2606,14 @@
     @Test
     public void testRejectIncomingCallOnPAHInactive_ProfilePaused() throws Exception {
         ConnectionServiceWrapper service = mock(ConnectionServiceWrapper.class);
-        doReturn(WORK_HANDLE.getComponentName()).when(service).getComponentName();
-        mCallsManager.addConnectionServiceRepositoryCache(WORK_HANDLE.getComponentName(),
-                WORK_HANDLE.getUserHandle(), service);
+        doReturn(SIM_2_HANDLE.getComponentName()).when(service).getComponentName();
+        mCallsManager.addConnectionServiceRepositoryCache(SIM_2_HANDLE.getComponentName(),
+                SIM_2_HANDLE.getUserHandle(), service);
 
         UserManager um = mContext.getSystemService(UserManager.class);
-        when(um.isUserAdmin(anyInt())).thenReturn(true);
-        when(um.isQuietModeEnabled(eq(WORK_HANDLE.getUserHandle()))).thenReturn(true);
-        when(mPhoneAccountRegistrar.getPhoneAccountUnchecked(eq(WORK_HANDLE)))
-                .thenReturn(WORK_ACCOUNT);
+        when(um.isQuietModeEnabled(eq(SIM_2_HANDLE.getUserHandle()))).thenReturn(true);
         Call newCall = mCallsManager.processIncomingCallIntent(
-                WORK_HANDLE, new Bundle(), false);
+                SIM_2_HANDLE, new Bundle(), false);
 
         verify(service, timeout(TEST_TIMEOUT)).createConnectionFailed(any());
         assertFalse(newCall.isInECBM());
@@ -2652,7 +2650,9 @@
         when(mEmergencyCallHelper.isLastOutgoingEmergencyCallPAH(eq(WORK_HANDLE)))
                 .thenReturn(true);
         UserManager um = mContext.getSystemService(UserManager.class);
-        when(um.isUserAdmin(anyInt())).thenReturn(false);
+        UserHandle newUser = new UserHandle(11);
+        when(mCallsManager.getCurrentUserHandle()).thenReturn(newUser);
+        when(um.isUserAdmin(eq(newUser.getIdentifier()))).thenReturn(false);
         when(um.isQuietModeEnabled(eq(WORK_HANDLE.getUserHandle()))).thenReturn(false);
         when(mPhoneAccountRegistrar.getPhoneAccountUnchecked(eq(WORK_HANDLE)))
                 .thenReturn(WORK_ACCOUNT);
@@ -3429,8 +3429,7 @@
                 false /* shouldAttachToExistingConnection*/,
                 false /* isConference */,
                 mClockProxy,
-                mToastFactory,
-                mFeatureFlags);
+                mToastFactory);
         ongoingCall.setState(initialState, "just cuz");
         if (targetPhoneAccount == SELF_MANAGED_HANDLE
                 || targetPhoneAccount == SELF_MANAGED_2_HANDLE) {
diff --git a/tests/src/com/android/server/telecom/tests/EmergencyCallDiagnosticLoggerTest.java b/tests/src/com/android/server/telecom/tests/EmergencyCallDiagnosticLoggerTest.java
index c63a3d5..3cb8196 100644
--- a/tests/src/com/android/server/telecom/tests/EmergencyCallDiagnosticLoggerTest.java
+++ b/tests/src/com/android/server/telecom/tests/EmergencyCallDiagnosticLoggerTest.java
@@ -35,7 +35,6 @@
 import android.net.Uri;
 import android.os.BugreportManager;
 import android.os.DropBoxManager;
-import android.os.UserHandle;
 import android.telecom.DisconnectCause;
 import android.telecom.PhoneAccount;
 import android.telecom.PhoneAccountHandle;
@@ -129,7 +128,6 @@
         when(mTimeouts.getDaysBackToSearchEmergencyDiagnosticEntries()).
                 thenReturn(DAYS_BACK_TO_SEARCH_EMERGENCY_DIAGNOSTIC_ENTRIES);
         when(mClockProxy.currentTimeMillis()).thenReturn(System.currentTimeMillis());
-        when(mMockCallsManager.getCurrentUserHandle()).thenReturn(UserHandle.CURRENT);
 
         mEmergencyCallDiagnosticLogger = new EmergencyCallDiagnosticLogger(mTm, mBrm,
                 mTimeouts, mDbm, Runnable::run, mClockProxy);
@@ -173,8 +171,7 @@
                 false /* shouldAttachToExistingConnection*/,
                 false /* isConference */,
                 mMockClockProxy,
-                mMockToastProxy,
-                mFeatureFlags);
+                mMockToastProxy);
     }
 
     /**
diff --git a/tests/src/com/android/server/telecom/tests/InCallControllerTests.java b/tests/src/com/android/server/telecom/tests/InCallControllerTests.java
index cd8431a..1b5677e 100644
--- a/tests/src/com/android/server/telecom/tests/InCallControllerTests.java
+++ b/tests/src/com/android/server/telecom/tests/InCallControllerTests.java
@@ -141,8 +141,6 @@
     @Mock PackageManager mMockPackageManager;
     @Mock PermissionCheckerManager mMockPermissionCheckerManager;
     @Mock Call mMockCall;
-    @Mock Call mMockSystemCall1;
-    @Mock Call mMockSystemCall2;
     @Mock Resources mMockResources;
     @Mock AppOpsManager mMockAppOpsManager;
     @Mock MockContext mMockContext;
@@ -588,7 +586,6 @@
         when(mMockCall.isEmergencyCall()).thenReturn(true);
         when(mMockCall.isIncoming()).thenReturn(true);
         when(mMockCall.getAssociatedUser()).thenReturn(DUMMY_USER_HANDLE);
-        when(mMockCall.getTargetPhoneAccount()).thenReturn(PA_HANDLE);
         when(mMockContext.getSystemService(eq(UserManager.class)))
             .thenReturn(mMockUserManager);
         when(mMockUserManager.isQuietModeEnabled(any(UserHandle.class))).thenReturn(true);
@@ -618,7 +615,6 @@
         when(mMockCall.isInECBM()).thenReturn(true);
         when(mMockCall.isIncoming()).thenReturn(true);
         when(mMockCall.getAssociatedUser()).thenReturn(DUMMY_USER_HANDLE);
-        when(mMockCall.getTargetPhoneAccount()).thenReturn(PA_HANDLE);
         when(mMockContext.getSystemService(eq(UserManager.class)))
                 .thenReturn(mMockUserManager);
         when(mMockUserManager.isQuietModeEnabled(any(UserHandle.class))).thenReturn(true);
@@ -649,7 +645,6 @@
         when(mMockCall.isInECBM()).thenReturn(true);
         when(mMockCall.isIncoming()).thenReturn(true);
         when(mMockCall.getAssociatedUser()).thenReturn(DUMMY_USER_HANDLE);
-        when(mMockCall.getTargetPhoneAccount()).thenReturn(PA_HANDLE);
         when(mMockContext.getSystemService(eq(UserManager.class)))
                 .thenReturn(mMockUserManager);
         when(mMockUserManager.isQuietModeEnabled(any(UserHandle.class))).thenReturn(false);
@@ -1842,67 +1837,6 @@
         assertNull(mInCallController.getInCallServiceConnections().get(testUser));
     }
 
-    @Test
-    public void testRemoveAllServiceConnections_MultiUser() throws Exception {
-        when(mFeatureFlags.workProfileAssociatedUser()).thenReturn(true);
-        setupMocks(false /* isExternalCall */);
-        setupMockPackageManager(true /* default */, true /* system */, false /* external calls */);
-        UserHandle workUser = new UserHandle(12);
-        UserManager um = mContext.getSystemService(UserManager.class);
-        when(um.getUserInfo(anyInt())).thenReturn(mMockUserInfo);
-        when(mMockUserInfo.isManagedProfile()).thenReturn(false);
-        when(mMockCall.getAssociatedUser()).thenReturn(workUser);
-        setupFakeSystemCall(mMockSystemCall1, 1);
-        setupFakeSystemCall(mMockSystemCall2, 2);
-
-        // Add "work" call to service. The mapping should've been inserted
-        // with the workUser as the key.
-        mInCallController.onCallAdded(mMockCall);
-        // Add system call to service. The mapping should've been
-        // inserted with the system user as the key.
-        mInCallController.onCallAdded(mMockSystemCall1);
-
-        ArgumentCaptor<Intent> bindIntentCaptor = ArgumentCaptor.forClass(Intent.class);
-        // Make sure we bound to the system call as well as the work call.
-        verify(mMockContext, times(2)).bindServiceAsUser(
-                bindIntentCaptor.capture(),
-                any(ServiceConnection.class),
-                eq(serviceBindingFlags),
-                eq(UserHandle.CURRENT));
-        assertTrue(mInCallController.getInCallServiceConnections().containsKey(workUser));
-        assertTrue(mInCallController.getInCallServiceConnections().containsKey(UserHandle.SYSTEM));
-
-        // Remove the work call. This leverages getUserFromCall to remove the ICS mapping.
-        when(mMockCallsManager.getCalls()).thenReturn(Collections.singletonList(mMockSystemCall1));
-        mInCallController.onCallRemoved(mMockCall);
-        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
-        // Verify that the mapping was properly removed.
-        assertNull(mInCallController.getInCallServiceConnections().get(workUser));
-        // Verify mapping for system user is still present.
-        assertNotNull(mInCallController.getInCallServiceConnections().get(UserHandle.SYSTEM));
-
-        // Add another system call
-        mInCallController.onCallAdded(mMockSystemCall2);
-        when(mMockCallsManager.getCalls()).thenReturn(Collections.singletonList(mMockSystemCall2));
-        // Remove first system call and verify that mapping is present
-        mInCallController.onCallRemoved(mMockSystemCall1);
-        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
-        // Verify mapping for system user is still present.
-        assertNotNull(mInCallController.getInCallServiceConnections().get(UserHandle.SYSTEM));
-        // Remove last system call and verify that connection isn't present in ICS mapping.
-        when(mMockCallsManager.getCalls()).thenReturn(Collections.emptyList());
-        mInCallController.onCallRemoved(mMockSystemCall2);
-        waitForHandlerAction(new Handler(Looper.getMainLooper()), TEST_TIMEOUT);
-        assertNull(mInCallController.getInCallServiceConnections().get(UserHandle.SYSTEM));
-    }
-
-    private void setupFakeSystemCall(@Mock Call call, int id) {
-        when(call.getAssociatedUser()).thenReturn(UserHandle.SYSTEM);
-        when(call.getTargetPhoneAccount()).thenReturn(PA_HANDLE);
-        when(call.getAnalytics()).thenReturn(new Analytics.CallInfo());
-        when(call.getId()).thenReturn("TC@" + id);
-    }
-
     private void setupMocksForWorkProfileTest() {
         when(mMockContext.getPackageManager()).thenReturn(mMockPackageManager);
         when(mMockCallsManager.isInEmergencyCall()).thenReturn(false);
diff --git a/tests/src/com/android/server/telecom/tests/InCallServiceFixture.java b/tests/src/com/android/server/telecom/tests/InCallServiceFixture.java
index 39381e6..88b5bb5 100644
--- a/tests/src/com/android/server/telecom/tests/InCallServiceFixture.java
+++ b/tests/src/com/android/server/telecom/tests/InCallServiceFixture.java
@@ -16,7 +16,6 @@
 
 package com.android.server.telecom.tests;
 
-import com.android.internal.annotations.VisibleForTesting;
 import com.android.internal.telecom.IInCallAdapter;
 import com.android.internal.telecom.IInCallService;
 
@@ -40,7 +39,7 @@
  * Controls a test {@link IInCallService} as would be provided by an InCall UI on a system.
  */
 public class InCallServiceFixture implements TestFixture<IInCallService> {
-    public static boolean sIgnoreOverrideAdapterFlag = false;
+
     public String mLatestCallId;
     public IInCallAdapter mInCallAdapter;
     public CallAudioState mCallAudioState;
@@ -54,17 +53,10 @@
     public CountDownLatch mUpdateCallLock = new CountDownLatch(1);
     public CountDownLatch mAddCallLock = new CountDownLatch(1);
 
-    @VisibleForTesting
-    public static void setIgnoreOverrideAdapterFlag(boolean flag) {
-        sIgnoreOverrideAdapterFlag = flag;
-    }
-
     public class FakeInCallService extends IInCallService.Stub {
         @Override
         public void setInCallAdapter(IInCallAdapter inCallAdapter) throws RemoteException {
-            // sIgnoreOverrideAdapterFlag is being used to verify a scenario where the InCallAdapter
-            // gets set twice (secondary user places MO/MT call).
-            if (mInCallAdapter != null && inCallAdapter != null && !sIgnoreOverrideAdapterFlag) {
+            if (mInCallAdapter != null && inCallAdapter != null) {
                 throw new RuntimeException("Adapter is already set");
             }
             if (mInCallAdapter == null && inCallAdapter == null) {
diff --git a/tests/src/com/android/server/telecom/tests/MissedInformationTest.java b/tests/src/com/android/server/telecom/tests/MissedInformationTest.java
index f28966e..753c847 100644
--- a/tests/src/com/android/server/telecom/tests/MissedInformationTest.java
+++ b/tests/src/com/android/server/telecom/tests/MissedInformationTest.java
@@ -153,8 +153,6 @@
         setUpEmergencyCall();
         when(mEmergencyCall.getAssociatedUser()).
                 thenReturn(mPhoneAccountA0.getAccountHandle().getUserHandle());
-        when(mEmergencyCall.getTargetPhoneAccount())
-                .thenReturn(mPhoneAccountA0.getAccountHandle());
         mCallsManager.addCall(mEmergencyCall);
         assertTrue(mCallsManager.isInEmergencyCall());
 
@@ -420,7 +418,7 @@
                 null, mCallsManager.getPhoneNumberUtilsAdapter(), null,
                 null, null, mPhoneAccountA0.getAccountHandle(),
                 Call.CALL_DIRECTION_INCOMING, false, false,
-                mClockProxy, null, mFeatureFlags));
+                mClockProxy, null));
         doReturn(1L).when(mIncomingCall).getStartRingTime();
         doAnswer((x) -> {
             mCountDownLatch.countDown();
diff --git a/tests/src/com/android/server/telecom/tests/ParcelableCallUtilsTest.java b/tests/src/com/android/server/telecom/tests/ParcelableCallUtilsTest.java
index 57c6191..fed8084 100644
--- a/tests/src/com/android/server/telecom/tests/ParcelableCallUtilsTest.java
+++ b/tests/src/com/android/server/telecom/tests/ParcelableCallUtilsTest.java
@@ -13,7 +13,6 @@
 import android.net.Uri;
 import android.os.Bundle;
 import android.os.SystemClock;
-import android.os.UserHandle;
 import android.telecom.Connection;
 import android.telecom.ParcelableCall;
 import android.telecom.PhoneAccountHandle;
@@ -58,7 +57,6 @@
         when(mClockProxy.elapsedRealtime()).thenReturn(SystemClock.elapsedRealtime());
         when(mCallsManager.getCallerInfoLookupHelper()).thenReturn(mCallerInfoLookupHelper);
         when(mCallsManager.getPhoneAccountRegistrar()).thenReturn(mPhoneAccountRegistrar);
-        when(mCallsManager.getCurrentUserHandle()).thenReturn(UserHandle.CURRENT);
         when(mPhoneAccountRegistrar.getPhoneAccountUnchecked(any())).thenReturn(null);
         when(mComponentContextFixture.getTelephonyManager().isEmergencyNumber(any()))
                 .thenReturn(false);
@@ -77,8 +75,7 @@
                 false /* shouldAttachToExistingConnection */,
                 false /* isConference */,
                 mClockProxy /* ClockProxy */,
-                mToastProxy,
-                mFeatureFlags);
+                mToastProxy);
     }
 
     @Override
diff --git a/tests/src/com/android/server/telecom/tests/RingerTest.java b/tests/src/com/android/server/telecom/tests/RingerTest.java
index 9854384..baa4f90 100644
--- a/tests/src/com/android/server/telecom/tests/RingerTest.java
+++ b/tests/src/com/android/server/telecom/tests/RingerTest.java
@@ -147,8 +147,6 @@
         when(mockCall2.getState()).thenReturn(CallState.RINGING);
         when(mockCall1.getAssociatedUser()).thenReturn(PA_HANDLE.getUserHandle());
         when(mockCall2.getAssociatedUser()).thenReturn(PA_HANDLE.getUserHandle());
-        when(mockCall1.getTargetPhoneAccount()).thenReturn(PA_HANDLE);
-        when(mockCall2.getTargetPhoneAccount()).thenReturn(PA_HANDLE);
         // Set BT active state in tests to ensure that we do not end up blocking tests for 1 sec
         // waiting for BT to connect in unit tests by default.
         asyncRingtonePlayer.updateBtActiveState(true);
diff --git a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
index aa2cf56..33b0068 100644
--- a/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
+++ b/tests/src/com/android/server/telecom/tests/TelecomSystemTest.java
@@ -327,20 +327,6 @@
                                     PhoneAccount.CAPABILITY_PLACE_EMERGENCY_CALLS)
                     .build();
 
-    final PhoneAccount mPhoneAccountMultiUser =
-            PhoneAccount.builder(
-                            new PhoneAccountHandle(
-                                    mConnectionServiceComponentNameA,
-                                    "id MU", UserHandle.of(12)),
-                            "Phone account service MU")
-                    .addSupportedUriScheme("tel")
-                    .setCapabilities(
-                            PhoneAccount.CAPABILITY_CALL_PROVIDER |
-                                    PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION |
-                                    PhoneAccount.CAPABILITY_VIDEO_CALLING |
-                                    PhoneAccount.CAPABILITY_MULTI_USER)
-                    .build();
-
     ConnectionServiceFixture mConnectionServiceFixtureA;
     ConnectionServiceFixture mConnectionServiceFixtureB;
     Timeouts.Adapter mTimeoutsAdapter;
@@ -615,7 +601,6 @@
         mTelecomSystem.getPhoneAccountRegistrar().registerPhoneAccount(mPhoneAccountB0);
         mTelecomSystem.getPhoneAccountRegistrar().registerPhoneAccount(mPhoneAccountE0);
         mTelecomSystem.getPhoneAccountRegistrar().registerPhoneAccount(mPhoneAccountE1);
-        mTelecomSystem.getPhoneAccountRegistrar().registerPhoneAccount(mPhoneAccountMultiUser);
 
         mTelecomSystem.getPhoneAccountRegistrar().setUserSelectedOutgoingPhoneAccount(
                 mPhoneAccountA0.getAccountHandle(), Process.myUserHandle());
diff --git a/tests/src/com/android/server/telecom/tests/TransactionTests.java b/tests/src/com/android/server/telecom/tests/TransactionTests.java
index b35f88e..d733d9d 100644
--- a/tests/src/com/android/server/telecom/tests/TransactionTests.java
+++ b/tests/src/com/android/server/telecom/tests/TransactionTests.java
@@ -338,8 +338,7 @@
                 false /* shouldAttachToExistingConnection*/,
                 false /* isConference */,
                 mClockProxy,
-                mToastFactory,
-                mFeatureFlags);
+                mToastFactory);
 
         Call callSpy = Mockito.spy(call);