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

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

Snap for 10402374 from 4e41376a to udc-qpr1-release

Change-Id: I63b4bfeb670d4f5e56aa20249c111b03759fd5d3
parents 350ddc67 4e41376a
Loading
Loading
Loading
Loading
+39 −2
Original line number Original line Diff line number Diff line
@@ -58,6 +58,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.Message;
import android.util.Log;
import android.util.Log;


import com.android.bluetooth.BluetoothStatsLog;
import com.android.bluetooth.Utils;
import com.android.bluetooth.Utils;
import com.android.bluetooth.btservice.MetricsLogger;
import com.android.bluetooth.btservice.MetricsLogger;
import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.btservice.ProfileService;
@@ -169,6 +170,8 @@ final class A2dpStateMachine extends StateMachine {
                                        BluetoothA2dp.STATE_PLAYING);
                                        BluetoothA2dp.STATE_PLAYING);
                }
                }
            }
            }

            logFailureIfNeeded();
        }
        }


        @Override
        @Override
@@ -260,6 +263,26 @@ final class A2dpStateMachine extends StateMachine {
                    break;
                    break;
            }
            }
        }
        }

        private void logFailureIfNeeded() {
            if (mLastConnectionState == BluetoothProfile.STATE_CONNECTING
                    || mLastConnectionState == BluetoothProfile.STATE_DISCONNECTED) {
                // Result for disconnected -> disconnected is unknown as it should
                // not have occurred.
                int result =
                        (mLastConnectionState == BluetoothProfile.STATE_CONNECTING)
                                ? BluetoothProtoEnums.RESULT_FAILURE
                                : BluetoothProtoEnums.RESULT_UNKNOWN;

                BluetoothStatsLog.write(
                        BluetoothStatsLog.BLUETOOTH_PROFILE_CONNECTION_ATTEMPTED,
                        BluetoothProfile.A2DP,
                        result,
                        mLastConnectionState,
                        BluetoothProfile.STATE_DISCONNECTED,
                        BluetoothProtoEnums.REASON_UNEXPECTED_STATE);
            }
        }
    }
    }


    @VisibleForTesting
    @VisibleForTesting
@@ -481,10 +504,11 @@ final class A2dpStateMachine extends StateMachine {
            // it differs from what we had saved before.
            // it differs from what we had saved before.
            mA2dpService.updateOptionalCodecsSupport(mDevice);
            mA2dpService.updateOptionalCodecsSupport(mDevice);
            mA2dpService.updateLowLatencyAudioSupport(mDevice);
            mA2dpService.updateLowLatencyAudioSupport(mDevice);

            broadcastConnectionState(mConnectionState, mLastConnectionState);
            broadcastConnectionState(mConnectionState, mLastConnectionState);
            // Upon connected, the audio starts out as stopped
            // Upon connected, the audio starts out as stopped
            broadcastAudioState(BluetoothA2dp.STATE_NOT_PLAYING,
            broadcastAudioState(BluetoothA2dp.STATE_NOT_PLAYING, BluetoothA2dp.STATE_PLAYING);
                                BluetoothA2dp.STATE_PLAYING);
            logSuccessIfNeeded();
        }
        }


        @Override
        @Override
@@ -593,6 +617,19 @@ final class A2dpStateMachine extends StateMachine {
                    break;
                    break;
            }
            }
        }
        }

        private void logSuccessIfNeeded() {
            if (mLastConnectionState == BluetoothProfile.STATE_CONNECTING
                    || mLastConnectionState == BluetoothProfile.STATE_DISCONNECTED) {
                BluetoothStatsLog.write(
                        BluetoothStatsLog.BLUETOOTH_PROFILE_CONNECTION_ATTEMPTED,
                        BluetoothProfile.A2DP,
                        BluetoothProtoEnums.RESULT_SUCCESS,
                        mLastConnectionState,
                        BluetoothProfile.STATE_CONNECTED,
                        BluetoothProtoEnums.REASON_SUCCESS);
            }
        }
    }
    }


    int getConnectionState() {
    int getConnectionState() {
+39 −1
Original line number Original line Diff line number Diff line
@@ -483,7 +483,10 @@ public class HeadsetStateMachine extends StateMachine {
            mHasWbsEnabled = false;
            mHasWbsEnabled = false;
            mHasSwbEnabled = false;
            mHasSwbEnabled = false;
            mHasNrecEnabled = false;
            mHasNrecEnabled = false;

            broadcastStateTransitions();
            broadcastStateTransitions();
            logFailureIfNeeded();

            // Remove the state machine for unbonded devices
            // Remove the state machine for unbonded devices
            if (mPrevState != null
            if (mPrevState != null
                    && mAdapterService.getBondState(mDevice) == BluetoothDevice.BOND_NONE) {
                    && mAdapterService.getBondState(mDevice) == BluetoothDevice.BOND_NONE) {
@@ -505,7 +508,9 @@ public class HeadsetStateMachine extends StateMachine {
                    if (!mNativeInterface.connectHfp(device)) {
                    if (!mNativeInterface.connectHfp(device)) {
                        stateLogE("CONNECT failed for connectHfp(" + device + ")");
                        stateLogE("CONNECT failed for connectHfp(" + device + ")");
                        // No state transition is involved, fire broadcast immediately
                        // No state transition is involved, fire broadcast immediately
                        broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTED,
                        broadcastConnectionState(
                                device,
                                BluetoothProfile.STATE_DISCONNECTED,
                                BluetoothProfile.STATE_DISCONNECTED);
                                BluetoothProfile.STATE_DISCONNECTED);
                        break;
                        break;
                    }
                    }
@@ -578,6 +583,25 @@ public class HeadsetStateMachine extends StateMachine {
                    break;
                    break;
            }
            }
        }
        }

        private void logFailureIfNeeded() {
            if (mPrevState == mConnecting || mPrevState == mDisconnected) {
                // Result for disconnected -> disconnected is unknown as it should
                // not have occurred.
                int result =
                        (mPrevState == mConnecting)
                                ? BluetoothProtoEnums.RESULT_FAILURE
                                : BluetoothProtoEnums.RESULT_UNKNOWN;

                BluetoothStatsLog.write(
                        BluetoothStatsLog.BLUETOOTH_PROFILE_CONNECTION_ATTEMPTED,
                        BluetoothProfile.A2DP,
                        result,
                        mPrevState.getConnectionStateInt(),
                        BluetoothProfile.STATE_DISCONNECTED,
                        BluetoothProtoEnums.REASON_UNEXPECTED_STATE);
            }
        }
    }
    }


    // Per HFP 1.7.1 spec page 23/144, Pending state needs to handle
    // Per HFP 1.7.1 spec page 23/144, Pending state needs to handle
@@ -1090,7 +1114,9 @@ public class HeadsetStateMachine extends StateMachine {
                // or the retry count reached MAX_RETRY_DISCONNECT_AUDIO.
                // or the retry count reached MAX_RETRY_DISCONNECT_AUDIO.
                mAudioDisconnectRetry = 0;
                mAudioDisconnectRetry = 0;
            }
            }

            broadcastStateTransitions();
            broadcastStateTransitions();
            logSuccessIfNeeded();
        }
        }


        @Override
        @Override
@@ -1184,6 +1210,18 @@ public class HeadsetStateMachine extends StateMachine {
                    break;
                    break;
            }
            }
        }
        }

        private void logSuccessIfNeeded() {
            if (mPrevState == mConnecting || mPrevState == mDisconnected) {
                BluetoothStatsLog.write(
                        BluetoothStatsLog.BLUETOOTH_PROFILE_CONNECTION_ATTEMPTED,
                        BluetoothProfile.HEADSET,
                        BluetoothProtoEnums.RESULT_SUCCESS,
                        mPrevState.getConnectionStateInt(),
                        BluetoothProfile.STATE_CONNECTED,
                        BluetoothProtoEnums.REASON_SUCCESS);
            }
        }
    }
    }


    class AudioConnecting extends ConnectedBase {
    class AudioConnecting extends ConnectedBase {
+2 −1
Original line number Original line Diff line number Diff line
@@ -55,7 +55,8 @@ extern tBTM_CB btm_cb;
namespace {
namespace {
constexpr char kBtmLogTag[] = "SCAN";
constexpr char kBtmLogTag[] = "SCAN";
constexpr uint16_t kAllowServiceDataFilter = 0x0040;
constexpr uint16_t kAllowServiceDataFilter = 0x0040;
constexpr uint16_t kAllowADTypeFilter = 0x80;
// Bit 8 for enable AD Type Check
constexpr uint16_t kAllowADTypeFilter = 0x100;
constexpr uint8_t kFilterLogicOr = 0x00;
constexpr uint8_t kFilterLogicOr = 0x00;
constexpr uint8_t kFilterLogicAnd = 0x01;
constexpr uint8_t kFilterLogicAnd = 0x01;
constexpr uint8_t kLowestRssiValue = 129;
constexpr uint8_t kLowestRssiValue = 129;