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

Commit 23676d8f authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Improve active device handling

If active state for the group has not changed,
do not send intent that it has changed to the system.

Bug: 150670922
Tag: #feature
Sponsor: jpawlowski@
Test: manual
Change-Id: Ibd05948e63bde58c8012dfb3c952605062fbf4b7
parent 8c4e5f0a
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -976,6 +976,7 @@ public class LeAudioService extends ProfileService {
        } else if (stackEvent.type == LeAudioStackEvent.EVENT_TYPE_GROUP_STATUS_CHANGED) {
            int group_id = stackEvent.valueInt1;
            int group_status = stackEvent.valueInt2;
            boolean send_intent = false;

            switch (group_status) {
                case LeAudioStackEvent.GROUP_STATUS_ACTIVE: {
@@ -985,6 +986,7 @@ public class LeAudioService extends ProfileService {
                            descriptor.mIsActive = true;
                            updateActiveDevices(group_id, ACTIVE_CONTEXTS_NONE,
                                                descriptor.mActiveContexts, descriptor.mIsActive);
                            send_intent = true;
                        }
                    } else {
                        Log.e(TAG, "no descriptors for group: " + group_id);
@@ -998,6 +1000,7 @@ public class LeAudioService extends ProfileService {
                            descriptor.mIsActive = false;
                            updateActiveDevices(group_id, descriptor.mActiveContexts,
                                    ACTIVE_CONTEXTS_NONE, descriptor.mIsActive);
                            send_intent = true;
                        }
                    } else {
                        Log.e(TAG, "no descriptors for group: " + group_id);
@@ -1008,10 +1011,11 @@ public class LeAudioService extends ProfileService {
                    break;
            }

            if (send_intent) {
                intent = new Intent(BluetoothLeAudio.ACTION_LE_AUDIO_GROUP_STATUS_CHANGED);
                intent.putExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_ID, group_id);
                intent.putExtra(BluetoothLeAudio.EXTRA_LE_AUDIO_GROUP_STATUS, group_status);

            }
        }

        if (intent != null) {