Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 44583d35 authored by RoboErik's avatar RoboErik Committed by Android (Google) Code Review
Browse files

Merge changes I51f2e466,I5b67cb3e into lmp-dev

* changes:
  Make PlaybackState immutable with a builder
  Add API to set a default session in Activity
parents 2178cee0 c785a78f
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -3309,6 +3309,7 @@ package android.app {
    method public android.view.LayoutInflater getLayoutInflater();
    method public android.app.LoaderManager getLoaderManager();
    method public java.lang.String getLocalClassName();
    method public final android.media.session.MediaController getMediaController();
    method public android.view.MenuInflater getMenuInflater();
    method public final android.app.Activity getParent();
    method public android.content.Intent getParentActivityIntent();
@@ -3432,6 +3433,7 @@ package android.app {
    method public void setFinishOnTouchOutside(boolean);
    method public void setImmersive(boolean);
    method public void setIntent(android.content.Intent);
    method public final void setMediaController(android.media.session.MediaController);
    method public boolean setMediaPlaying(boolean);
    method public final void setProgress(int);
    method public final void setProgressBarIndeterminate(boolean);
@@ -16224,19 +16226,14 @@ package android.media.session {
  }
  public final class PlaybackState implements android.os.Parcelable {
    ctor public PlaybackState();
    ctor public PlaybackState(android.media.session.PlaybackState);
    method public int describeContents();
    method public long getActions();
    method public long getBufferPosition();
    method public java.lang.CharSequence getErrorMessage();
    method public float getPlaybackRate();
    method public long getLastPositionUpdateTime();
    method public float getPlaybackSpeed();
    method public long getPosition();
    method public int getState();
    method public void setActions(long);
    method public void setBufferPosition(long);
    method public void setErrorMessage(java.lang.CharSequence);
    method public void setState(int, long, float);
    method public void writeToParcel(android.os.Parcel, int);
    field public static final long ACTION_FAST_FORWARD = 64L; // 0x40L
    field public static final long ACTION_PAUSE = 2L; // 0x2L
@@ -16263,6 +16260,17 @@ package android.media.session {
    field public static final int STATE_STOPPED = 1; // 0x1
  }
  public static final class PlaybackState.Builder {
    ctor public PlaybackState.Builder();
    ctor public PlaybackState.Builder(android.media.session.PlaybackState);
    method public android.media.session.PlaybackState build();
    method public android.media.session.PlaybackState.Builder setActions(long);
    method public android.media.session.PlaybackState.Builder setBufferPosition(long);
    method public android.media.session.PlaybackState.Builder setErrorMessage(java.lang.CharSequence);
    method public android.media.session.PlaybackState.Builder setState(int, long, float, long);
    method public android.media.session.PlaybackState.Builder setState(int, long, float);
  }
}
package android.media.tv {
@@ -34285,6 +34293,7 @@ package android.view {
    method protected final int getForcedWindowFlags();
    method public abstract android.view.LayoutInflater getLayoutInflater();
    method protected final int getLocalFeatures();
    method public android.media.session.MediaController getMediaController();
    method public abstract int getNavigationBarColor();
    method public android.transition.Transition getSharedElementEnterTransition();
    method public android.transition.Transition getSharedElementExitTransition();
@@ -34341,6 +34350,7 @@ package android.view {
    method public void setLayout(int, int);
    method public void setLocalFocus(boolean, boolean);
    method public void setLogo(int);
    method public void setMediaController(android.media.session.MediaController);
    method public abstract void setNavigationBarColor(int);
    method public void setSharedElementEnterTransition(android.transition.Transition);
    method public void setSharedElementExitTransition(android.transition.Transition);
+413 −377
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.transition.TransitionManager;
import android.util.ArrayMap;
import android.util.SuperNotCalledException;
import android.widget.Toolbar;

import com.android.internal.app.IVoiceInteractor;
import com.android.internal.app.WindowDecorActionBar;
import com.android.internal.app.ToolbarActionBar;
@@ -51,6 +52,8 @@ import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.media.AudioManager;
import android.media.session.MediaController;
import android.media.session.MediaSession;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -5104,16 +5107,16 @@ public class Activity extends ContextThemeWrapper
     * volume controls.
     * <p>
     * The suggested audio stream will be tied to the window of this Activity.
     * If the Activity is switched, the stream set here is no longer the
     * suggested stream. The client does not need to save and restore the old
     * suggested stream value in onPause and onResume.
     * Volume requests which are received while the Activity is in the
     * foreground will affect this stream.
     * <p>
     * It is not guaranteed that the hardware volume controls will always change
     * this stream's volume (for example, if a call is in progress, its stream's
     * volume may be changed instead). To reset back to the default, use
     * {@link AudioManager#USE_DEFAULT_STREAM_TYPE}.
     *
     * @param streamType The type of the audio stream whose volume should be
     *        changed by the hardware volume controls. It is not guaranteed that
     *        the hardware volume controls will always change this stream's
     *        volume (for example, if a call is in progress, its stream's volume
     *        may be changed instead). To reset back to the default, use
     *        {@link AudioManager#USE_DEFAULT_STREAM_TYPE}.
     *            changed by the hardware volume controls.
     */
    public final void setVolumeControlStream(int streamType) {
        getWindow().setVolumeControlStream(streamType);
@@ -5131,6 +5134,39 @@ public class Activity extends ContextThemeWrapper
        return getWindow().getVolumeControlStream();
    }

    /**
     * Sets a {@link MediaController} to send media keys and volume changes to.
     * <p>
     * The controller will be tied to the window of this Activity. Media key and
     * volume events which are received while the Activity is in the foreground
     * will be forwarded to the controller and used to invoke transport controls
     * or adjust the volume. This may be used instead of or in addition to
     * {@link #setVolumeControlStream} to affect a specific session instead of a
     * specific stream.
     * <p>
     * It is not guaranteed that the hardware volume controls will always change
     * this session's volume (for example, if a call is in progress, its
     * stream's volume may be changed instead). To reset back to the default use
     * null as the controller.
     *
     * @param controller The controller for the session which should receive
     *            media keys and volume changes.
     */
    public final void setMediaController(MediaController controller) {
        getWindow().setMediaController(controller);
    }

    /**
     * Gets the controller which should be receiving media key and volume events
     * while this activity is in the foreground.
     *
     * @return The controller which should receive events.
     * @see #setMediaController(android.media.session.MediaController)
     */
    public final MediaController getMediaController() {
        return getWindow().getMediaController();
    }

    /**
     * Runs the specified action on the UI thread. If the current thread is the UI
     * thread, then the action is executed immediately. If the current thread is
+57 −42
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.media.session.MediaController;
import android.media.session.MediaSession;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
@@ -1301,6 +1303,19 @@ public abstract class Window {
     */
    public abstract int getVolumeControlStream();

    /**
     * @see android.app.Activity#setMediaController(android.media.session.MediaController)
     */
    public void setMediaController(MediaController controller) {
    }

    /**
     * @see android.app.Activity#getMediaController()
     */
    public MediaController getMediaController() {
        return null;
    }

    /**
     * Set extra options that will influence the UI for this window.
     * @param uiOptions Flags specifying extra options for this window.
+11 −6
Original line number Diff line number Diff line
@@ -682,9 +682,13 @@ public class RemoteControlClient
                // USE_SESSIONS
                if (mSession != null) {
                    int pbState = PlaybackState.getStateFromRccState(state);
                    mSessionPlaybackState.setState(pbState, hasPosition ?
                            mPlaybackPositionMs : PlaybackState.PLAYBACK_POSITION_UNKNOWN,
                            playbackSpeed);
                    long position = hasPosition ? mPlaybackPositionMs
                            : PlaybackState.PLAYBACK_POSITION_UNKNOWN;

                    PlaybackState.Builder bob = new PlaybackState.Builder(mSessionPlaybackState);
                    bob.setState(pbState, position, playbackSpeed, SystemClock.elapsedRealtime());
                    bob.setErrorMessage(null);
                    mSessionPlaybackState = bob.build();
                    mSession.setPlaybackState(mSessionPlaybackState);
                }
            }
@@ -745,8 +749,9 @@ public class RemoteControlClient

            // USE_SESSIONS
            if (mSession != null) {
                mSessionPlaybackState.setActions(PlaybackState
                        .getActionsFromRccControlFlags(transportControlFlags));
                PlaybackState.Builder bob = new PlaybackState.Builder(mSessionPlaybackState);
                bob.setActions(PlaybackState.getActionsFromRccControlFlags(transportControlFlags));
                mSessionPlaybackState = bob.build();
                mSession.setPlaybackState(mSessionPlaybackState);
            }
        }
@@ -946,7 +951,7 @@ public class RemoteControlClient
    /**
     * Cache for the current playback state using Session APIs.
     */
    private final PlaybackState mSessionPlaybackState = new PlaybackState();
    private PlaybackState mSessionPlaybackState = null;

    /**
     * Cache for metadata using Session APIs. This is re-initialized in apply().
+1 −1
Original line number Diff line number Diff line
@@ -1020,7 +1020,7 @@ public final class RemoteController
                l.onClientPlaybackStateUpdate(playstate);
            } else {
                l.onClientPlaybackStateUpdate(playstate, state.getLastPositionUpdateTime(),
                        state.getPosition(), state.getPlaybackRate());
                        state.getPosition(), state.getPlaybackSpeed());
            }
            if (state != null) {
                l.onClientTransportControlUpdate(PlaybackState.getRccControlFlagsFromActions(state
Loading