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

Commit 74c23649 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "BassClient: Respect forbidden connection policy" am: b9e4b63e

parents 2ea96d86 b9e4b63e
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.bluetooth.bass_client;

import static android.Manifest.permission.BLUETOOTH_CONNECT;

import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission;

import android.bluetooth.BluetoothAdapter;
@@ -49,7 +50,6 @@ import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.ProfileService;
import com.android.internal.annotations.VisibleForTesting;

import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -394,8 +394,8 @@ public class BassClientService extends ProfileService {
            Log.e(TAG, "connect: device is null");
            return false;
        }
        if (getConnectionPolicy(device) == BluetoothProfile.CONNECTION_POLICY_UNKNOWN) {
            Log.e(TAG, "connect: unknown connection policy");
        if (getConnectionPolicy(device) == BluetoothProfile.CONNECTION_POLICY_FORBIDDEN) {
            Log.e(TAG, "connect: connection policy set to forbidden");
            return false;
        }
        synchronized (mStateMachines) {
+3 −3
Original line number Diff line number Diff line
@@ -181,14 +181,14 @@ public class BassClientServiceTest {
    }

    /**
     * Test connecting to a device when the connection policy is unknown.
     * Test connecting to a device when the connection policy is forbidden.
     *  - service.connect() should return false.
     */
    @Test
    public void testConnect_whenConnectionPolicyIsUnknown() {
    public void testConnect_whenConnectionPolicyIsForbidden() {
        when(mDatabaseManager.getProfileConnectionPolicy(any(BluetoothDevice.class),
                eq(BluetoothProfile.LE_AUDIO_BROADCAST_ASSISTANT)))
                .thenReturn(BluetoothProfile.CONNECTION_POLICY_UNKNOWN);
                .thenReturn(BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
        mCurrentDevice = TestUtils.getTestDevice(mBluetoothAdapter, 0);
        assertThat(mCurrentDevice).isNotNull();