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

Commit a1be3556 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

McpService: Align with AVRCP behavior.

With this patch, base media control opcodes are always send up to the
player and are always exposed over SUPPORTED OPCODES characteristic.
This is to match AVRCP and workaround the issue with player being not
registered on time when LE HS connects when player is already started.

Bug: 312324138
Test: atest MediaControlGattServiceTest
Tag: feature
Flag: Exempt, LeAudio feature to match BR/EDR functionality
Change-Id: I1520712beca2abff693cce1b1b380e021c8c6cae
parent 89f6c846
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
 * Copyright 2021 HIMSA II K/S - www.himsa.com.
 * Represented by EHIMA - www.ehima.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * Licensed under the Apache License,mu Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
@@ -129,6 +129,17 @@ public class MediaControlGattService implements MediaControlGattServiceInterface

    private static final int INTERVAL_UNAVAILABLE = 0xFFFFFFFF;

    /* This is to match AVRCP behavior */
    @VisibleForTesting
    static final int INITIAL_SUPPORTED_OPCODES =
            Request.SupportedOpcodes.PLAY
                    | Request.SupportedOpcodes.STOP
                    | Request.SupportedOpcodes.PAUSE
                    | Request.SupportedOpcodes.FAST_REWIND
                    | Request.SupportedOpcodes.FAST_FORWARD
                    | Request.SupportedOpcodes.NEXT_TRACK
                    | Request.SupportedOpcodes.PREVIOUS_TRACK;

    private final int mCcid;
    private Map<String, Map<UUID, Short>> mCccDescriptorValues = new HashMap<>();
    private long mFeatures;
@@ -1034,7 +1045,7 @@ public class MediaControlGattService implements MediaControlGattServiceInterface
        updateSeekingSpeedChar(1, notify);
        updatePlayingOrderSupportedChar(SupportedPlayingOrder.SINGLE_ONCE);
        updatePlayingOrderChar(PlayingOrder.SINGLE_ONCE, notify);
        updateSupportedOpcodesChar(Request.SupportedOpcodes.NONE, notify);
        updateSupportedOpcodesChar(INITIAL_SUPPORTED_OPCODES, notify);
    }

    private void setInitialCharacteristicValues() {
+4 −2
Original line number Diff line number Diff line
@@ -355,8 +355,10 @@ public class MediaControlGattServiceTest {
        Assert.assertEquals(characteristic.getProperties(),
                BluetoothGattCharacteristic.PROPERTY_READ
                        | BluetoothGattCharacteristic.PROPERTY_NOTIFY);
        Assert.assertEquals(Request.SupportedOpcodes.NONE,
                characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT32, 0)
        Assert.assertEquals(
                MediaControlGattService.INITIAL_SUPPORTED_OPCODES,
                characteristic
                        .getIntValue(BluetoothGattCharacteristic.FORMAT_UINT32, 0)
                        .intValue());

        characteristic = service.getCharacteristic(