Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 67daa9ee authored by Pranav Madapurmath's avatar Pranav Madapurmath
Browse files

Ensure ICS receives call endpoint change when connected.

When setting up a call, sometimes InCallController#onCallEndpointChanged
is invoked before InCallService connected, and result that
InCallService#onCallEndpointChanged can not be notified to update
CallEndpoint info.

It is timing issue, the sequence can not be fixed. So when InCallService
is connected, invoke InCallService#onCallEndpointChanged again.

Bug: 348297436
Test: Manual call, atest InCallControllerTests
Flag: com.android.server.telecom.flags.on_call_endpoint_changed_ics_on_connected

Change-Id: I015715e8485713a9ab520be0a0be6611a1d9a933
parent 413076ef
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -24,3 +24,11 @@ flag {
  description: "Binding/Unbinding to BluetoothInCallServices in proper time to improve call audio"
  bug: "306395598"
}

# OWNER=pmadapurmath TARGET=24Q4
flag {
  name: "on_call_endpoint_changed_ics_on_connected"
  namespace: "telecom"
  description: "Ensure onCallEndpointChanged is sent to ICS when it connects."
  bug: "348297436"
}
+4 −0
Original line number Diff line number Diff line
@@ -2587,6 +2587,10 @@ public class InCallController extends CallsManagerListenerBase implements
        try {
            inCallService.onCallAudioStateChanged(mCallsManager.getAudioState());
            inCallService.onCanAddCallChanged(mCallsManager.canAddCall());
            if (mFeatureFlags.onCallEndpointChangedIcsOnConnected()) {
                inCallService.onCallEndpointChanged(mCallsManager.getCallEndpointController()
                        .getCurrentCallEndpoint());
            }
        } catch (RemoteException ignored) {
        }
        // Don't complete the binding future for non-ui incalls
+7 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.permission.PermissionCheckerManager;
import android.telecom.CallAudioState;
import android.telecom.CallEndpoint;
import android.telecom.InCallService;
import android.telecom.ParcelableCall;
import android.telecom.PhoneAccountHandle;
@@ -95,6 +96,7 @@ import com.android.internal.telecom.IInCallService;
import com.android.server.telecom.Analytics;
import com.android.server.telecom.AnomalyReporterAdapter;
import com.android.server.telecom.Call;
import com.android.server.telecom.CallEndpointController;
import com.android.server.telecom.CallsManager;
import com.android.server.telecom.CarModeTracker;
import com.android.server.telecom.ClockProxy;
@@ -157,6 +159,7 @@ public class InCallControllerTests extends TelecomTestCase {
    @Mock UserManager mMockUserManager;
    @Mock Context mMockCreateContextAsUser;
    @Mock UserManager mMockCurrentUserManager;
    @Mock CallEndpointController mMockCallEndpointController;

    @Rule
    public TestRule compatChangeRule = new PlatformCompatChangeRule();
@@ -307,6 +310,10 @@ public class InCallControllerTests extends TelecomTestCase {
                .thenReturn(PackageManager.PERMISSION_DENIED);

        when(mMockCallsManager.getAudioState()).thenReturn(new CallAudioState(false, 0, 0));
        when(mFeatureFlags.onCallEndpointChangedIcsOnConnected()).thenReturn(true);
        when(mMockCallsManager.getCallEndpointController()).thenReturn(mMockCallEndpointController);
        when(mMockCallEndpointController.getCurrentCallEndpoint())
                .thenReturn(new CallEndpoint("Earpiece", 1));

        when(mMockContext.getSystemService(eq(Context.USER_SERVICE))).thenReturn(mMockUserManager);
        when(mMockContext.getSystemService(eq(UserManager.class)))