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

Commit 0100b4d6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Call audio routing performance improvment" into main

parents e0666863 6b8a2726
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -195,3 +195,14 @@ flag {
    purpose: PURPOSE_BUGFIX
  }
}

# OWNER=pmadapurmath TARGET=25Q3
flag {
  name: "call_audio_routing_performance_improvemenent"
  namespace: "telecom"
  description: "Change the handler to use the main looper to improve performance with processing messages from the message queue"
  bug: "383466267"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}
+8 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.media.IAudioService;
import android.media.audiopolicy.AudioProductStrategy;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.telecom.CallAudioState;
@@ -213,7 +214,9 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {

        mTelecomLock = callsManager.getLock();
        HandlerThread handlerThread = new HandlerThread(this.getClass().getSimpleName());
        if (!mFeatureFlags.callAudioRoutingPerformanceImprovemenent()) {
            handlerThread.start();
        }

        // Register broadcast receivers
        if (!mFeatureFlags.newAudioPathSpeakerBroadcastAndUnfocusedRouting()) {
@@ -253,8 +256,11 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
            }
        };

        Looper looper = mFeatureFlags.callAudioRoutingPerformanceImprovemenent()
                ? Looper.getMainLooper()
                : handlerThread.getLooper();
        // Create handler
        mHandler = new Handler(handlerThread.getLooper()) {
        mHandler = new Handler(looper) {
            @Override
            public void handleMessage(@NonNull Message msg) {
                synchronized (this) {
+7 −2
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ import android.media.AudioDeviceInfo;
import android.media.AudioManager;
import android.media.IAudioService;
import android.media.audiopolicy.AudioProductStrategy;
import android.os.Looper;
import android.os.UserHandle;
import android.telecom.CallAudioState;
import android.telecom.VideoProfile;
@@ -216,13 +217,17 @@ public class CallAudioRouteControllerTest extends TelecomTestCase {
        when(mFeatureFlags.resolveActiveBtRoutingAndBtTimingIssue()).thenReturn(false);
        when(mFeatureFlags.newAudioPathSpeakerBroadcastAndUnfocusedRouting()).thenReturn(false);
        when(mFeatureFlags.fixUserRequestBaselineRouteVideoCall()).thenReturn(false);
        when(mFeatureFlags.callAudioRoutingPerformanceImprovemenent()).thenReturn(true);
        BLUETOOTH_DEVICES.add(BLUETOOTH_DEVICE_1);
    }

    @After
    public void tearDown() throws Exception {
        Looper looper = mController.getAdapterHandler().getLooper();
        if (looper != Looper.getMainLooper()) {
            mController.getAdapterHandler().getLooper().quit();
            mController.getAdapterHandler().getLooper().getThread().join();
        }
        BLUETOOTH_DEVICES.clear();
        super.tearDown();
    }