Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2553)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaButtonReceiver.java

Issue 1491943002: Refactoring media notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added two MediaSessionBrowserTests to test MediaSession.Stop() Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaButtonReceiver.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaButtonReceiver.java b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaButtonReceiver.java
index c18df6c25d139903619a3a436c22fae62d9c4bcd..736cf0c55c36d0bbf65cee9f5a42de9dbceb8ea1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaButtonReceiver.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/media/ui/MediaButtonReceiver.java
@@ -5,13 +5,8 @@
package org.chromium.chrome.browser.media.ui;
import android.content.BroadcastReceiver;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
-
-import java.util.List;
/**
* MediaButtonReceiver is a basic BroadcastReceiver class that receives
@@ -20,30 +15,11 @@ import java.util.List;
* This is there for backward compatibility with JB_MR0 and JB_MR1.
*/
public abstract class MediaButtonReceiver extends BroadcastReceiver {
- private static final String LISTENER_SERVICE_CLASS_NAME =
- "org.chromium.chrome.browser.media.ui"
- + "MediaNotificationManager$ListenerService";
- public static final String EXTRA_NOTIFICATION_ID =
- "MediaNotificationManager.ListenerService.NOTIFICATION_ID";
-
- public abstract int getNotificationId();
+ public abstract String getServiceClassName();
@Override
public void onReceive(Context context, Intent intent) {
- Intent queryIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);
- queryIntent.setPackage(context.getPackageName());
-
- PackageManager pm = context.getPackageManager();
- List<ResolveInfo> infos = pm.queryIntentServices(queryIntent, 0);
- assert infos.size() == 1;
-
- ResolveInfo info = infos.get(0);
- ComponentName component = new ComponentName(info.serviceInfo.packageName,
- info.serviceInfo.name);
- assert LISTENER_SERVICE_CLASS_NAME.equals(component.getClassName());
-
- intent.setComponent(component);
- intent.putExtra(EXTRA_NOTIFICATION_ID, getNotificationId());
+ intent.setClassName(context, getServiceClassName());
context.startService(intent);
whywhat 2015/12/09 16:59:27 Why is setClassName() equivalent to setComponent()
Zhiqiang Zhang (Slow) 2015/12/09 18:02:55 I checked the Android reference. setClassName() is
}
}

Powered by Google App Engine
This is Rietveld 408576698