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

Commit 0cb205b6 authored by Henri Chataing's avatar Henri Chataing
Browse files

Flags 24Q4: Remove the flag a2dp_service_looper

Bug: 337348333
Test: m com.android.btservices
Flag: com.android.bluetooth.flags.a2dp_service_looper
Change-Id: I01be4670da5c225a4904a920a3dfde7ac7ee4f6b
parent 48cd179a
Loading
Loading
Loading
Loading
+1 −21
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@ public class A2dpService extends ProfileService {
    private final CompanionDeviceManager mCompanionDeviceManager;
    private final Looper mLooper;
    private final Handler mHandler;
    private final HandlerThread mStateMachinesThread;
    // Upper limit of all A2DP devices that are Connected or Connecting
    private final int mMaxConnectedAudioDevices;

@@ -108,9 +107,6 @@ public class A2dpService extends ProfileService {
    // Protect setActiveDevice()/removeActiveDevice() so all invoked is handled sequentially
    private final Object mActiveSwitchingGuard = new Object();

    // Timeout for state machine thread join, to prevent potential ANR.
    private static final int SM_THREAD_JOIN_TIMEOUT_MS = 1000;

    // Upper limit of all A2DP devices: Bonded or Connected
    private static final int MAX_A2DP_STATE_MACHINES = 50;
    // A2DP Offload Enabled in platform
@@ -137,13 +133,6 @@ public class A2dpService extends ProfileService {
        mMaxConnectedAudioDevices = mAdapterService.getMaxConnectedAudioDevices();
        Log.i(TAG, "Max connected audio devices set to " + mMaxConnectedAudioDevices);

        if (!Flags.a2dpServiceLooper()) {
            mStateMachinesThread = new HandlerThread("A2dpService.StateMachines");
            mStateMachinesThread.start();
        } else {
            mStateMachinesThread = null;
        }

        mA2dpCodecConfig = new A2dpCodecConfig(this, mNativeInterface);

        mNativeInterface.init(
@@ -200,15 +189,6 @@ public class A2dpService extends ProfileService {
            mStateMachines.clear();
        }

        if (mStateMachinesThread != null) {
            try {
                mStateMachinesThread.quitSafely();
                mStateMachinesThread.join(SM_THREAD_JOIN_TIMEOUT_MS);
            } catch (InterruptedException e) {
                // Do not rethrow as we are shutting down anyway
            }
        }

        mHandler.removeCallbacksAndMessages(null);
    }

@@ -1015,7 +995,7 @@ public class A2dpService extends ProfileService {
                            device,
                            mNativeInterface,
                            mA2dpOffloadEnabled,
                            Flags.a2dpServiceLooper() ? mLooper : mStateMachinesThread.getLooper());
                            mLooper);
            mStateMachines.put(device, sm);
            return sm;
        }
+4 −21
Original line number Diff line number Diff line
@@ -110,7 +110,6 @@ public class A2dpServiceTest {
    @Parameters(name = "{0}")
    public static List<FlagsParameterization> getParams() {
        return FlagsParameterization.allCombinationsOf(
                Flags.FLAG_A2DP_SERVICE_LOOPER,
                Flags.FLAG_A2DP_BROADCAST_CONNECTION_STATE_WHEN_TURNED_OFF);
    }

@@ -155,19 +154,11 @@ public class A2dpServiceTest {
        doReturn(new ParcelUuid[] {BluetoothUuid.A2DP_SINK})
                .when(mAdapterService)
                .getRemoteUuids(any(BluetoothDevice.class));

        if (!Flags.a2dpServiceLooper()) {
            mLooper.startAutoDispatch();
        }
    }

    @After
    public void tearDown() {
        if (Flags.a2dpServiceLooper()) {
        assertThat(mLooper.dispatchAll()).isEqualTo(0);
        } else {
            mLooper.stopAutoDispatchAndIgnoreExceptions();
        }
        mA2dpService.stop();
    }

@@ -333,7 +324,6 @@ public class A2dpServiceTest {

    /** Test that an outgoing connection times out */
    @Test
    @EnableFlags(Flags.FLAG_A2DP_SERVICE_LOOPER)
    public void testOutgoingConnectTimeout() {
        // Update the device priority so okToConnect() returns true
        when(mDatabaseManager.getProfileConnectionPolicy(sTestDevice, BluetoothProfile.A2DP))
@@ -654,7 +644,6 @@ public class A2dpServiceTest {
     * if the device is unbond.
     */
    @Test
    @EnableFlags(Flags.FLAG_A2DP_SERVICE_LOOPER)
    public void testDeleteStateMachineDisconnectEvents() {
        // Update the device priority so okToConnect() returns true
        when(mDatabaseManager.getProfileConnectionPolicy(sTestDevice, BluetoothProfile.A2DP))
@@ -1255,21 +1244,15 @@ public class A2dpServiceTest {
    // Dispatch messages for the A2dpService looper, and validate
    // that at least one message was handled.
    private void dispatchAtLeastOneMessage() {
        if (Flags.a2dpServiceLooper()) {
        assertThat(mLooper.dispatchAll()).isGreaterThan(0);
    }
    }

    // Validate that no messages are pending on the A2dpService looper.
    private void dispatchNoMessages() {
        if (Flags.a2dpServiceLooper()) {
        assertThat(mLooper.dispatchAll()).isEqualTo(0);
    }
    }

    private void moveTimeForward(long millis) {
        if (Flags.a2dpServiceLooper()) {
        mLooper.moveTimeForward(millis);
    }
}
}
+0 −10
Original line number Diff line number Diff line
package: "com.android.bluetooth.flags"
container: "com.android.btservices"

flag {
    name: "a2dp_service_looper"
    namespace: "bluetooth"
    description: "Inject looper into A2dpService"
    bug: "337348333"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "avdtp_error_codes"
    namespace: "bluetooth"