Loading android/app/src/com/android/bluetooth/a2dp/A2dpStateMachine.java +39 −2 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import android.os.Looper; import android.os.Message; import android.util.Log; import com.android.bluetooth.BluetoothStatsLog; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.MetricsLogger; import com.android.bluetooth.btservice.ProfileService; Loading Loading @@ -169,6 +170,8 @@ final class A2dpStateMachine extends StateMachine { BluetoothA2dp.STATE_PLAYING); } } logFailureIfNeeded(); } @Override Loading Loading @@ -260,6 +263,26 @@ final class A2dpStateMachine extends StateMachine { 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 Loading Loading @@ -481,10 +504,11 @@ final class A2dpStateMachine extends StateMachine { // it differs from what we had saved before. mA2dpService.updateOptionalCodecsSupport(mDevice); mA2dpService.updateLowLatencyAudioSupport(mDevice); broadcastConnectionState(mConnectionState, mLastConnectionState); // Upon connected, the audio starts out as stopped broadcastAudioState(BluetoothA2dp.STATE_NOT_PLAYING, BluetoothA2dp.STATE_PLAYING); broadcastAudioState(BluetoothA2dp.STATE_NOT_PLAYING, BluetoothA2dp.STATE_PLAYING); logSuccessIfNeeded(); } @Override Loading Loading @@ -593,6 +617,19 @@ final class A2dpStateMachine extends StateMachine { 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() { Loading android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +39 −1 Original line number Diff line number Diff line Loading @@ -483,7 +483,10 @@ public class HeadsetStateMachine extends StateMachine { mHasWbsEnabled = false; mHasSwbEnabled = false; mHasNrecEnabled = false; broadcastStateTransitions(); logFailureIfNeeded(); // Remove the state machine for unbonded devices if (mPrevState != null && mAdapterService.getBondState(mDevice) == BluetoothDevice.BOND_NONE) { Loading @@ -505,7 +508,9 @@ public class HeadsetStateMachine extends StateMachine { if (!mNativeInterface.connectHfp(device)) { stateLogE("CONNECT failed for connectHfp(" + device + ")"); // No state transition is involved, fire broadcast immediately broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTED, broadcastConnectionState( device, BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.STATE_DISCONNECTED); break; } Loading Loading @@ -578,6 +583,25 @@ public class HeadsetStateMachine extends StateMachine { 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 Loading Loading @@ -1090,7 +1114,9 @@ public class HeadsetStateMachine extends StateMachine { // or the retry count reached MAX_RETRY_DISCONNECT_AUDIO. mAudioDisconnectRetry = 0; } broadcastStateTransitions(); logSuccessIfNeeded(); } @Override Loading Loading @@ -1184,6 +1210,18 @@ public class HeadsetStateMachine extends StateMachine { 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 { Loading Loading
android/app/src/com/android/bluetooth/a2dp/A2dpStateMachine.java +39 −2 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ import android.os.Looper; import android.os.Message; import android.util.Log; import com.android.bluetooth.BluetoothStatsLog; import com.android.bluetooth.Utils; import com.android.bluetooth.btservice.MetricsLogger; import com.android.bluetooth.btservice.ProfileService; Loading Loading @@ -169,6 +170,8 @@ final class A2dpStateMachine extends StateMachine { BluetoothA2dp.STATE_PLAYING); } } logFailureIfNeeded(); } @Override Loading Loading @@ -260,6 +263,26 @@ final class A2dpStateMachine extends StateMachine { 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 Loading Loading @@ -481,10 +504,11 @@ final class A2dpStateMachine extends StateMachine { // it differs from what we had saved before. mA2dpService.updateOptionalCodecsSupport(mDevice); mA2dpService.updateLowLatencyAudioSupport(mDevice); broadcastConnectionState(mConnectionState, mLastConnectionState); // Upon connected, the audio starts out as stopped broadcastAudioState(BluetoothA2dp.STATE_NOT_PLAYING, BluetoothA2dp.STATE_PLAYING); broadcastAudioState(BluetoothA2dp.STATE_NOT_PLAYING, BluetoothA2dp.STATE_PLAYING); logSuccessIfNeeded(); } @Override Loading Loading @@ -593,6 +617,19 @@ final class A2dpStateMachine extends StateMachine { 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() { Loading
android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +39 −1 Original line number Diff line number Diff line Loading @@ -483,7 +483,10 @@ public class HeadsetStateMachine extends StateMachine { mHasWbsEnabled = false; mHasSwbEnabled = false; mHasNrecEnabled = false; broadcastStateTransitions(); logFailureIfNeeded(); // Remove the state machine for unbonded devices if (mPrevState != null && mAdapterService.getBondState(mDevice) == BluetoothDevice.BOND_NONE) { Loading @@ -505,7 +508,9 @@ public class HeadsetStateMachine extends StateMachine { if (!mNativeInterface.connectHfp(device)) { stateLogE("CONNECT failed for connectHfp(" + device + ")"); // No state transition is involved, fire broadcast immediately broadcastConnectionState(device, BluetoothProfile.STATE_DISCONNECTED, broadcastConnectionState( device, BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.STATE_DISCONNECTED); break; } Loading Loading @@ -578,6 +583,25 @@ public class HeadsetStateMachine extends StateMachine { 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 Loading Loading @@ -1090,7 +1114,9 @@ public class HeadsetStateMachine extends StateMachine { // or the retry count reached MAX_RETRY_DISCONNECT_AUDIO. mAudioDisconnectRetry = 0; } broadcastStateTransitions(); logSuccessIfNeeded(); } @Override Loading Loading @@ -1184,6 +1210,18 @@ public class HeadsetStateMachine extends StateMachine { 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 { Loading