Skip to content

Conversation

@jialu522
Copy link
Contributor

@jialu522 jialu522 commented Feb 9, 2026

…P target (tg) connection.

bug: v/85747

…P target (tg) connection.

bug: v/85747

Fix connection manager disconnection logic: Only AVRCP Controller (CT) instances register explicit disconnect callbacks with the connection manager, while AVRCP Target (TG) connections are not proactively terminated during disable operations, leading to stale connection states and potential resource leaks.

Signed-off-by: jialu <jialu@xiaomi.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a Bluetooth AVRCP issue where disabling Bluetooth does not properly tear down the AVRCP Target (TG) connection, by ensuring the TG role is integrated with the connection manager’s disconnect sequencing.

Changes:

  • Replaces the CT-only disconnect handler with a shared AVRCP disconnect handler (bt_sal_avrcp_disconnect).
  • Registers the AVRCP TG profile with the connection manager on connect so it can be disconnected during adapter disable.
  • Adds TG-side connection-manager “connected/disconnected” callbacks to mirror existing CT behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1056 to +1058

bt_sal_cm_profile_connected_callback(&avrcp_info->bd_addr, PROFILE_AVRCP_TG, CONN_ID_DEFAULT);
bt_sal_profile_disconnect_register(&avrcp_info->bd_addr, PROFILE_AVRCP_TG, CONN_ID_DEFAULT, PRIMARY_ADAPTER, bt_sal_avrcp_disconnect, NULL);
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The connection-manager integration for TG connect/disconnect is wrapped in #ifdef CONFIG_BLUETOOTH_AVRCP_TARGET. However, BLUETOOTH_AVRCP_ABSOLUTE_VOLUME can be enabled without BLUETOOTH_AVRCP_TARGET (see root Kconfig), and this file still registers TG callbacks in that configuration. In that case the TG connection will still not be registered for disconnect handling, so disabling Bluetooth may continue to leave the TG connection up. Consider widening the preprocessor guard to include CONFIG_BLUETOOTH_AVRCP_ABSOLUTE_VOLUME (or moving these CM calls outside the TARGET-only guard) so any configuration that brings up a TG link registers/unregisters it with the connection manager.

Copilot uses AI. Check for mistakes.
Comment on lines +1080 to 1082

bt_sal_cm_profile_disconnected_callback(&avrcp_info->bd_addr, PROFILE_AVRCP_TG, CONN_ID_DEFAULT);
#endif
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same conditional-compilation issue on the disconnect side: bt_sal_cm_profile_disconnected_callback() is only called when CONFIG_BLUETOOTH_AVRCP_TARGET is set, but TG connections can exist when only CONFIG_BLUETOOTH_AVRCP_ABSOLUTE_VOLUME is enabled. If the TG disconnect isn’t reported to the connection manager, its disconnect handler node may remain registered and can interfere with later disconnect sequencing.

Suggested change
bt_sal_cm_profile_disconnected_callback(&avrcp_info->bd_addr, PROFILE_AVRCP_TG, CONN_ID_DEFAULT);
#endif
#endif
bt_sal_cm_profile_disconnected_callback(&avrcp_info->bd_addr, PROFILE_AVRCP_TG, CONN_ID_DEFAULT);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants