Commit 07812a28 authored by zqzhang's avatar zqzhang Committed by Commit bot

Fix conflicting PendingIntent for stop button and swipe away

Notification PendingIntents having the same name will conflict
with each other. This CL fixes the conflict for MediaNotification
stop button and swipe away, which now fire different actions but
we treat both as ACTION_STOP.

BUG=640301

Review-Url: https://codereview.chromium.org/2279263002
Cr-Commit-Position: refs/heads/master@{#414754}
parent ef896c91
...@@ -63,6 +63,10 @@ public class MediaNotificationManager { ...@@ -63,6 +63,10 @@ public class MediaNotificationManager {
"MediaNotificationManager.ListenerService.PAUSE"; "MediaNotificationManager.ListenerService.PAUSE";
private static final String ACTION_STOP = private static final String ACTION_STOP =
"MediaNotificationManager.ListenerService.STOP"; "MediaNotificationManager.ListenerService.STOP";
private static final String ACTION_SWIPE =
"MediaNotificationManager.ListenerService.SWIPE";
private static final String ACTION_CANCEL =
"MediaNotificationManager.ListenerService.CANCEL";
@Override @Override
public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) {
...@@ -134,7 +138,9 @@ public class MediaNotificationManager { ...@@ -134,7 +138,9 @@ public class MediaNotificationManager {
default: default:
break; break;
} }
} else if (ACTION_STOP.equals(action)) { } else if (ACTION_STOP.equals(action)
|| ACTION_SWIPE.equals(action)
|| ACTION_CANCEL.equals(action)) {
manager.onStop( manager.onStop(
MediaNotificationListener.ACTION_SOURCE_MEDIA_NOTIFICATION); MediaNotificationListener.ACTION_SOURCE_MEDIA_NOTIFICATION);
stopSelf(); stopSelf();
...@@ -517,7 +523,7 @@ public class MediaNotificationManager { ...@@ -517,7 +523,7 @@ public class MediaNotificationManager {
if (mMediaNotificationInfo.supportsSwipeAway()) { if (mMediaNotificationInfo.supportsSwipeAway()) {
mNotificationBuilder.setOngoing(!mMediaNotificationInfo.isPaused); mNotificationBuilder.setOngoing(!mMediaNotificationInfo.isPaused);
mNotificationBuilder.setDeleteIntent(createPendingIntent(ListenerService.ACTION_STOP)); mNotificationBuilder.setDeleteIntent(createPendingIntent(ListenerService.ACTION_SWIPE));
} }
// The intent will currently only be null when using a custom tab. // The intent will currently only be null when using a custom tab.
...@@ -642,7 +648,7 @@ public class MediaNotificationManager { ...@@ -642,7 +648,7 @@ public class MediaNotificationManager {
createPendingIntent(ListenerService.ACTION_PAUSE)); createPendingIntent(ListenerService.ACTION_PAUSE));
} }
style.setShowActionsInCompactView(0); style.setShowActionsInCompactView(0);
style.setCancelButtonIntent(createPendingIntent(ListenerService.ACTION_STOP)); style.setCancelButtonIntent(createPendingIntent(ListenerService.ACTION_CANCEL));
style.setShowCancelButton(true); style.setShowCancelButton(true);
builder.setStyle(style); builder.setStyle(style);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment