Finish plumbing for launch intents in sessions
This finishes out the plumbing for setting a launchable PendingIntent on a session and getting it from a controller to launch an app's UI. Change-Id: I0c9506e7c3f0ebf57070ca7e0d91324eb3fdd1e1
This commit is contained in:
@@ -16578,6 +16578,7 @@ package android.media.session {
|
||||
method public android.media.routing.MediaRouter.Delegate createMediaRouterDelegate();
|
||||
method public boolean dispatchMediaButtonEvent(android.view.KeyEvent);
|
||||
method public long getFlags();
|
||||
method public android.app.PendingIntent getLaunchActivity();
|
||||
method public android.media.MediaMetadata getMetadata();
|
||||
method public android.media.session.PlaybackState getPlaybackState();
|
||||
method public java.util.List<android.media.session.MediaSession.Track> getQueue();
|
||||
@@ -16641,7 +16642,7 @@ package android.media.session {
|
||||
method public void setActive(boolean);
|
||||
method public void setExtras(android.os.Bundle);
|
||||
method public void setFlags(int);
|
||||
method public void setLaunchPendingIntent(android.app.PendingIntent);
|
||||
method public void setLaunchActivity(android.app.PendingIntent);
|
||||
method public void setMediaRouter(android.media.routing.MediaRouter);
|
||||
method public void setMetadata(android.media.MediaMetadata);
|
||||
method public void setPlaybackState(android.media.session.PlaybackState);
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
package android.media.session;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.media.AudioAttributes;
|
||||
@@ -37,6 +38,7 @@ interface ISession {
|
||||
void setActive(boolean active);
|
||||
void setMediaRouter(in IMediaRouter router);
|
||||
void setMediaButtonReceiver(in ComponentName mbr);
|
||||
void setLaunchPendingIntent(in PendingIntent pi);
|
||||
void destroy();
|
||||
|
||||
// These commands are for the TransportPerformer
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
package android.media.session;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.media.MediaMetadata;
|
||||
@@ -44,6 +45,7 @@ interface ISessionController {
|
||||
void unregisterCallbackListener(in ISessionControllerCallback cb);
|
||||
boolean isTransportControlEnabled();
|
||||
MediaSessionInfo getSessionInfo();
|
||||
PendingIntent getLaunchPendingIntent();
|
||||
long getFlags();
|
||||
ParcelableVolumeInfo getVolumeAttributes();
|
||||
void adjustVolume(int direction, int flags);
|
||||
|
||||
@@ -18,6 +18,7 @@ package android.media.session;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.pm.ParceledListSlice;
|
||||
import android.media.AudioAttributes;
|
||||
import android.media.AudioManager;
|
||||
@@ -240,6 +241,21 @@ public final class MediaController {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an intent for launching UI associated with this session if one
|
||||
* exists.
|
||||
*
|
||||
* @return A {@link PendingIntent} to launch UI or null.
|
||||
*/
|
||||
public @Nullable PendingIntent getLaunchActivity() {
|
||||
try {
|
||||
return mSessionBinder.getLaunchPendingIntent();
|
||||
} catch (RemoteException e) {
|
||||
Log.wtf(TAG, "Error calling getPendingIntent.", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the token for the session this is connected to.
|
||||
*
|
||||
|
||||
@@ -19,6 +19,7 @@ package android.media.session;
|
||||
import android.annotation.IntDef;
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.Activity;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
@@ -222,12 +223,17 @@ public final class MediaSession {
|
||||
|
||||
/**
|
||||
* Set an intent for launching UI for this Session. This can be used as a
|
||||
* quick link to an ongoing media screen.
|
||||
* quick link to an ongoing media screen. The intent should be for an
|
||||
* activity that may be started using {@link Activity#startActivity(Intent)}.
|
||||
*
|
||||
* @param pi The intent to launch to show UI for this Session.
|
||||
*/
|
||||
public void setLaunchPendingIntent(@Nullable PendingIntent pi) {
|
||||
// TODO
|
||||
public void setLaunchActivity(@Nullable PendingIntent pi) {
|
||||
try {
|
||||
mBinder.setLaunchPendingIntent(pi);
|
||||
} catch (RemoteException e) {
|
||||
Log.wtf(TAG, "Failure in setLaunchPendingIntent.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.server.media;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -99,6 +100,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
|
||||
private long mFlags;
|
||||
private IMediaRouter mMediaRouter;
|
||||
private ComponentName mMediaButtonReceiver;
|
||||
private PendingIntent mLaunchIntent;
|
||||
|
||||
// TransportPerformer fields
|
||||
|
||||
@@ -650,6 +652,11 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
|
||||
mMediaButtonReceiver = mbr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLaunchPendingIntent(PendingIntent pi) {
|
||||
mLaunchIntent = pi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(MediaMetadata metadata) {
|
||||
mMetadata = metadata;
|
||||
@@ -920,6 +927,11 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
|
||||
return mSessionInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PendingIntent getLaunchPendingIntent() {
|
||||
return mLaunchIntent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFlags() {
|
||||
return mFlags;
|
||||
|
||||
Reference in New Issue
Block a user