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

Commit f20e8364 authored by Henri Chataing's avatar Henri Chataing Committed by Automerger Merge Worker
Browse files

Generate CONNECTION_STATE_CHANGED intent when A2dpService is stopped am: 6657bd97

parents aa1d02af 6657bd97
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.MetricsLogger;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.flags.Flags;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
@@ -125,9 +126,16 @@ final class A2dpStateMachine extends StateMachine {

    public void doQuit() {
        log("doQuit for device " + mDevice);
        if (Flags.a2dpBroadcastConnectionStateWhenTurnedOff()
                && mConnectionState != BluetoothProfile.STATE_DISCONNECTED
                && mLastConnectionState != -1) {
            // Broadcast CONNECTION_STATE_CHANGED when A2dpService is turned off while
            // the device is connected
            broadcastConnectionState(BluetoothProfile.STATE_DISCONNECTED, mConnectionState);
        }
        if (mIsPlaying) {
            // Stop if auido is still playing
            log("doQuit: stopped playing " + mDevice);
            // Broadcast AUDIO_STATE_CHANGED when A2dpService is turned off while
            // the device is playing
            mIsPlaying = false;
            broadcastAudioState(BluetoothA2dp.STATE_NOT_PLAYING, BluetoothA2dp.STATE_PLAYING);
        }
+12 −1
Original line number Diff line number Diff line
@@ -104,7 +104,9 @@ public class A2dpServiceTest {

    @Parameters(name = "{0}")
    public static List<FlagsParameterization> getParams() {
        return FlagsParameterization.allCombinationsOf(Flags.FLAG_A2DP_SERVICE_LOOPER);
        return FlagsParameterization.allCombinationsOf(
                Flags.FLAG_A2DP_SERVICE_LOOPER,
                Flags.FLAG_A2DP_BROADCAST_CONNECTION_STATE_WHEN_TURNED_OFF);
    }

    public A2dpServiceTest(FlagsParameterization flags) {
@@ -198,6 +200,15 @@ public class A2dpServiceTest {
        mA2dpService.stop();
        dispatchAtLeastOneMessage();

        if (Flags.a2dpBroadcastConnectionStateWhenTurnedOff()) {
            // Verify that the intent CONNECTION_STATE_CHANGED is generated
            // for the existing connections.
            verifyConnectionStateIntent(
                    sTestDevice,
                    BluetoothProfile.STATE_DISCONNECTED,
                    BluetoothProfile.STATE_CONNECTED);
        }

        // Verify that setActiveDevice(null) was called during shutdown
        verify(mMockNativeInterface).setActiveDevice(null);
        mA2dpService.start();