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

Commit 4fac27a6 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski Committed by Gerrit Code Review
Browse files

Merge changes I76c02e87,I4ee6039b

* changes:
  GTBS: Respect inband configuration
  LeAudioService: Read inband ringtone support from the flag
parents b1f046b8 b8c2d0dc
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -282,6 +282,9 @@ public class LeAudioService extends ProfileService {
        mTmapGattServer = LeAudioObjectsFactory.getInstance().getTmapGattServer(this);
        mTmapGattServer.start(tmapRoleMask);

        mLeAudioInbandRingtoneSupportedByPlatform =
                        BluetoothProperties.isLeAudioInbandRingtoneSupported().orElse(true);

        mAudioManager.registerAudioDeviceCallback(mAudioManagerAudioDeviceCallback,
                       mHandler);

@@ -3312,6 +3315,8 @@ public class LeAudioService extends ProfileService {
        ProfileService.println(sb, "  mActiveAudioOutDevice: " + mActiveAudioOutDevice);
        ProfileService.println(sb, "  mActiveAudioInDevice: " + mActiveAudioInDevice);
        ProfileService.println(sb, "  mHfpHandoverDevice:" + mHfpHandoverDevice);
        ProfileService.println(sb, "  mLeAudioIsInbandRingtoneSupported:"
                                + mLeAudioInbandRingtoneSupportedByPlatform);

        for (Map.Entry<BluetoothDevice, LeAudioDeviceDescriptor> entry
                : mDeviceDescriptors.entrySet()) {
+17 −2
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ import android.bluetooth.BluetoothGattCharacteristic;
import android.bluetooth.BluetoothGattDescriptor;
import android.bluetooth.BluetoothGattServerCallback;
import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.IBluetoothManager;
import android.bluetooth.IBluetoothStateChangeCallback;
import android.content.Context;
@@ -36,8 +35,8 @@ import android.os.ParcelUuid;
import android.os.RemoteException;
import android.util.Log;

import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.AdapterService;
import com.android.internal.annotations.VisibleForTesting;

import java.io.ByteArrayOutputStream;
@@ -154,6 +153,14 @@ public class TbsGatt {

        public abstract void onCallControlPointRequest(BluetoothDevice device, int opcode,
                byte[] args);

        /**
         * Check if device has enabled inband ringtone
         *
         * @param device device which is checked for inband ringtone availability
         * @return  {@code true} if enabled, {@code false} otherwise
         */
        public abstract boolean isInbandRingtoneEnabled(BluetoothDevice device);
    }

    TbsGatt(Context context) {
@@ -808,6 +815,14 @@ public class TbsGatt {
            if (value == null) {
                value = new byte[0];
            }
            /* TODO: Properly handle caching for multiple devices.
             * This patch assumes, LeAudio services just uses single value
             * for inband ringtone */
            if (characteristic.getUuid().equals(UUID_STATUS_FLAGS) && (value.length == 2)) {
                if (mCallback.isInbandRingtoneEnabled(device)) {
                    value[0] = (byte) (value[0] | STATUS_FLAG_INBAND_RINGTONE_ENABLED);
                }
            }

            int status;
            if (value.length < offset) {
+10 −3
Original line number Diff line number Diff line
@@ -192,9 +192,6 @@ public class TbsGeneric {
            mTbsGatt.clearSilentModeFlag();
        }

        // Android supports inband ringtone
        mTbsGatt.setInbandRingtoneFlag();

        mReceiver = new Receiver();
        mTbsGatt.getContext().registerReceiver(mReceiver,
                new IntentFilter(AudioManager.RINGER_MODE_CHANGED_ACTION));
@@ -751,6 +748,16 @@ public class TbsGeneric {
            }
        }

        @Override
        public boolean isInbandRingtoneEnabled(BluetoothDevice device) {
            if (!isLeAudioServiceAvailable()) {
                Log.i(TAG, "LeAudio service not available");
                return false;
            }
            int groupId = mLeAudioService.getGroupId(device);
            return mLeAudioService.isInbandRingtoneEnabled(groupId);
        }

        @Override
        public void onCallControlPointRequest(BluetoothDevice device, int opcode, byte[] args) {
            synchronized (TbsGeneric.this) {
+12 −0
Original line number Diff line number Diff line
@@ -558,6 +558,18 @@ public class TbsGattTest {
                aryEq(new byte[] {0x0A}));
    }

    @Test
    public void testHandleIsInbandRingtoneEnabled() {
        prepareDefaultService();
        BluetoothGattCharacteristic characteristic =
                getCharacteristic(TbsGatt.UUID_STATUS_FLAGS);

        mTbsGatt.mGattServerCallback.onCharacteristicReadRequest(mCurrentDevice, 1, 0,
                characteristic);
        // Verify the higher layer callback call
        verify(mMockTbsGattCallback).isInbandRingtoneEnabled(eq(mCurrentDevice));
    }

    @Test
    public void testClientCharacteristicConfiguration() {
        prepareDefaultService();