[Audiosharing] Handle cancel notification in receiver
Test: atest Bug: 395786392 Flag: com.android.settingslib.flags.enable_le_audio_sharing Change-Id: Ib4b8ed3eff1df01819b37be2c1334abeae00ea2c
This commit is contained in:
@@ -141,6 +141,12 @@ public class AudioSharingReceiver extends BroadcastReceiver {
|
|||||||
showAddSourceNotification(context, device);
|
showAddSourceNotification(context, device);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ACTION_LE_AUDIO_SHARING_CANCEL_NOTIF:
|
||||||
|
int notifId = intent.getIntExtra(EXTRA_NOTIF_ID, -1);
|
||||||
|
if (notifId != -1) {
|
||||||
|
cancelSharingNotification(context, notifId);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Log.w(TAG, "Received unexpected intent " + intent.getAction());
|
Log.w(TAG, "Received unexpected intent " + intent.getAction());
|
||||||
}
|
}
|
||||||
|
@@ -82,6 +82,9 @@ import java.util.stream.Collectors;
|
|||||||
public class AudioSharingReceiverTest {
|
public class AudioSharingReceiverTest {
|
||||||
private static final String ACTION_LE_AUDIO_SHARING_STOP =
|
private static final String ACTION_LE_AUDIO_SHARING_STOP =
|
||||||
"com.android.settings.action.BLUETOOTH_LE_AUDIO_SHARING_STOP";
|
"com.android.settings.action.BLUETOOTH_LE_AUDIO_SHARING_STOP";
|
||||||
|
private static final String ACTION_LE_AUDIO_SHARING_CANCEL_NOTIF =
|
||||||
|
"com.android.settings.action.BLUETOOTH_LE_AUDIO_SHARING_CANCEL_NOTIF";
|
||||||
|
private static final String EXTRA_NOTIF_ID = "NOTIF_ID";
|
||||||
private static final String TEST_DEVICE_NAME = "test";
|
private static final String TEST_DEVICE_NAME = "test";
|
||||||
|
|
||||||
@Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
@Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||||
@@ -343,6 +346,19 @@ public class AudioSharingReceiverTest {
|
|||||||
any(Notification.class));
|
any(Notification.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@EnableFlags(Flags.FLAG_ENABLE_LE_AUDIO_SHARING)
|
||||||
|
public void broadcastReceiver_receiveAudioSharingCancelNotif_cancel() {
|
||||||
|
Intent intent = new Intent(ACTION_LE_AUDIO_SHARING_CANCEL_NOTIF);
|
||||||
|
intent.setPackage(mContext.getPackageName());
|
||||||
|
intent.putExtra(EXTRA_NOTIF_ID,
|
||||||
|
com.android.settings.R.string.share_audio_notification_title);
|
||||||
|
AudioSharingReceiver audioSharingReceiver = getAudioSharingReceiver(intent);
|
||||||
|
audioSharingReceiver.onReceive(mContext, intent);
|
||||||
|
|
||||||
|
verify(mNm).cancel(com.android.settings.R.string.share_audio_notification_title);
|
||||||
|
}
|
||||||
|
|
||||||
private AudioSharingReceiver getAudioSharingReceiver(Intent intent) {
|
private AudioSharingReceiver getAudioSharingReceiver(Intent intent) {
|
||||||
assertThat(mShadowApplication.hasReceiverForIntent(intent)).isTrue();
|
assertThat(mShadowApplication.hasReceiverForIntent(intent)).isTrue();
|
||||||
List<BroadcastReceiver> receiversForIntent =
|
List<BroadcastReceiver> receiversForIntent =
|
||||||
|
Reference in New Issue
Block a user