Merge "Remove unneeded context" into pi-dev

am: 72e895fd9f

Change-Id: I53e3f05bbd2ac91556eb2db74da5d41ca4d61c2f
This commit is contained in:
Christofer Åkersten
2018-03-27 07:33:52 +00:00
committed by android-build-merger
12 changed files with 79 additions and 113 deletions

View File

@@ -19,7 +19,6 @@ package android.media;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.media.update.ApiLoader;
import android.media.update.MediaItem2Provider;
import android.os.Bundle;
@@ -81,8 +80,8 @@ public class MediaItem2 {
return mProvider.toBundle_impl();
}
public static MediaItem2 fromBundle(Context context, Bundle bundle) {
return ApiLoader.getProvider().fromBundle_MediaItem2(context, bundle);
public static MediaItem2 fromBundle(Bundle bundle) {
return ApiLoader.getProvider().fromBundle_MediaItem2(bundle);
}
public String toString() {
@@ -161,11 +160,10 @@ public class MediaItem2 {
/**
* Constructor for {@link Builder}
*
* @param context
* @param flags
*/
public Builder(@NonNull Context context, @Flags int flags) {
mProvider = ApiLoader.getProvider().createMediaItem2Builder(context, this, flags);
public Builder(@Flags int flags) {
mProvider = ApiLoader.getProvider().createMediaItem2Builder(this, flags);
}
/**

View File

@@ -20,7 +20,6 @@ import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.PendingIntent;
import android.content.Context;
import android.media.MediaLibraryService2.MediaLibrarySession.Builder;
import android.media.MediaLibraryService2.MediaLibrarySession.MediaLibrarySessionCallback;
import android.media.MediaSession2.ControllerInfo;
@@ -74,8 +73,8 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 {
* Callback for the {@link MediaLibrarySession}.
*/
public static class MediaLibrarySessionCallback extends MediaSession2.SessionCallback {
public MediaLibrarySessionCallback(@NonNull Context context) {
super(context);
public MediaLibrarySessionCallback() {
super();
}
/**
@@ -401,10 +400,9 @@ public abstract class MediaLibraryService2 extends MediaSessionService2 {
* @param rootId The root id for browsing.
* @param extras Any extras about the library service.
*/
public LibraryRoot(@NonNull Context context,
@NonNull String rootId, @Nullable Bundle extras) {
public LibraryRoot(@NonNull String rootId, @Nullable Bundle extras) {
mProvider = ApiLoader.getProvider().createMediaLibraryService2LibraryRoot(
context, this, rootId, extras);
this, rootId, extras);
}
/**

View File

@@ -19,7 +19,6 @@ package android.media;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.StringDef;
import android.content.Context;
import android.graphics.Bitmap;
import android.media.update.ApiLoader;
import android.media.update.MediaMetadata2Provider;
@@ -657,13 +656,11 @@ public final class MediaMetadata2 {
* Creates the {@link MediaMetadata2} from the bundle that previously returned by
* {@link #toBundle()}.
*
* @param context context
* @param bundle bundle for the metadata
* @return a new MediaMetadata2
*/
public static @NonNull MediaMetadata2 fromBundle(@NonNull Context context,
@Nullable Bundle bundle) {
return ApiLoader.getProvider().fromBundle_MediaMetadata2(context, bundle);
public static @NonNull MediaMetadata2 fromBundle(@Nullable Bundle bundle) {
return ApiLoader.getProvider().fromBundle_MediaMetadata2(bundle);
}
/**
@@ -677,8 +674,8 @@ public final class MediaMetadata2 {
* Create an empty Builder. Any field that should be included in the
* {@link MediaMetadata2} must be added.
*/
public Builder(@NonNull Context context) {
mProvider = ApiLoader.getProvider().createMediaMetadata2Builder(context, this);
public Builder() {
mProvider = ApiLoader.getProvider().createMediaMetadata2Builder(this);
}
/**
@@ -688,8 +685,8 @@ public final class MediaMetadata2 {
*
* @param source
*/
public Builder(@NonNull Context context, @NonNull MediaMetadata2 source) {
mProvider = ApiLoader.getProvider().createMediaMetadata2Builder(context, this, source);
public Builder(@NonNull MediaMetadata2 source) {
mProvider = ApiLoader.getProvider().createMediaMetadata2Builder(this, source);
}
/**

View File

@@ -20,7 +20,6 @@ import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
import android.media.update.ApiLoader;
import android.media.update.MediaPlaylistAgentProvider;
@@ -148,8 +147,8 @@ public abstract class MediaPlaylistAgent {
@RepeatMode int repeatMode) { }
}
public MediaPlaylistAgent(@NonNull Context context) {
mProvider = ApiLoader.getProvider().createMediaPlaylistAgent(context, this);
public MediaPlaylistAgent() {
mProvider = ApiLoader.getProvider().createMediaPlaylistAgent(this);
}
/**

View File

@@ -445,12 +445,12 @@ public class MediaSession2 implements AutoCloseable {
public static final class Command {
private final CommandProvider mProvider;
public Command(@NonNull Context context, int commandCode) {
public Command(int commandCode) {
mProvider = ApiLoader.getProvider().createMediaSession2Command(
this, commandCode, null, null);
}
public Command(@NonNull Context context, @NonNull String action, @Nullable Bundle extras) {
public Command(@NonNull String action, @Nullable Bundle extras) {
if (action == null) {
throw new IllegalArgumentException("action shouldn't be null");
}
@@ -502,8 +502,8 @@ public class MediaSession2 implements AutoCloseable {
* @return a new Command instance from the Bundle
* @hide
*/
public static Command fromBundle(@NonNull Context context, @NonNull Bundle command) {
return ApiLoader.getProvider().fromBundle_MediaSession2Command(context, command);
public static Command fromBundle(@NonNull Bundle command) {
return ApiLoader.getProvider().fromBundle_MediaSession2Command(command);
}
}
@@ -513,14 +513,12 @@ public class MediaSession2 implements AutoCloseable {
public static final class CommandGroup {
private final CommandGroupProvider mProvider;
public CommandGroup(@NonNull Context context) {
mProvider = ApiLoader.getProvider().createMediaSession2CommandGroup(
context, this, null);
public CommandGroup() {
mProvider = ApiLoader.getProvider().createMediaSession2CommandGroup(this, null);
}
public CommandGroup(@NonNull Context context, @Nullable CommandGroup others) {
mProvider = ApiLoader.getProvider().createMediaSession2CommandGroup(
context, this, others);
public CommandGroup(@Nullable CommandGroup others) {
mProvider = ApiLoader.getProvider().createMediaSession2CommandGroup(this, others);
}
/**
@@ -581,8 +579,8 @@ public class MediaSession2 implements AutoCloseable {
* @return new instance of CommandGroup from the bundle
* @hide
*/
public static @Nullable CommandGroup fromBundle(Context context, Bundle commands) {
return ApiLoader.getProvider().fromBundle_MediaSession2CommandGroup(context, commands);
public static @Nullable CommandGroup fromBundle(Bundle commands) {
return ApiLoader.getProvider().fromBundle_MediaSession2CommandGroup(commands);
}
}
@@ -594,15 +592,6 @@ public class MediaSession2 implements AutoCloseable {
*/
// TODO(jaewan): Move this to updatable for default implementation (b/74091963)
public static abstract class SessionCallback {
private final Context mContext;
public SessionCallback(@NonNull Context context) {
if (context == null) {
throw new IllegalArgumentException("context shouldn't be null");
}
mContext = context;
}
/**
* Called when a controller is created for this session. Return allowed commands for
* controller. By default it allows all connection requests and commands.
@@ -617,7 +606,7 @@ public class MediaSession2 implements AutoCloseable {
*/
public @Nullable CommandGroup onConnect(@NonNull MediaSession2 session,
@NonNull ControllerInfo controller) {
CommandGroup commands = new CommandGroup(mContext);
CommandGroup commands = new CommandGroup();
commands.addAllPredefinedCommands();
return commands;
}
@@ -1221,9 +1210,8 @@ public class MediaSession2 implements AutoCloseable {
public static final class Builder {
private final CommandButtonProvider.BuilderProvider mProvider;
public Builder(@NonNull Context context) {
mProvider = ApiLoader.getProvider().createMediaSession2CommandButtonBuilder(
context, this);
public Builder() {
mProvider = ApiLoader.getProvider().createMediaSession2CommandButtonBuilder(this);
}
public @NonNull Builder setCommand(@Nullable Command command) {

View File

@@ -21,7 +21,6 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.Notification;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.media.MediaSession2.ControllerInfo;
import android.media.update.ApiLoader;
@@ -213,16 +212,14 @@ public abstract class MediaSessionService2 extends Service {
/**
* Default constructor
*
* @param context context
* @param notificationId notification id to be used for
* {@link android.app.NotificationManager#notify(int, Notification)}.
* @param notification a notification to make session service foreground service. Media
* style notification is recommended here.
*/
public MediaNotification(@NonNull Context context,
int notificationId, @NonNull Notification notification) {
public MediaNotification(int notificationId, @NonNull Notification notification) {
mProvider = ApiLoader.getProvider().createMediaSessionService2MediaNotification(
context, this, notificationId, notification);
this, notificationId, notification);
}
public int getNotificationId() {

View File

@@ -19,7 +19,6 @@ package android.media;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.IntDef;
import android.content.Context;
import android.media.update.ApiLoader;
import android.media.update.Rating2Provider;
import android.os.Bundle;
@@ -127,12 +126,11 @@ public final class Rating2 {
/**
* Create an instance from bundle object, previoulsy created by {@link #toBundle()}
*
* @param context context
* @param bundle bundle
* @return new Rating2 instance or {@code null} for error
*/
public static Rating2 fromBundle(@NonNull Context context, @Nullable Bundle bundle) {
return ApiLoader.getProvider().fromBundle_Rating2(context, bundle);
public static Rating2 fromBundle(@Nullable Bundle bundle) {
return ApiLoader.getProvider().fromBundle_Rating2(bundle);
}
/**
@@ -147,39 +145,35 @@ public final class Rating2 {
* Return a Rating2 instance with no rating.
* Create and return a new Rating2 instance with no rating known for the given
* rating style.
* @param context context
* @param ratingStyle one of {@link #RATING_HEART}, {@link #RATING_THUMB_UP_DOWN},
* {@link #RATING_3_STARS}, {@link #RATING_4_STARS}, {@link #RATING_5_STARS},
* or {@link #RATING_PERCENTAGE}.
* @return null if an invalid rating style is passed, a new Rating2 instance otherwise.
*/
public static @Nullable Rating2 newUnratedRating(@NonNull Context context,
@Style int ratingStyle) {
return ApiLoader.getProvider().newUnratedRating_Rating2(context, ratingStyle);
public static @Nullable Rating2 newUnratedRating(@Style int ratingStyle) {
return ApiLoader.getProvider().newUnratedRating_Rating2(ratingStyle);
}
/**
* Return a Rating2 instance with a heart-based rating.
* Create and return a new Rating2 instance with a rating style of {@link #RATING_HEART},
* and a heart-based rating.
* @param context context
* @param hasHeart true for a "heart selected" rating, false for "heart unselected".
* @return a new Rating2 instance.
*/
public static @Nullable Rating2 newHeartRating(@NonNull Context context, boolean hasHeart) {
return ApiLoader.getProvider().newHeartRating_Rating2(context, hasHeart);
public static @Nullable Rating2 newHeartRating(boolean hasHeart) {
return ApiLoader.getProvider().newHeartRating_Rating2(hasHeart);
}
/**
* Return a Rating2 instance with a thumb-based rating.
* Create and return a new Rating2 instance with a {@link #RATING_THUMB_UP_DOWN}
* rating style, and a "thumb up" or "thumb down" rating.
* @param context context
* @param thumbIsUp true for a "thumb up" rating, false for "thumb down".
* @return a new Rating2 instance.
*/
public static @Nullable Rating2 newThumbRating(@NonNull Context context, boolean thumbIsUp) {
return ApiLoader.getProvider().newThumbRating_Rating2(context, thumbIsUp);
public static @Nullable Rating2 newThumbRating(boolean thumbIsUp) {
return ApiLoader.getProvider().newThumbRating_Rating2(thumbIsUp);
}
/**
@@ -187,7 +181,6 @@ public final class Rating2 {
* Create and return a new Rating2 instance with one of the star-base rating styles
* and the given integer or fractional number of stars. Non integer values can for instance
* be used to represent an average rating value, which might not be an integer number of stars.
* @param context context
* @param starRatingStyle one of {@link #RATING_3_STARS}, {@link #RATING_4_STARS},
* {@link #RATING_5_STARS}.
* @param starRating a number ranging from 0.0f to 3.0f, 4.0f or 5.0f according to
@@ -195,26 +188,25 @@ public final class Rating2 {
* @return null if the rating style is invalid, or the rating is out of range,
* a new Rating2 instance otherwise.
*/
public static @Nullable Rating2 newStarRating(@NonNull Context context,
public static @Nullable Rating2 newStarRating(
@StarStyle int starRatingStyle, float starRating) {
return ApiLoader.getProvider().newStarRating_Rating2(context, starRatingStyle, starRating);
return ApiLoader.getProvider().newStarRating_Rating2(starRatingStyle, starRating);
}
/**
* Return a Rating2 instance with a percentage-based rating.
* Create and return a new Rating2 instance with a {@link #RATING_PERCENTAGE}
* rating style, and a rating of the given percentage.
* @param context context
* @param percent the value of the rating
* @return null if the rating is out of range, a new Rating2 instance otherwise.
*/
public static @Nullable Rating2 newPercentageRating(@NonNull Context context, float percent) {
return ApiLoader.getProvider().newPercentageRating_Rating2(context, percent);
public static @Nullable Rating2 newPercentageRating(float percent) {
return ApiLoader.getProvider().newPercentageRating_Rating2(percent);
}
/**
* Return whether there is a rating value available.
* @return true if the instance was not created with {@link #newUnratedRating(Context, int)}.
* @return true if the instance was not created with {@link #newUnratedRating(int)}.
*/
public boolean isRated() {
return mProvider.isRated_impl();

View File

@@ -150,8 +150,8 @@ public final class SessionToken2 {
* @param bundle
* @return
*/
public static SessionToken2 fromBundle(@NonNull Context context, @NonNull Bundle bundle) {
return ApiLoader.getProvider().fromBundle_SessionToken2(context, bundle);
public static SessionToken2 fromBundle(@NonNull Bundle bundle) {
return ApiLoader.getProvider().fromBundle_SessionToken2(bundle);
}
/**

View File

@@ -18,7 +18,6 @@ package android.media;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.content.Context;
import android.media.update.ApiLoader;
import android.media.update.VolumeProvider2Provider;
@@ -75,10 +74,9 @@ public abstract class VolumeProvider2 {
* @param maxVolume The maximum allowed volume.
* @param currentVolume The current volume on the output.
*/
public VolumeProvider2(@NonNull Context context, @ControlType int controlType,
int maxVolume, int currentVolume) {
public VolumeProvider2(@ControlType int controlType, int maxVolume, int currentVolume) {
mProvider = ApiLoader.getProvider().createVolumeProvider2(
context, this, controlType, maxVolume, currentVolume);
this, controlType, maxVolume, currentVolume);
}
/**

View File

@@ -407,7 +407,7 @@ public final class MediaSessionManager {
List<Bundle> bundles = mService.getSessionTokens(
/* activeSessionOnly */ true, /* sessionServiceOnly */ false,
mContext.getPackageName());
return toTokenList(mContext, bundles);
return toTokenList(bundles);
} catch (RemoteException e) {
Log.wtf(TAG, "Cannot communicate with the service.", e);
return Collections.emptyList();
@@ -430,7 +430,7 @@ public final class MediaSessionManager {
List<Bundle> bundles = mService.getSessionTokens(
/* activeSessionOnly */ false, /* sessionServiceOnly */ true,
mContext.getPackageName());
return toTokenList(mContext, bundles);
return toTokenList(bundles);
} catch (RemoteException e) {
Log.wtf(TAG, "Cannot communicate with the service.", e);
return Collections.emptyList();
@@ -455,7 +455,7 @@ public final class MediaSessionManager {
List<Bundle> bundles = mService.getSessionTokens(
/* activeSessionOnly */ false, /* sessionServiceOnly */ false,
mContext.getPackageName());
return toTokenList(mContext, bundles);
return toTokenList(bundles);
} catch (RemoteException e) {
Log.wtf(TAG, "Cannot communicate with the service.", e);
return Collections.emptyList();
@@ -540,11 +540,11 @@ public final class MediaSessionManager {
}
}
private static List<SessionToken2> toTokenList(Context context, List<Bundle> bundles) {
private static List<SessionToken2> toTokenList(List<Bundle> bundles) {
List<SessionToken2> tokens = new ArrayList<>();
if (bundles != null) {
for (int i = 0; i < bundles.size(); i++) {
SessionToken2 token = SessionToken2.fromBundle(context, bundles.get(i));
SessionToken2 token = SessionToken2.fromBundle(bundles.get(i));
if (token != null) {
tokens.add(token);
}
@@ -829,7 +829,7 @@ public final class MediaSessionManager {
final Context context = mContext;
final OnSessionTokensChangedListener listener = mListener;
if (context != null && listener != null) {
listener.onSessionTokensChanged(toTokenList(context, bundles));
listener.onSessionTokensChanged(toTokenList(bundles));
}
});
}

View File

@@ -69,14 +69,14 @@ public interface StaticProvider {
CommandProvider createMediaSession2Command(MediaSession2.Command instance,
int commandCode, String action, Bundle extra);
MediaSession2.Command fromBundle_MediaSession2Command(Context context, Bundle bundle);
CommandGroupProvider createMediaSession2CommandGroup(Context context,
MediaSession2.Command fromBundle_MediaSession2Command(Bundle bundle);
CommandGroupProvider createMediaSession2CommandGroup(
MediaSession2.CommandGroup instance, MediaSession2.CommandGroup others);
MediaSession2.CommandGroup fromBundle_MediaSession2CommandGroup(Context context, Bundle bundle);
MediaSession2.CommandGroup fromBundle_MediaSession2CommandGroup(Bundle bundle);
ControllerInfoProvider createMediaSession2ControllerInfo(Context context,
MediaSession2.ControllerInfo instance, int uid, int pid,
String packageName, IInterface callback);
CommandButtonProvider.BuilderProvider createMediaSession2CommandButtonBuilder(Context context,
CommandButtonProvider.BuilderProvider createMediaSession2CommandButtonBuilder(
MediaSession2.CommandButton.Builder instance);
BuilderBaseProvider<MediaSession2, SessionCallback> createMediaSession2Builder(
Context context, MediaSession2.Builder instance);
@@ -88,7 +88,7 @@ public interface StaticProvider {
SessionToken2 token, Executor executor, BrowserCallback callback);
MediaSessionService2Provider createMediaSessionService2(MediaSessionService2 instance);
MediaNotificationProvider createMediaSessionService2MediaNotification(Context context,
MediaNotificationProvider createMediaSessionService2MediaNotification(
MediaNotification mediaNotification, int notificationId, Notification notification);
MediaSessionService2Provider createMediaLibraryService2(MediaLibraryService2 instance);
@@ -96,33 +96,32 @@ public interface StaticProvider {
createMediaLibraryService2Builder(
MediaLibraryService2 service, MediaLibrarySession.Builder instance,
Executor callbackExecutor, MediaLibrarySessionCallback callback);
LibraryRootProvider createMediaLibraryService2LibraryRoot(Context context, LibraryRoot instance,
String rootId, Bundle extras);
LibraryRootProvider createMediaLibraryService2LibraryRoot(LibraryRoot instance, String rootId,
Bundle extras);
SessionToken2Provider createSessionToken2(Context context, SessionToken2 instance,
String packageName, String serviceName, int uid);
SessionToken2 fromBundle_SessionToken2(Context context, Bundle bundle);
SessionToken2 fromBundle_SessionToken2(Bundle bundle);
MediaItem2Provider.BuilderProvider createMediaItem2Builder(
Context context, MediaItem2.Builder instance, int flags);
MediaItem2 fromBundle_MediaItem2(Context context, Bundle bundle);
MediaItem2Provider.BuilderProvider createMediaItem2Builder(MediaItem2.Builder instance,
int flags);
MediaItem2 fromBundle_MediaItem2(Bundle bundle);
VolumeProvider2Provider createVolumeProvider2(Context context, VolumeProvider2 instance,
int controlType, int maxVolume, int currentVolume);
VolumeProvider2Provider createVolumeProvider2(VolumeProvider2 instance, int controlType,
int maxVolume, int currentVolume);
MediaMetadata2 fromBundle_MediaMetadata2(Context context, Bundle bundle);
MediaMetadata2 fromBundle_MediaMetadata2(Bundle bundle);
MediaMetadata2Provider.BuilderProvider createMediaMetadata2Builder(
Context context, MediaMetadata2.Builder instance);
MediaMetadata2.Builder instance);
MediaMetadata2Provider.BuilderProvider createMediaMetadata2Builder(
Context context, MediaMetadata2.Builder instance, MediaMetadata2 source);
MediaMetadata2.Builder instance, MediaMetadata2 source);
Rating2 newUnratedRating_Rating2(Context context, int ratingStyle);
Rating2 fromBundle_Rating2(Context context, Bundle bundle);
Rating2 newHeartRating_Rating2(Context context, boolean hasHeart);
Rating2 newThumbRating_Rating2(Context context, boolean thumbIsUp);
Rating2 newStarRating_Rating2(Context context, int starRatingStyle, float starRating);
Rating2 newPercentageRating_Rating2(Context context, float percent);
Rating2 newUnratedRating_Rating2(int ratingStyle);
Rating2 fromBundle_Rating2(Bundle bundle);
Rating2 newHeartRating_Rating2(boolean hasHeart);
Rating2 newThumbRating_Rating2(boolean thumbIsUp);
Rating2 newStarRating_Rating2(int starRatingStyle, float starRating);
Rating2 newPercentageRating_Rating2(float percent);
MediaPlaylistAgentProvider createMediaPlaylistAgent(Context context,
MediaPlaylistAgent instance);
MediaPlaylistAgentProvider createMediaPlaylistAgent(MediaPlaylistAgent instance);
}

View File

@@ -1532,7 +1532,7 @@ public class MediaSessionService extends SystemService implements Monitor {
@Override
public boolean createSession2(Bundle sessionToken) {
final int uid = Binder.getCallingUid();
final SessionToken2 token = SessionToken2.fromBundle(getContext(), sessionToken);
final SessionToken2 token = SessionToken2.fromBundle(sessionToken);
if (token == null || token.getUid() != uid) {
Log.w(TAG, "onSessionCreated failed, expected caller uid=" + token.getUid()
+ " but from uid=" + uid);
@@ -1571,7 +1571,7 @@ public class MediaSessionService extends SystemService implements Monitor {
@Override
public void destroySession2(Bundle sessionToken) {
final int uid = Binder.getCallingUid();
final SessionToken2 token = SessionToken2.fromBundle(getContext(), sessionToken);
final SessionToken2 token = SessionToken2.fromBundle(sessionToken);
if (token == null || token.getUid() != uid) {
Log.w(TAG, "onSessionDestroyed failed, expected caller uid=" + token.getUid()
+ " but from uid=" + uid);