Fix output switcher will display previous media session

Before this CL, the same request code will cause intent to
be cached. It will cause the output switcher to display the
previous media session.

This CL uses the package name as an unique request code to
fix this issue.

Bug: 169077753
Test: make -j42 RunSettingsRoboTests
Change-Id: Iebfc7904609e243d5bf0222307bae98a952a3331
This commit is contained in:
Hugh Chen
2020-09-22 19:25:18 +08:00
parent c4ae769663
commit c3fe8d87d6
3 changed files with 12 additions and 4 deletions

View File

@@ -257,9 +257,11 @@ public class MediaOutputSlice implements CustomSliceable {
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
.putExtra(MediaOutputSliceConstants.EXTRA_PACKAGE_NAME,
getWorker().getPackageName());
final int requestCode = TextUtils.isEmpty(getWorker().getPackageName())
? 0
: getWorker().getPackageName().hashCode();
return SliceAction.createDeeplink(
PendingIntent.getActivity(mContext, 0 /* requestCode */, intent, 0 /* flags */),
PendingIntent.getActivity(mContext, requestCode, intent, 0 /* flags */),
IconCompat.createWithResource(mContext, R.drawable.ic_add_blue_24dp),
ListBuilder.ICON_IMAGE,
mContext.getText(R.string.add));