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

Commit 75fe1574 authored by Grzegorz Kołodziejczyk's avatar Grzegorz Kołodziejczyk
Browse files

LeAudioService: Ignore store of intents when LeAudioService is inactive

There is possibility that in test teardown an intent may come which will
be stored on device queue to parse in test. When there is no service,
this intent should be ignored.

Tag: #feature
Test: atest GoogleBluetoothInstrumentationTests:com.android.bluetooth.le_audio.LeAudioServiceTest#testDump_doesNotCrash -- --abi x86_64
Bug: 299431664
Change-Id: I0f2ca423c80150920e27d67a55ade2e0eb33af0b
parent 373e5fbd
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -258,6 +258,11 @@ public class LeAudioServiceTest {
    private class LeAudioIntentReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            /* Ignore intent when service is inactive */
            if (mService == null) {
                return;
            }

            if (BluetoothLeAudio.ACTION_LE_AUDIO_CONNECTION_STATE_CHANGED
                    .equals(intent.getAction())) {
                try {
@@ -271,8 +276,8 @@ public class LeAudioServiceTest {
                    assertWithMessage("Cannot add Intent to the Connection State queue: "
                            + e.getMessage()).fail();
                }
            }
            if (BluetoothLeAudio.ACTION_LE_AUDIO_ACTIVE_DEVICE_CHANGED.equals(intent.getAction())) {
            } else if (BluetoothLeAudio.ACTION_LE_AUDIO_ACTIVE_DEVICE_CHANGED.equals(
                    intent.getAction())) {
                try {
                    BluetoothDevice device = intent.getParcelableExtra(
                            BluetoothDevice.EXTRA_DEVICE);