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

Commit 3f31a6ce authored by Pavel Maltsev's avatar Pavel Maltsev
Browse files

Ignore incoming A2DP if profile is disabled

If profile was disabled (PRIORITY_OFF), it should not accept
incoming connections. A2DP source currently respects priority off, in
A2dpService.isOkToConnect(), but A2DP sink silently accepts incoming
connection.

Bug: 140590407
Test: connect phone with Automotive OS (it implements sink
profile). Disable A2DP from settings in Automotive OS, try to
connect from the phone side - verify A2DP remains disconnected.

Change-Id: I2c385f098ba5dca7ba3d51c2855ed8b22989a15c
parent 4e3ae054
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@
 */
package com.android.bluetooth.a2dpsink;

import static android.bluetooth.BluetoothProfile.PRIORITY_OFF;

import android.bluetooth.BluetoothA2dpSink;
import android.bluetooth.BluetoothAudioConfig;
import android.bluetooth.BluetoothDevice;
@@ -168,6 +170,15 @@ public class A2dpSinkStateMachine extends StateMachine {
            switch (event.mType) {
                case StackEvent.EVENT_TYPE_CONNECTION_STATE_CHANGED:
                    switch (event.mState) {
                        case StackEvent.CONNECTION_STATE_CONNECTING:
                            if (mService.getPriority(mDevice) == PRIORITY_OFF) {
                                Log.w(TAG, "Ignore incoming connection, profile is"
                                        + " turned off for " + mDevice);
                                mService.disconnectA2dpNative(mDeviceAddress);
                            } else {
                                transitionTo(mConnecting);
                            }
                            break;
                        case StackEvent.CONNECTION_STATE_CONNECTED:
                            transitionTo(mConnected);
                            break;