diff options
| author | Dianne Hackborn <hackbod@google.com> | 2012-06-11 15:08:39 -0700 |
|---|---|---|
| committer | Dianne Hackborn <hackbod@google.com> | 2012-06-11 15:41:08 -0700 |
| commit | b58b8f832d06b0ffa8886eba5a4916578a3b8743 (patch) | |
| tree | 46c116da0e9c0f7fb6b9403b18771bdffe8760d9 /core/java/android | |
| parent | fbce66cb259cb63b43fda654db68152b8b4a2c2f (diff) | |
| download | frameworks_base-b58b8f832d06b0ffa8886eba5a4916578a3b8743.zip frameworks_base-b58b8f832d06b0ffa8886eba5a4916578a3b8743.tar.gz frameworks_base-b58b8f832d06b0ffa8886eba5a4916578a3b8743.tar.bz2 | |
Rework media router to be per-context with global process state.
Change-Id: Ic1cb6f13e691d22783bcdafae85b7c75aec0a66f
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/app/ContextImpl.java | 6 | ||||
| -rw-r--r-- | core/java/android/app/MediaRouteActionProvider.java | 2 | ||||
| -rw-r--r-- | core/java/android/app/MediaRouteButton.java | 2 | ||||
| -rw-r--r-- | core/java/android/content/Context.java | 13 |
4 files changed, 20 insertions, 3 deletions
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java index 4c35a8c..b902550 100644 --- a/core/java/android/app/ContextImpl.java +++ b/core/java/android/app/ContextImpl.java @@ -55,6 +55,7 @@ import android.location.ICountryDetector; import android.location.ILocationManager; import android.location.LocationManager; import android.media.AudioManager; +import android.media.MediaRouter; import android.net.ConnectivityManager; import android.net.IConnectivityManager; import android.net.INetworkPolicyManager; @@ -288,6 +289,11 @@ class ContextImpl extends Context { return new AudioManager(ctx); }}); + registerService(MEDIA_ROUTER_SERVICE, new ServiceFetcher() { + public Object createService(ContextImpl ctx) { + return new MediaRouter(ctx); + }}); + registerService(CLIPBOARD_SERVICE, new ServiceFetcher() { public Object createService(ContextImpl ctx) { return new ClipboardManager(ctx.getOuterContext(), diff --git a/core/java/android/app/MediaRouteActionProvider.java b/core/java/android/app/MediaRouteActionProvider.java index 9b9e14f..7764ac6 100644 --- a/core/java/android/app/MediaRouteActionProvider.java +++ b/core/java/android/app/MediaRouteActionProvider.java @@ -37,7 +37,7 @@ public class MediaRouteActionProvider extends ActionProvider { public MediaRouteActionProvider(Context context) { super(context); mContext = context; - mRouter = MediaRouter.forApplication(context); + mRouter = (MediaRouter)context.getSystemService(Context.MEDIA_ROUTER_SERVICE); // Start with live audio by default. // TODO Update this when new route types are added; segment by API level diff --git a/core/java/android/app/MediaRouteButton.java b/core/java/android/app/MediaRouteButton.java index 10c0793..8f9379a 100644 --- a/core/java/android/app/MediaRouteButton.java +++ b/core/java/android/app/MediaRouteButton.java @@ -58,7 +58,7 @@ public class MediaRouteButton extends View { public MediaRouteButton(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - mRouter = MediaRouter.forApplication(context); + mRouter = (MediaRouter)context.getSystemService(Context.MEDIA_ROUTER_SERVICE); TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.MediaRouteButton, defStyleAttr, 0); diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 4c169d3..7588cda 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -1528,6 +1528,8 @@ public abstract class Context { * @see android.net.wifi.WifiManager * @see #AUDIO_SERVICE * @see android.media.AudioManager + * @see #MEDIA_ROUTER_SERVICE + * @see android.media.MediaRouter * @see #TELEPHONY_SERVICE * @see android.telephony.TelephonyManager * @see #INPUT_METHOD_SERVICE @@ -1778,7 +1780,6 @@ public abstract class Context { */ public static final String NSD_SERVICE = "servicediscovery"; - /** * Use with {@link #getSystemService} to retrieve a * {@link android.media.AudioManager} for handling management of volume, @@ -1791,6 +1792,16 @@ public abstract class Context { /** * Use with {@link #getSystemService} to retrieve a + * {@link android.media.MediaRouter} for controlling and managing + * routing of media. + * + * @see #getSystemService + * @see android.media.MediaRouter + */ + public static final String MEDIA_ROUTER_SERVICE = "media_router"; + + /** + * Use with {@link #getSystemService} to retrieve a * {@link android.telephony.TelephonyManager} for handling management the * telephony features of the device. * |
