[Audiosharing] Fix stop sharing btn in notification

When the broadcast is off but the notification mis-stay, click on "Stop
sharing" should dismiss the notification.

Test: atest
Flag: com.android.settingslib.flags.enable_le_audio_sharing
Bug: 305620450
Change-Id: Ic5b30f29b8acc06244c38eb357f63ed83985d74a
This commit is contained in:
Yiyi Shen
2024-08-08 17:55:18 +08:00
parent adbdc16113
commit a26baa0096
2 changed files with 34 additions and 9 deletions

View File

@@ -81,9 +81,15 @@ public class AudioSharingReceiver extends BroadcastReceiver {
break;
case ACTION_LE_AUDIO_SHARING_STOP:
LocalBluetoothManager manager = Utils.getLocalBtManager(context);
AudioSharingUtils.stopBroadcasting(manager);
metricsFeatureProvider.action(
context, SettingsEnums.ACTION_STOP_AUDIO_SHARING_FROM_NOTIFICATION);
if (BluetoothUtils.isBroadcasting(manager)) {
AudioSharingUtils.stopBroadcasting(manager);
metricsFeatureProvider.action(
context, SettingsEnums.ACTION_STOP_AUDIO_SHARING_FROM_NOTIFICATION);
} else {
cancelSharingNotification(context);
metricsFeatureProvider.action(
context, SettingsEnums.ACTION_CANCEL_AUDIO_SHARING_NOTIFICATION);
}
break;
default:
Log.w(TAG, "Received unexpected intent " + intent.getAction());