diff options
| -rw-r--r-- | core/java/android/widget/MediaControlView2.java | 229 | ||||
| -rw-r--r-- | core/java/android/widget/VideoView2.java | 452 | ||||
| -rw-r--r-- | media/java/android/media/update/MediaControlView2Provider.java | 52 | ||||
| -rw-r--r-- | media/java/android/media/update/StaticProvider.java | 11 | ||||
| -rw-r--r-- | media/java/android/media/update/VideoView2Provider.java | 99 | ||||
| -rw-r--r-- | media/java/android/media/update/ViewGroupHelper.java | 369 | ||||
| -rw-r--r-- | media/java/android/media/update/ViewGroupProvider.java | 67 |
7 files changed, 0 insertions, 1279 deletions
diff --git a/core/java/android/widget/MediaControlView2.java b/core/java/android/widget/MediaControlView2.java deleted file mode 100644 index f52854a87159..000000000000 --- a/core/java/android/widget/MediaControlView2.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright (C) 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.widget; - -import android.annotation.IntDef; -import android.annotation.NonNull; -import android.annotation.Nullable; -import android.content.Context; -import android.media.SessionToken2; -import android.media.session.MediaController; -import android.media.update.ApiLoader; -import android.media.update.MediaControlView2Provider; -import android.media.update.ViewGroupHelper; -import android.util.AttributeSet; -import android.view.View; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -// TODO: Use link annotation to refer VideoView2 once VideoView2 became unhidden. -/** - * @hide - * A View that contains the controls for MediaPlayer2. - * It provides a wide range of UI including buttons such as "Play/Pause", "Rewind", "Fast Forward", - * "Subtitle", "Full Screen", and it is also possible to add multiple custom buttons. - * - * <p> - * <em> MediaControlView2 can be initialized in two different ways: </em> - * 1) When VideoView2 is initialized, it automatically initializes a MediaControlView2 instance and - * adds it to the view. - * 2) Initialize MediaControlView2 programmatically and add it to a ViewGroup instance. - * - * In the first option, VideoView2 automatically connects MediaControlView2 to MediaController, - * which is necessary to communicate with MediaSession2. In the second option, however, the - * developer needs to manually retrieve a MediaController instance and set it to MediaControlView2 - * by calling setController(MediaController controller). - * - * <p> - * There is no separate method that handles the show/hide behavior for MediaControlView2. Instead, - * one can directly change the visibility of this view by calling View.setVisibility(int). The - * values supported are View.VISIBLE and View.GONE. - * In addition, the following customization is supported: - * Set focus to the play/pause button by calling requestPlayButtonFocus(). - * - * <p> - * It is also possible to add custom buttons with custom icons and actions inside MediaControlView2. - * Those buttons will be shown when the overflow button is clicked. - * See VideoView2#setCustomActions for more details on how to add. - */ -public class MediaControlView2 extends ViewGroupHelper<MediaControlView2Provider> { - /** @hide */ - @IntDef({ - BUTTON_PLAY_PAUSE, - BUTTON_FFWD, - BUTTON_REW, - BUTTON_NEXT, - BUTTON_PREV, - BUTTON_SUBTITLE, - BUTTON_FULL_SCREEN, - BUTTON_OVERFLOW, - BUTTON_MUTE, - BUTTON_ASPECT_RATIO, - BUTTON_SETTINGS - }) - @Retention(RetentionPolicy.SOURCE) - public @interface Button {} - - /** - * MediaControlView2 button value for playing and pausing media. - * @hide - */ - public static final int BUTTON_PLAY_PAUSE = 1; - /** - * MediaControlView2 button value for jumping 30 seconds forward. - * @hide - */ - public static final int BUTTON_FFWD = 2; - /** - * MediaControlView2 button value for jumping 10 seconds backward. - * @hide - */ - public static final int BUTTON_REW = 3; - /** - * MediaControlView2 button value for jumping to next media. - * @hide - */ - public static final int BUTTON_NEXT = 4; - /** - * MediaControlView2 button value for jumping to previous media. - * @hide - */ - public static final int BUTTON_PREV = 5; - /** - * MediaControlView2 button value for showing/hiding subtitle track. - * @hide - */ - public static final int BUTTON_SUBTITLE = 6; - /** - * MediaControlView2 button value for toggling full screen. - * @hide - */ - public static final int BUTTON_FULL_SCREEN = 7; - /** - * MediaControlView2 button value for showing/hiding overflow buttons. - * @hide - */ - public static final int BUTTON_OVERFLOW = 8; - /** - * MediaControlView2 button value for muting audio. - * @hide - */ - public static final int BUTTON_MUTE = 9; - /** - * MediaControlView2 button value for adjusting aspect ratio of view. - * @hide - */ - public static final int BUTTON_ASPECT_RATIO = 10; - /** - * MediaControlView2 button value for showing/hiding settings page. - * @hide - */ - public static final int BUTTON_SETTINGS = 11; - - public MediaControlView2(@NonNull Context context) { - this(context, null); - } - - public MediaControlView2(@NonNull Context context, @Nullable AttributeSet attrs) { - this(context, attrs, 0); - } - - public MediaControlView2(@NonNull Context context, @Nullable AttributeSet attrs, - int defStyleAttr) { - this(context, attrs, defStyleAttr, 0); - } - - public MediaControlView2(@NonNull Context context, @Nullable AttributeSet attrs, - int defStyleAttr, int defStyleRes) { - super((instance, superProvider, privateProvider) -> - ApiLoader.getProvider().createMediaControlView2( - (MediaControlView2) instance, superProvider, privateProvider, - attrs, defStyleAttr, defStyleRes), - context, attrs, defStyleAttr, defStyleRes); - mProvider.initialize(attrs, defStyleAttr, defStyleRes); - } - - /** - * Sets MediaSession2 token to control corresponding MediaSession2. - */ - public void setMediaSessionToken(SessionToken2 token) { - mProvider.setMediaSessionToken_impl(token); - } - - /** - * Registers a callback to be invoked when the fullscreen mode should be changed. - * @param l The callback that will be run - */ - public void setOnFullScreenListener(OnFullScreenListener l) { - mProvider.setOnFullScreenListener_impl(l); - } - - /** - * @hide TODO: remove once the implementation is revised - */ - public void setController(MediaController controller) { - mProvider.setController_impl(controller); - } - - /** - * Changes the visibility state of an individual button. Default value is View.Visible. - * - * @param button the {@code Button} assigned to individual buttons - * <ul> - * <li>{@link #BUTTON_PLAY_PAUSE} - * <li>{@link #BUTTON_FFWD} - * <li>{@link #BUTTON_REW} - * <li>{@link #BUTTON_NEXT} - * <li>{@link #BUTTON_PREV} - * <li>{@link #BUTTON_SUBTITLE} - * <li>{@link #BUTTON_FULL_SCREEN} - * <li>{@link #BUTTON_MUTE} - * <li>{@link #BUTTON_OVERFLOW} - * <li>{@link #BUTTON_ASPECT_RATIO} - * <li>{@link #BUTTON_SETTINGS} - * </ul> - * @param visibility One of {@link #VISIBLE}, {@link #INVISIBLE}, or {@link #GONE}. - * @hide - */ - public void setButtonVisibility(@Button int button, @Visibility int visibility) { - mProvider.setButtonVisibility_impl(button, visibility); - } - - /** - * Requests focus for the play/pause button. - */ - public void requestPlayButtonFocus() { - mProvider.requestPlayButtonFocus_impl(); - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - mProvider.onLayout_impl(changed, l, t, r, b); - } - - /** - * Interface definition of a callback to be invoked to inform the fullscreen mode is changed. - * Application should handle the fullscreen mode accordingly. - */ - public interface OnFullScreenListener { - /** - * Called to indicate a fullscreen mode change. - */ - void onFullScreen(View view, boolean fullScreen); - } -} diff --git a/core/java/android/widget/VideoView2.java b/core/java/android/widget/VideoView2.java deleted file mode 100644 index 0724294a4e22..000000000000 --- a/core/java/android/widget/VideoView2.java +++ /dev/null @@ -1,452 +0,0 @@ -/* - * Copyright 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.widget; - -import android.annotation.IntDef; -import android.annotation.NonNull; -import android.annotation.Nullable; -import android.annotation.UnsupportedAppUsage; -import android.content.Context; -import android.media.AudioAttributes; -import android.media.AudioManager; -import android.media.DataSourceDesc; -import android.media.MediaItem2; -import android.media.MediaMetadata2; -import android.media.MediaPlayer2; -import android.media.SessionToken2; -import android.media.session.MediaController; -import android.media.session.PlaybackState; -import android.media.update.ApiLoader; -import android.media.update.VideoView2Provider; -import android.media.update.ViewGroupHelper; -import android.net.Uri; -import android.os.Bundle; -import android.util.AttributeSet; -import android.view.View; - -import com.android.internal.annotations.VisibleForTesting; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Executor; - -// TODO: Replace MediaSession wtih MediaSession2 once MediaSession2 is submitted. -/** - * @hide - * Displays a video file. VideoView2 class is a View class which is wrapping {@link MediaPlayer2} - * so that developers can easily implement a video rendering application. - * - * <p> - * <em> Data sources that VideoView2 supports : </em> - * VideoView2 can play video files and audio-only files as - * well. It can load from various sources such as resources or content providers. The supported - * media file formats are the same as {@link MediaPlayer2}. - * - * <p> - * <em> View type can be selected : </em> - * VideoView2 can render videos on top of TextureView as well as - * SurfaceView selectively. The default is SurfaceView and it can be changed using - * {@link #setViewType(int)} method. Using SurfaceView is recommended in most cases for saving - * battery. TextureView might be preferred for supporting various UIs such as animation and - * translucency. - * - * <p> - * <em> Differences between {@link VideoView} class : </em> - * VideoView2 covers and inherits the most of - * VideoView's functionalities. The main differences are - * <ul> - * <li> VideoView2 inherits FrameLayout and renders videos using SurfaceView and TextureView - * selectively while VideoView inherits SurfaceView class. - * <li> VideoView2 is integrated with MediaControlView2 and a default MediaControlView2 instance is - * attached to VideoView2 by default. If a developer does not want to use the default - * MediaControlView2, needs to set enableControlView attribute to false. For instance, - * <pre> - * <VideoView2 - * android:id="@+id/video_view" - * xmlns:widget="http://schemas.android.com/apk/com.android.media.update" - * widget:enableControlView="false" /> - * </pre> - * If a developer wants to attach a customed MediaControlView2, then set enableControlView attribute - * to false and assign the customed media control widget using {@link #setMediaControlView2}. - * <li> VideoView2 is integrated with MediaPlayer2 while VideoView is integrated with MediaPlayer. - * <li> VideoView2 is integrated with MediaSession and so it responses with media key events. - * A VideoView2 keeps a MediaSession instance internally and connects it to a corresponding - * MediaControlView2 instance. - * </p> - * </ul> - * - * <p> - * <em> Audio focus and audio attributes : </em> - * By default, VideoView2 requests audio focus with - * {@link AudioManager#AUDIOFOCUS_GAIN}. Use {@link #setAudioFocusRequest(int)} to change this - * behavior. The default {@link AudioAttributes} used during playback have a usage of - * {@link AudioAttributes#USAGE_MEDIA} and a content type of - * {@link AudioAttributes#CONTENT_TYPE_MOVIE}, use {@link #setAudioAttributes(AudioAttributes)} to - * modify them. - * - * <p> - * Note: VideoView2 does not retain its full state when going into the background. In particular, it - * does not restore the current play state, play position, selected tracks. Applications should save - * and restore these on their own in {@link android.app.Activity#onSaveInstanceState} and - * {@link android.app.Activity#onRestoreInstanceState}. - */ -public class VideoView2 extends ViewGroupHelper<VideoView2Provider> { - /** @hide */ - @IntDef({ - VIEW_TYPE_TEXTUREVIEW, - VIEW_TYPE_SURFACEVIEW - }) - @Retention(RetentionPolicy.SOURCE) - public @interface ViewType {} - - /** - * Indicates video is rendering on SurfaceView. - * - * @see #setViewType - */ - public static final int VIEW_TYPE_SURFACEVIEW = 1; - - /** - * Indicates video is rendering on TextureView. - * - * @see #setViewType - */ - public static final int VIEW_TYPE_TEXTUREVIEW = 2; - - public VideoView2(@NonNull Context context) { - this(context, null); - } - - public VideoView2(@NonNull Context context, @Nullable AttributeSet attrs) { - this(context, attrs, 0); - } - - public VideoView2(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { - this(context, attrs, defStyleAttr, 0); - } - - public VideoView2( - @NonNull Context context, @Nullable AttributeSet attrs, - int defStyleAttr, int defStyleRes) { - super((instance, superProvider, privateProvider) -> - ApiLoader.getProvider().createVideoView2( - (VideoView2) instance, superProvider, privateProvider, - attrs, defStyleAttr, defStyleRes), - context, attrs, defStyleAttr, defStyleRes); - mProvider.initialize(attrs, defStyleAttr, defStyleRes); - } - - /** - * Sets MediaControlView2 instance. It will replace the previously assigned MediaControlView2 - * instance if any. - * - * @param mediaControlView a media control view2 instance. - * @param intervalMs a time interval in milliseconds until VideoView2 hides MediaControlView2. - */ - public void setMediaControlView2(MediaControlView2 mediaControlView, long intervalMs) { - mProvider.setMediaControlView2_impl(mediaControlView, intervalMs); - } - - /** - * Returns MediaControlView2 instance which is currently attached to VideoView2 by default or by - * {@link #setMediaControlView2} method. - */ - public MediaControlView2 getMediaControlView2() { - return mProvider.getMediaControlView2_impl(); - } - - /** - * Sets MediaMetadata2 instance. It will replace the previously assigned MediaMetadata2 instance - * if any. - * - * @param metadata a MediaMetadata2 instance. - * @hide - */ - public void setMediaMetadata(MediaMetadata2 metadata) { - mProvider.setMediaMetadata_impl(metadata); - } - - /** - * Returns MediaMetadata2 instance which is retrieved from MediaPlayer2 inside VideoView2 by - * default or by {@link #setMediaMetadata} method. - * @hide - */ - public MediaMetadata2 getMediaMetadata() { - // TODO: add to Javadoc whether this value can be null or not when integrating with - // MediaSession2. - return mProvider.getMediaMetadata_impl(); - } - - /** - * Returns MediaController instance which is connected with MediaSession that VideoView2 is - * using. This method should be called when VideoView2 is attached to window, or it throws - * IllegalStateException, since internal MediaSession instance is not available until - * this view is attached to window. Please check {@link android.view.View#isAttachedToWindow} - * before calling this method. - * - * @throws IllegalStateException if interal MediaSession is not created yet. - * @hide TODO: remove - */ - @UnsupportedAppUsage - public MediaController getMediaController() { - return mProvider.getMediaController_impl(); - } - - /** - * Returns {@link android.media.SessionToken2} so that developers create their own - * {@link android.media.MediaController2} instance. This method should be called when VideoView2 - * is attached to window, or it throws IllegalStateException. - * - * @throws IllegalStateException if interal MediaSession is not created yet. - */ - public SessionToken2 getMediaSessionToken() { - return mProvider.getMediaSessionToken_impl(); - } - - /** - * Shows or hides closed caption or subtitles if there is any. - * The first subtitle track will be chosen if there multiple subtitle tracks exist. - * Default behavior of VideoView2 is not showing subtitle. - * @param enable shows closed caption or subtitles if this value is true, or hides. - */ - public void setSubtitleEnabled(boolean enable) { - mProvider.setSubtitleEnabled_impl(enable); - } - - /** - * Returns true if showing subtitle feature is enabled or returns false. - * Although there is no subtitle track or closed caption, it can return true, if the feature - * has been enabled by {@link #setSubtitleEnabled}. - */ - public boolean isSubtitleEnabled() { - return mProvider.isSubtitleEnabled_impl(); - } - - /** - * Sets playback speed. - * - * It is expressed as a multiplicative factor, where normal speed is 1.0f. If it is less than - * or equal to zero, it will be just ignored and nothing will be changed. If it exceeds the - * maximum speed that internal engine supports, system will determine best handling or it will - * be reset to the normal speed 1.0f. - * @param speed the playback speed. It should be positive. - */ - // TODO: Support this via MediaController2. - public void setSpeed(float speed) { - mProvider.setSpeed_impl(speed); - } - - /** - * Sets which type of audio focus will be requested during the playback, or configures playback - * to not request audio focus. Valid values for focus requests are - * {@link AudioManager#AUDIOFOCUS_GAIN}, {@link AudioManager#AUDIOFOCUS_GAIN_TRANSIENT}, - * {@link AudioManager#AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK}, and - * {@link AudioManager#AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE}. Or use - * {@link AudioManager#AUDIOFOCUS_NONE} to express that audio focus should not be - * requested when playback starts. You can for instance use this when playing a silent animation - * through this class, and you don't want to affect other audio applications playing in the - * background. - * - * @param focusGain the type of audio focus gain that will be requested, or - * {@link AudioManager#AUDIOFOCUS_NONE} to disable the use audio focus during - * playback. - */ - public void setAudioFocusRequest(int focusGain) { - mProvider.setAudioFocusRequest_impl(focusGain); - } - - /** - * Sets the {@link AudioAttributes} to be used during the playback of the video. - * - * @param attributes non-null <code>AudioAttributes</code>. - */ - public void setAudioAttributes(@NonNull AudioAttributes attributes) { - mProvider.setAudioAttributes_impl(attributes); - } - - /** - * Sets video path. - * - * @param path the path of the video. - * - * @hide TODO remove - */ - @UnsupportedAppUsage - public void setVideoPath(String path) { - mProvider.setVideoPath_impl(path); - } - - /** - * Sets video URI. - * - * @param uri the URI of the video. - * - * @hide TODO remove - */ - public void setVideoUri(Uri uri) { - mProvider.setVideoUri_impl(uri); - } - - /** - * Sets video URI using specific headers. - * - * @param uri the URI of the video. - * @param headers the headers for the URI request. - * Note that the cross domain redirection is allowed by default, but that can be - * changed with key/value pairs through the headers parameter with - * "android-allow-cross-domain-redirect" as the key and "0" or "1" as the value - * to disallow or allow cross domain redirection. - * - * @hide TODO remove - */ - public void setVideoUri(Uri uri, Map<String, String> headers) { - mProvider.setVideoUri_impl(uri, headers); - } - - /** - * Sets {@link MediaItem2} object to render using VideoView2. Alternative way to set media - * object to VideoView2 is {@link #setDataSource}. - * @param mediaItem the MediaItem2 to play - * @see #setDataSource - */ - public void setMediaItem(@NonNull MediaItem2 mediaItem) { - mProvider.setMediaItem_impl(mediaItem); - } - - /** - * Sets {@link DataSourceDesc} object to render using VideoView2. - * @param dataSource the {@link DataSourceDesc} object to play. - * @see #setMediaItem - */ - public void setDataSource(@NonNull DataSourceDesc dataSource) { - mProvider.setDataSource_impl(dataSource); - } - - /** - * Selects which view will be used to render video between SurfacView and TextureView. - * - * @param viewType the view type to render video - * <ul> - * <li>{@link #VIEW_TYPE_SURFACEVIEW} - * <li>{@link #VIEW_TYPE_TEXTUREVIEW} - * </ul> - */ - public void setViewType(@ViewType int viewType) { - mProvider.setViewType_impl(viewType); - } - - /** - * Returns view type. - * - * @return view type. See {@see setViewType}. - */ - @ViewType - public int getViewType() { - return mProvider.getViewType_impl(); - } - - /** - * Sets custom actions which will be shown as custom buttons in {@link MediaControlView2}. - * - * @param actionList A list of {@link PlaybackState.CustomAction}. The return value of - * {@link PlaybackState.CustomAction#getIcon()} will be used to draw buttons - * in {@link MediaControlView2}. - * @param executor executor to run callbacks on. - * @param listener A listener to be called when a custom button is clicked. - * @hide TODO remove - */ - public void setCustomActions(List<PlaybackState.CustomAction> actionList, - Executor executor, OnCustomActionListener listener) { - mProvider.setCustomActions_impl(actionList, executor, listener); - } - - /** - * Registers a callback to be invoked when a view type change is done. - * {@see #setViewType(int)} - * @param l The callback that will be run - * @hide - */ - @VisibleForTesting - @UnsupportedAppUsage - public void setOnViewTypeChangedListener(OnViewTypeChangedListener l) { - mProvider.setOnViewTypeChangedListener_impl(l); - } - - /** - * Registers a callback to be invoked when the fullscreen mode should be changed. - * @param l The callback that will be run - * @hide TODO remove - */ - public void setFullScreenRequestListener(OnFullScreenRequestListener l) { - mProvider.setFullScreenRequestListener_impl(l); - } - - /** - * Interface definition of a callback to be invoked when the view type has been changed. - * - * @hide - */ - @VisibleForTesting - public interface OnViewTypeChangedListener { - /** - * Called when the view type has been changed. - * @see #setViewType(int) - * @param view the View whose view type is changed - * @param viewType - * <ul> - * <li>{@link #VIEW_TYPE_SURFACEVIEW} - * <li>{@link #VIEW_TYPE_TEXTUREVIEW} - * </ul> - */ - @UnsupportedAppUsage - void onViewTypeChanged(View view, @ViewType int viewType); - } - - /** - * Interface definition of a callback to be invoked to inform the fullscreen mode is changed. - * Application should handle the fullscreen mode accordingly. - * @hide TODO remove - */ - public interface OnFullScreenRequestListener { - /** - * Called to indicate a fullscreen mode change. - */ - void onFullScreenRequest(View view, boolean fullScreen); - } - - /** - * Interface definition of a callback to be invoked to inform that a custom action is performed. - * @hide TODO remove - */ - public interface OnCustomActionListener { - /** - * Called to indicate that a custom action is performed. - * - * @param action The action that was originally sent in the - * {@link PlaybackState.CustomAction}. - * @param extras Optional extras. - */ - void onCustomAction(String action, Bundle extras); - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - mProvider.onLayout_impl(changed, l, t, r, b); - } -} diff --git a/media/java/android/media/update/MediaControlView2Provider.java b/media/java/android/media/update/MediaControlView2Provider.java deleted file mode 100644 index 8e69653c6a31..000000000000 --- a/media/java/android/media/update/MediaControlView2Provider.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2017 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.media.update; - -import android.media.SessionToken2; -import android.media.session.MediaController; -import android.util.AttributeSet; -import android.widget.MediaControlView2; - -/** - * Interface for connecting the public API to an updatable implementation. - * - * Each instance object is connected to one corresponding updatable object which implements the - * runtime behavior of that class. There should a corresponding provider method for all public - * methods. - * - * All methods behave as per their namesake in the public API. - * - * @see android.widget.MediaControlView2 - * - * @hide - */ -// TODO: @SystemApi -public interface MediaControlView2Provider extends ViewGroupProvider { - void initialize(AttributeSet attrs, int defStyleAttr, int defStyleRes); - - void setMediaSessionToken_impl(SessionToken2 token); - void setOnFullScreenListener_impl(MediaControlView2.OnFullScreenListener l); - /** - * @hide TODO: remove - */ - void setController_impl(MediaController controller); - /** - * @hide - */ - void setButtonVisibility_impl(int button, int visibility); - void requestPlayButtonFocus_impl(); -} diff --git a/media/java/android/media/update/StaticProvider.java b/media/java/android/media/update/StaticProvider.java index 8687b802add8..2bc17a9f1c08 100644 --- a/media/java/android/media/update/StaticProvider.java +++ b/media/java/android/media/update/StaticProvider.java @@ -16,7 +16,6 @@ package android.media.update; -import android.annotation.Nullable; import android.app.Notification; import android.content.Context; import android.media.MediaBrowser2; @@ -48,9 +47,6 @@ import android.media.update.MediaSession2Provider.ControllerInfoProvider; import android.media.update.MediaSessionService2Provider.MediaNotificationProvider; import android.os.Bundle; import android.os.IInterface; -import android.util.AttributeSet; -import android.widget.MediaControlView2; -import android.widget.VideoView2; import java.util.concurrent.Executor; @@ -62,13 +58,6 @@ import java.util.concurrent.Executor; * @hide */ public interface StaticProvider { - MediaControlView2Provider createMediaControlView2(MediaControlView2 instance, - ViewGroupProvider superProvider, ViewGroupProvider privateProvider, - @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes); - VideoView2Provider createVideoView2(VideoView2 instance, - ViewGroupProvider superProvider, ViewGroupProvider privateProvider, - @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes); - CommandProvider createMediaSession2Command(SessionCommand2 instance, int commandCode, String action, Bundle extra); SessionCommand2 fromBundle_MediaSession2Command(Bundle bundle); diff --git a/media/java/android/media/update/VideoView2Provider.java b/media/java/android/media/update/VideoView2Provider.java deleted file mode 100644 index 27b436fd1b79..000000000000 --- a/media/java/android/media/update/VideoView2Provider.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.media.update; - -import android.annotation.SystemApi; -import android.media.AudioAttributes; -import android.media.DataSourceDesc; -import android.media.MediaItem2; -import android.media.MediaMetadata2; -import android.media.MediaPlayerBase; -import android.media.SessionToken2; -import android.media.session.MediaController; -import android.media.session.PlaybackState; -import android.media.session.MediaSession; -import android.net.Uri; -import android.util.AttributeSet; -import android.widget.MediaControlView2; -import android.widget.VideoView2; - -import com.android.internal.annotations.VisibleForTesting; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.Executor; - -/** - * Interface for connecting the public API to an updatable implementation. - * - * Each instance object is connected to one corresponding updatable object which implements the - * runtime behavior of that class. There should a corresponding provider method for all public - * methods. - * - * All methods behave as per their namesake in the public API. - * - * @see android.widget.VideoView2 - * - * @hide - */ -// TODO @SystemApi -public interface VideoView2Provider extends ViewGroupProvider { - void initialize(AttributeSet attrs, int defStyleAttr, int defStyleRes); - - void setMediaControlView2_impl(MediaControlView2 mediaControlView, long intervalMs); - void setMediaMetadata_impl(MediaMetadata2 metadata); - /** - * @hide TODO: remove - */ - MediaController getMediaController_impl(); - SessionToken2 getMediaSessionToken_impl(); - MediaControlView2 getMediaControlView2_impl(); - MediaMetadata2 getMediaMetadata_impl(); - void setSubtitleEnabled_impl(boolean enable); - boolean isSubtitleEnabled_impl(); - // TODO: remove setSpeed_impl once MediaController2 is ready. - void setSpeed_impl(float speed); - void setAudioFocusRequest_impl(int focusGain); - void setAudioAttributes_impl(AudioAttributes attributes); - void setVideoPath_impl(String path); - /** - * @hide TODO: remove - */ - void setVideoUri_impl(Uri uri); - /** - * @hide TODO: remove - */ - void setVideoUri_impl(Uri uri, Map<String, String> headers); - void setMediaItem_impl(MediaItem2 mediaItem); - void setDataSource_impl(DataSourceDesc dsd); - void setViewType_impl(int viewType); - int getViewType_impl(); - /** - * @hide TODO: remove - */ - void setCustomActions_impl(List<PlaybackState.CustomAction> actionList, - Executor executor, VideoView2.OnCustomActionListener listener); - /** - * @hide - */ - @VisibleForTesting - void setOnViewTypeChangedListener_impl(VideoView2.OnViewTypeChangedListener l); - /** - * @hide TODO: remove - */ - void setFullScreenRequestListener_impl(VideoView2.OnFullScreenRequestListener l); -} diff --git a/media/java/android/media/update/ViewGroupHelper.java b/media/java/android/media/update/ViewGroupHelper.java deleted file mode 100644 index 6b4f15d0fdb7..000000000000 --- a/media/java/android/media/update/ViewGroupHelper.java +++ /dev/null @@ -1,369 +0,0 @@ -/* - * Copyright 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.media.update; - -import android.content.Context; -import android.graphics.Canvas; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewGroup; - -/** - * Helper class for connecting the public API to an updatable implementation. - * - * @see ViewGroupProvider - * - * @hide - */ -public abstract class ViewGroupHelper<T extends ViewGroupProvider> extends ViewGroup { - /** @hide */ - final public T mProvider; - - /** @hide */ - public ViewGroupHelper(ProviderCreator<T> creator, - Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { - super(context, attrs, defStyleAttr, defStyleRes); - - mProvider = creator.createProvider(this, new SuperProvider(), - new PrivateProvider()); - } - - /** @hide */ - // TODO @SystemApi - public T getProvider() { - return mProvider; - } - - @Override - protected void onAttachedToWindow() { - mProvider.onAttachedToWindow_impl(); - } - - @Override - protected void onDetachedFromWindow() { - mProvider.onDetachedFromWindow_impl(); - } - - @Override - public CharSequence getAccessibilityClassName() { - return mProvider.getAccessibilityClassName_impl(); - } - - @Override - public boolean onTouchEvent(MotionEvent ev) { - return mProvider.onTouchEvent_impl(ev); - } - - @Override - public boolean onTrackballEvent(MotionEvent ev) { - return mProvider.onTrackballEvent_impl(ev); - } - - @Override - public void onFinishInflate() { - mProvider.onFinishInflate_impl(); - } - - @Override - public void setEnabled(boolean enabled) { - mProvider.setEnabled_impl(enabled); - } - - @Override - public void onVisibilityAggregated(boolean isVisible) { - mProvider.onVisibilityAggregated_impl(isVisible); - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - mProvider.onLayout_impl(changed, left, top, right, bottom); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - mProvider.onMeasure_impl(widthMeasureSpec, heightMeasureSpec); - } - - @Override - protected int getSuggestedMinimumWidth() { - return mProvider.getSuggestedMinimumWidth_impl(); - } - - @Override - protected int getSuggestedMinimumHeight() { - return mProvider.getSuggestedMinimumHeight_impl(); - } - - // setMeasuredDimension is final - - @Override - public boolean dispatchTouchEvent(MotionEvent ev) { - return mProvider.dispatchTouchEvent_impl(ev); - } - - @Override - protected boolean checkLayoutParams(LayoutParams p) { - return mProvider.checkLayoutParams_impl(p); - } - - @Override - protected LayoutParams generateDefaultLayoutParams() { - return mProvider.generateDefaultLayoutParams_impl(); - } - - @Override - public LayoutParams generateLayoutParams(AttributeSet attrs) { - return mProvider.generateLayoutParams_impl(attrs); - } - - @Override - protected LayoutParams generateLayoutParams(LayoutParams lp) { - return mProvider.generateLayoutParams_impl(lp); - } - - @Override - public boolean shouldDelayChildPressedState() { - return mProvider.shouldDelayChildPressedState_impl(); - } - - @Override - protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, - int parentHeightMeasureSpec, int heightUsed) { - mProvider.measureChildWithMargins_impl(child, - parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed); - } - - /** @hide */ - public class SuperProvider implements ViewGroupProvider { - @Override - public CharSequence getAccessibilityClassName_impl() { - return ViewGroupHelper.super.getAccessibilityClassName(); - } - - @Override - public boolean onTouchEvent_impl(MotionEvent ev) { - return ViewGroupHelper.super.onTouchEvent(ev); - } - - @Override - public boolean onTrackballEvent_impl(MotionEvent ev) { - return ViewGroupHelper.super.onTrackballEvent(ev); - } - - @Override - public void onFinishInflate_impl() { - ViewGroupHelper.super.onFinishInflate(); - } - - @Override - public void setEnabled_impl(boolean enabled) { - ViewGroupHelper.super.setEnabled(enabled); - } - - @Override - public void onAttachedToWindow_impl() { - ViewGroupHelper.super.onAttachedToWindow(); - } - - @Override - public void onDetachedFromWindow_impl() { - ViewGroupHelper.super.onDetachedFromWindow(); - } - - @Override - public void onVisibilityAggregated_impl(boolean isVisible) { - ViewGroupHelper.super.onVisibilityAggregated(isVisible); - } - - @Override - public void onLayout_impl(boolean changed, int left, int top, int right, int bottom) { - // abstract method; no super - } - - @Override - public void onMeasure_impl(int widthMeasureSpec, int heightMeasureSpec) { - ViewGroupHelper.super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - - @Override - public int getSuggestedMinimumWidth_impl() { - return ViewGroupHelper.super.getSuggestedMinimumWidth(); - } - - @Override - public int getSuggestedMinimumHeight_impl() { - return ViewGroupHelper.super.getSuggestedMinimumHeight(); - } - - @Override - public void setMeasuredDimension_impl(int measuredWidth, int measuredHeight) { - ViewGroupHelper.super.setMeasuredDimension(measuredWidth, measuredHeight); - } - - @Override - public boolean dispatchTouchEvent_impl(MotionEvent ev) { - return ViewGroupHelper.super.dispatchTouchEvent(ev); - } - - @Override - public boolean checkLayoutParams_impl(LayoutParams p) { - return ViewGroupHelper.super.checkLayoutParams(p); - } - - @Override - public LayoutParams generateDefaultLayoutParams_impl() { - return ViewGroupHelper.super.generateDefaultLayoutParams(); - } - - @Override - public LayoutParams generateLayoutParams_impl(AttributeSet attrs) { - return ViewGroupHelper.super.generateLayoutParams(attrs); - } - - @Override - public LayoutParams generateLayoutParams_impl(LayoutParams lp) { - return ViewGroupHelper.super.generateLayoutParams(lp); - } - - @Override - public boolean shouldDelayChildPressedState_impl() { - return ViewGroupHelper.super.shouldDelayChildPressedState(); - } - - @Override - public void measureChildWithMargins_impl(View child, - int parentWidthMeasureSpec, int widthUsed, - int parentHeightMeasureSpec, int heightUsed) { - ViewGroupHelper.super.measureChildWithMargins(child, - parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed); - } - } - - /** @hide */ - public class PrivateProvider implements ViewGroupProvider { - @Override - public CharSequence getAccessibilityClassName_impl() { - return ViewGroupHelper.this.getAccessibilityClassName(); - } - - @Override - public boolean onTouchEvent_impl(MotionEvent ev) { - return ViewGroupHelper.this.onTouchEvent(ev); - } - - @Override - public boolean onTrackballEvent_impl(MotionEvent ev) { - return ViewGroupHelper.this.onTrackballEvent(ev); - } - - @Override - public void onFinishInflate_impl() { - ViewGroupHelper.this.onFinishInflate(); - } - - @Override - public void setEnabled_impl(boolean enabled) { - ViewGroupHelper.this.setEnabled(enabled); - } - - @Override - public void onAttachedToWindow_impl() { - ViewGroupHelper.this.onAttachedToWindow(); - } - - @Override - public void onDetachedFromWindow_impl() { - ViewGroupHelper.this.onDetachedFromWindow(); - } - - @Override - public void onVisibilityAggregated_impl(boolean isVisible) { - ViewGroupHelper.this.onVisibilityAggregated(isVisible); - } - - @Override - public void onLayout_impl(boolean changed, int left, int top, int right, int bottom) { - ViewGroupHelper.this.onLayout(changed, left, top, right, bottom); - } - - @Override - public void onMeasure_impl(int widthMeasureSpec, int heightMeasureSpec) { - ViewGroupHelper.this.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - - @Override - public int getSuggestedMinimumWidth_impl() { - return ViewGroupHelper.this.getSuggestedMinimumWidth(); - } - - @Override - public int getSuggestedMinimumHeight_impl() { - return ViewGroupHelper.this.getSuggestedMinimumHeight(); - } - - @Override - public void setMeasuredDimension_impl(int measuredWidth, int measuredHeight) { - ViewGroupHelper.this.setMeasuredDimension(measuredWidth, measuredHeight); - } - - @Override - public boolean dispatchTouchEvent_impl(MotionEvent ev) { - return ViewGroupHelper.this.dispatchTouchEvent(ev); - } - - @Override - public boolean checkLayoutParams_impl(LayoutParams p) { - return ViewGroupHelper.this.checkLayoutParams(p); - } - - @Override - public LayoutParams generateDefaultLayoutParams_impl() { - return ViewGroupHelper.this.generateDefaultLayoutParams(); - } - - @Override - public LayoutParams generateLayoutParams_impl(AttributeSet attrs) { - return ViewGroupHelper.this.generateLayoutParams(attrs); - } - - @Override - public LayoutParams generateLayoutParams_impl(LayoutParams lp) { - return ViewGroupHelper.this.generateLayoutParams(lp); - } - - @Override - public boolean shouldDelayChildPressedState_impl() { - return ViewGroupHelper.this.shouldDelayChildPressedState(); - } - - @Override - public void measureChildWithMargins_impl(View child, - int parentWidthMeasureSpec, int widthUsed, - int parentHeightMeasureSpec, int heightUsed) { - ViewGroupHelper.this.measureChildWithMargins(child, - parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed); - } - } - - /** @hide */ - @FunctionalInterface - public interface ProviderCreator<T extends ViewGroupProvider> { - T createProvider(ViewGroupHelper<T> instance, ViewGroupProvider superProvider, - ViewGroupProvider privateProvider); - } -} diff --git a/media/java/android/media/update/ViewGroupProvider.java b/media/java/android/media/update/ViewGroupProvider.java deleted file mode 100644 index 67e8cea871e9..000000000000 --- a/media/java/android/media/update/ViewGroupProvider.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.media.update; - -import android.annotation.SystemApi; -import android.util.AttributeSet; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewGroup.LayoutParams; - -/** - * Interface for connecting the public API to an updatable implementation. - * - * Each instance object is connected to one corresponding updatable object which implements the - * runtime behavior of that class. There should a corresponding provider method for all public - * methods. - * - * All methods behave as per their namesake in the public API. - * - * @see android.view.View - * - * @hide - */ -// TODO @SystemApi -public interface ViewGroupProvider { - // View methods - void onAttachedToWindow_impl(); - void onDetachedFromWindow_impl(); - CharSequence getAccessibilityClassName_impl(); - boolean onTouchEvent_impl(MotionEvent ev); - boolean onTrackballEvent_impl(MotionEvent ev); - void onFinishInflate_impl(); - void setEnabled_impl(boolean enabled); - void onVisibilityAggregated_impl(boolean isVisible); - void onLayout_impl(boolean changed, int left, int top, int right, int bottom); - void onMeasure_impl(int widthMeasureSpec, int heightMeasureSpec); - int getSuggestedMinimumWidth_impl(); - int getSuggestedMinimumHeight_impl(); - void setMeasuredDimension_impl(int measuredWidth, int measuredHeight); - boolean dispatchTouchEvent_impl(MotionEvent ev); - - // ViewGroup methods - boolean checkLayoutParams_impl(LayoutParams p); - LayoutParams generateDefaultLayoutParams_impl(); - LayoutParams generateLayoutParams_impl(AttributeSet attrs); - LayoutParams generateLayoutParams_impl(LayoutParams lp); - boolean shouldDelayChildPressedState_impl(); - void measureChildWithMargins_impl(View child, int parentWidthMeasureSpec, int widthUsed, - int parentHeightMeasureSpec, int heightUsed); - - // ViewManager methods - // ViewParent methods -} |