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

Commit a226e91a authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8937168 from ecff95ce to tm-qpr1-release

Change-Id: I7a9241e62ca917b4b4e8eff27a7c45dd4e3ed2a1
parents 4ddebc70 ecff95ce
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -85,6 +85,7 @@
    <integer name="a2dp_source_codec_priority_aptx_hd">4001</integer>
    <integer name="a2dp_source_codec_priority_ldac">5001</integer>
    <integer name="a2dp_source_codec_priority_lc3">6001</integer>
    <integer name="a2dp_source_codec_priority_opus">7001</integer>

    <!-- For enabling the AVRCP Target Cover Artowrk feature-->
    <bool name="avrcp_target_enable_cover_art">true</bool>
+23 −5
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@ class A2dpCodecConfig {
    private static final boolean DBG = true;
    private static final String TAG = "A2dpCodecConfig";

    // TODO(b/240635097): remove in U
    private static final int SOURCE_CODEC_TYPE_OPUS = 6;

    private Context mContext;
    private A2dpNativeInterface mA2dpNativeInterface;

@@ -53,6 +56,8 @@ class A2dpCodecConfig {
            BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
    private @CodecPriority int mA2dpSourceCodecPriorityLc3 =
            BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
    private @CodecPriority int mA2dpSourceCodecPriorityOpus =
            BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;

    private BluetoothCodecConfig[] mCodecConfigOffloading = new BluetoothCodecConfig[0];

@@ -243,6 +248,16 @@ class A2dpCodecConfig {
            mA2dpSourceCodecPriorityLc3 = value;
        }

        try {
            value = resources.getInteger(R.integer.a2dp_source_codec_priority_opus);
        } catch (NotFoundException e) {
            value = BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT;
        }
        if ((value >= BluetoothCodecConfig.CODEC_PRIORITY_DISABLED) && (value
                < BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST)) {
            mA2dpSourceCodecPriorityOpus = value;
        }

        BluetoothCodecConfig codecConfig;
        BluetoothCodecConfig[] codecConfigArray =
                new BluetoothCodecConfig[6];
@@ -272,8 +287,9 @@ class A2dpCodecConfig {
                .build();
        codecConfigArray[4] = codecConfig;
        codecConfig = new BluetoothCodecConfig.Builder()
                .setCodecType(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3)
                .setCodecPriority(mA2dpSourceCodecPriorityLc3)
                // TODO(b/240635097): update in U
                .setCodecType(SOURCE_CODEC_TYPE_OPUS)
                .setCodecPriority(mA2dpSourceCodecPriorityOpus)
                .build();
        codecConfigArray[5] = codecConfig;

@@ -282,14 +298,16 @@ class A2dpCodecConfig {

    public void switchCodecByBufferSize(
            BluetoothDevice device, boolean isLowLatency, int currentCodecType) {
        if ((isLowLatency && currentCodecType == BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3)
        || (!isLowLatency && currentCodecType != BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3)) {
        // TODO(b/240635097): update in U
        if ((isLowLatency && currentCodecType == SOURCE_CODEC_TYPE_OPUS)
                || (!isLowLatency && currentCodecType != SOURCE_CODEC_TYPE_OPUS)) {
            return;
        }
        BluetoothCodecConfig[] codecConfigArray = assignCodecConfigPriorities();
        for (int i = 0; i < codecConfigArray.length; i++){
            BluetoothCodecConfig codecConfig = codecConfigArray[i];
            if (codecConfig.getCodecType() == BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3) {
            // TODO(b/240635097): update in U
            if (codecConfig.getCodecType() == SOURCE_CODEC_TYPE_OPUS) {
                if (isLowLatency) {
                    codecConfig.setCodecPriority(BluetoothCodecConfig.CODEC_PRIORITY_HIGHEST);
                } else {
+10 −0
Original line number Diff line number Diff line
@@ -76,6 +76,9 @@ final class A2dpStateMachine extends StateMachine {
    private static final boolean DBG = true;
    private static final String TAG = "A2dpStateMachine";

    // TODO(b/240635097): remove in U
    private static final int SOURCE_CODEC_TYPE_OPUS = 6;

    static final int CONNECT = 1;
    static final int DISCONNECT = 2;
    @VisibleForTesting
@@ -666,6 +669,13 @@ final class A2dpStateMachine extends StateMachine {
                    && (prevCodecConfig.getCodecSpecific1()
                        != newCodecConfig.getCodecSpecific1())) {
                update = true;
            } else if ((newCodecConfig.getCodecType()
                        == SOURCE_CODEC_TYPE_OPUS) // TODO(b/240635097): update in U
                    && (prevCodecConfig != null)
                    // check framesize field
                    && (prevCodecConfig.getCodecSpecific1()
                        != newCodecConfig.getCodecSpecific1())) {
                update = true;
            }
            if (update) {
                mA2dpService.codecConfigUpdated(mDevice, mCodecStatus, false);
+30 −28
Original line number Diff line number Diff line
@@ -713,11 +713,11 @@ public class BluetoothInCallService extends InCallService {
        }

        BluetoothCall conferenceCall = getBluetoothCallById(call.getParentId());
        if (!mCallInfo.isNullCall(conferenceCall)
                && conferenceCall.hasProperty(Call.Details.PROPERTY_GENERIC_CONFERENCE)) {
        if (!mCallInfo.isNullCall(conferenceCall)) {
            isPartOfConference = true;

            // Run some alternative states for Conference-level merge/swap support.
            if (conferenceCall.hasProperty(Call.Details.PROPERTY_GENERIC_CONFERENCE)) {
                // Run some alternative states for CDMA Conference-level merge/swap support.
                // Basically, if BluetoothCall supports swapping or merging at the conference-level,
                // then we need to expose the calls as having distinct states
                // (ACTIVE vs CAPABILITY_HOLD) or
@@ -726,7 +726,8 @@ public class BluetoothInCallService extends InCallService {
                // Before doing any special logic, ensure that we are dealing with an
                // ACTIVE BluetoothCall and that the conference itself has a notion of
                // the current "active" child call.
            BluetoothCall activeChild = getBluetoothCallById(
                BluetoothCall activeChild =
                        getBluetoothCallById(
                                conferenceCall.getGenericConferenceActiveChildCallId());
                if (state == CALL_STATE_ACTIVE && !mCallInfo.isNullCall(activeChild)) {
                    // Reevaluate state if we can MERGE or if we can SWAP without previously having
@@ -741,12 +742,13 @@ public class BluetoothInCallService extends InCallService {
                        if (call == activeChild) {
                            state = CALL_STATE_ACTIVE;
                        } else {
                        // At this point we know there is an "active" child and we know that it is
                        // not this call, so set it to HELD instead.
                            // At this point we know there is an "active" child and we know that it
                            // is not this call, so set it to HELD instead.
                            state = CALL_STATE_HELD;
                        }
                    }
                }
            }
            if (conferenceCall.getState() == Call.STATE_HOLDING
                    && conferenceCall.can(Connection.CAPABILITY_MANAGE_CONFERENCE)) {
                // If the parent IMS CEP conference BluetoothCall is on hold, we should mark
+36 −24
Original line number Diff line number Diff line
@@ -44,6 +44,10 @@ import java.util.Arrays;
@MediumTest
@RunWith(AndroidJUnit4.class)
public class A2dpCodecConfigTest {

    // TODO(b/240635097): remove in U
    private static final int SOURCE_CODEC_TYPE_OPUS = 6;

    private Context mTargetContext;
    private BluetoothDevice mTestDevice;
    private A2dpCodecConfig mA2dpCodecConfig;
@@ -57,7 +61,7 @@ public class A2dpCodecConfigTest {
            BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX,
            BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD,
            BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC,
            BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3
            SOURCE_CODEC_TYPE_OPUS // TODO(b/240635097): update in U
    };

    // Not use the default value to make sure it reads from config
@@ -67,6 +71,7 @@ public class A2dpCodecConfigTest {
    private static final int APTX_HD_PRIORITY_DEFAULT = 7001;
    private static final int LDAC_PRIORITY_DEFAULT = 9001;
    private static final int LC3_PRIORITY_DEFAULT = 11001;
    private static final int OPUS_PRIORITY_DEFAULT = 13001;
    private static final int PRIORITY_HIGH = 1000000;

    private static final BluetoothCodecConfig[] sCodecCapabilities = new BluetoothCodecConfig[] {
@@ -108,13 +113,11 @@ public class A2dpCodecConfigTest {
                                     | BluetoothCodecConfig.BITS_PER_SAMPLE_32,
                                     BluetoothCodecConfig.CHANNEL_MODE_STEREO,
                                     0, 0, 0, 0),       // Codec-specific fields
            buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3,
                                     LC3_PRIORITY_DEFAULT,
                                     BluetoothCodecConfig.SAMPLE_RATE_44100
                                     | BluetoothCodecConfig.SAMPLE_RATE_48000,
            buildBluetoothCodecConfig(SOURCE_CODEC_TYPE_OPUS, // TODO(b/240635097): update in U
                                     OPUS_PRIORITY_DEFAULT,
                                     BluetoothCodecConfig.SAMPLE_RATE_48000,
                                     BluetoothCodecConfig.BITS_PER_SAMPLE_16,
                                     BluetoothCodecConfig.CHANNEL_MODE_MONO
                                     | BluetoothCodecConfig.CHANNEL_MODE_STEREO,
                                     BluetoothCodecConfig.CHANNEL_MODE_STEREO,
                                     0, 0, 0, 0)        // Codec-specific fields
    };

@@ -149,8 +152,8 @@ public class A2dpCodecConfigTest {
                                     BluetoothCodecConfig.BITS_PER_SAMPLE_32,
                                     BluetoothCodecConfig.CHANNEL_MODE_STEREO,
                                     0, 0, 0, 0),       // Codec-specific fields
            buildBluetoothCodecConfig(BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3,
                                     LC3_PRIORITY_DEFAULT,
            buildBluetoothCodecConfig(SOURCE_CODEC_TYPE_OPUS, // TODO(b/240635097): update in U
                                     OPUS_PRIORITY_DEFAULT,
                                     BluetoothCodecConfig.SAMPLE_RATE_48000,
                                     BluetoothCodecConfig.BITS_PER_SAMPLE_16,
                                     BluetoothCodecConfig.CHANNEL_MODE_STEREO,
@@ -174,8 +177,8 @@ public class A2dpCodecConfigTest {
                .thenReturn(APTX_HD_PRIORITY_DEFAULT);
        when(mMockResources.getInteger(R.integer.a2dp_source_codec_priority_ldac))
                .thenReturn(LDAC_PRIORITY_DEFAULT);
        when(mMockResources.getInteger(R.integer.a2dp_source_codec_priority_lc3))
                .thenReturn(LC3_PRIORITY_DEFAULT);
        when(mMockResources.getInteger(R.integer.a2dp_source_codec_priority_opus))
                .thenReturn(OPUS_PRIORITY_DEFAULT);

        mA2dpCodecConfig = new A2dpCodecConfig(mMockContext, mA2dpNativeInterface);
        mTestDevice = BluetoothAdapter.getDefaultAdapter().getRemoteDevice("00:01:02:03:04:05");
@@ -209,8 +212,8 @@ public class A2dpCodecConfigTest {
                case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC:
                    Assert.assertEquals(config.getCodecPriority(), LDAC_PRIORITY_DEFAULT);
                    break;
                case BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3:
                    Assert.assertEquals(config.getCodecPriority(), LC3_PRIORITY_DEFAULT);
                case SOURCE_CODEC_TYPE_OPUS: // TODO(b/240635097): update in U
                    Assert.assertEquals(config.getCodecPriority(), OPUS_PRIORITY_DEFAULT);
                    break;
            }
        }
@@ -242,8 +245,9 @@ public class A2dpCodecConfigTest {
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC, PRIORITY_HIGH,
                true);
        testCodecPriorityChangeHelper(
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3, LC3_PRIORITY_DEFAULT,
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3, PRIORITY_HIGH,
                // TODO(b/240635097): update in U
                SOURCE_CODEC_TYPE_OPUS, OPUS_PRIORITY_DEFAULT,
                SOURCE_CODEC_TYPE_OPUS, PRIORITY_HIGH,
                false);
    }

@@ -255,27 +259,33 @@ public class A2dpCodecConfigTest {
    public void testSetCodecPreference_priorityDefaultToRaiseHigh() {
        testCodecPriorityChangeHelper(
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, PRIORITY_HIGH,
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3, LC3_PRIORITY_DEFAULT,
                // TODO(b/240635097): update in U
                SOURCE_CODEC_TYPE_OPUS, OPUS_PRIORITY_DEFAULT,
                true);
        testCodecPriorityChangeHelper(
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, PRIORITY_HIGH,
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3, LC3_PRIORITY_DEFAULT,
                // TODO(b/240635097): update in U
                SOURCE_CODEC_TYPE_OPUS, OPUS_PRIORITY_DEFAULT,
                true);
        testCodecPriorityChangeHelper(
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX, PRIORITY_HIGH,
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3, LC3_PRIORITY_DEFAULT,
                // TODO(b/240635097): update in U
                SOURCE_CODEC_TYPE_OPUS, OPUS_PRIORITY_DEFAULT,
                true);
        testCodecPriorityChangeHelper(
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD, PRIORITY_HIGH,
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3, LC3_PRIORITY_DEFAULT,
                // TODO(b/240635097): update in U
                SOURCE_CODEC_TYPE_OPUS, OPUS_PRIORITY_DEFAULT,
                true);
        testCodecPriorityChangeHelper(
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC, PRIORITY_HIGH,
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3, LC3_PRIORITY_DEFAULT,
                // TODO(b/240635097): update in U
                SOURCE_CODEC_TYPE_OPUS, OPUS_PRIORITY_DEFAULT,
                true);
        testCodecPriorityChangeHelper(
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3, PRIORITY_HIGH,
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3, LC3_PRIORITY_DEFAULT,
                // TODO(b/240635097): update in U
                SOURCE_CODEC_TYPE_OPUS, PRIORITY_HIGH,
                SOURCE_CODEC_TYPE_OPUS, OPUS_PRIORITY_DEFAULT,
                false);
    }

@@ -302,7 +312,8 @@ public class A2dpCodecConfigTest {
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, PRIORITY_HIGH,
                true);
        testCodecPriorityChangeHelper(
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3, PRIORITY_HIGH,
                // TODO(b/240635097): update in U
                SOURCE_CODEC_TYPE_OPUS, PRIORITY_HIGH,
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC, PRIORITY_HIGH,
                true);
    }
@@ -330,7 +341,8 @@ public class A2dpCodecConfigTest {
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, PRIORITY_HIGH,
                true);
        testCodecPriorityChangeHelper(
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_LC3, PRIORITY_HIGH,
                // TODO(b/240635097): update in U
                SOURCE_CODEC_TYPE_OPUS, PRIORITY_HIGH,
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC, PRIORITY_HIGH,
                true);
    }
Loading