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

Commit 674e9621 authored by Youngsang Cho's avatar Youngsang Cho
Browse files

Remove TvInputSession

TvInputSession is not used anymore. Instead, TvInputManager.Session
and TvInputService.TvInputSessionImpl are used.

Change-Id: Id252afa76b4ef45f561b1d20095ee235a9fdccf8
parent e5e8444c
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -27714,14 +27714,6 @@ package android.tv {
    method public abstract boolean onTune(android.net.Uri);
  }
  public abstract class TvInputSession {
    ctor public TvInputSession();
    method public void release();
    method public void setSurface(android.view.Surface);
    method public void setVolume(float);
    method public void tune(android.net.Uri);
  }
}
package android.util {
+3 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.tv;
import android.content.Context;
import android.net.Uri;
import android.os.Message;
import android.tv.TvInputService.TvInputSessionImpl;
import android.util.Log;
import android.view.Surface;

@@ -38,10 +39,10 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
    private static final int DO_SET_VOLUME = 3;
    private static final int DO_TUNE = 4;

    private TvInputSession mTvInputSession;
    private TvInputSessionImpl mTvInputSession;
    private final HandlerCaller mCaller;

    public ITvInputSessionWrapper(Context context, TvInputSession session) {
    public ITvInputSessionWrapper(Context context, TvInputSessionImpl session) {
        mCaller = new HandlerCaller(context, null, this, true /* asyncHandler */);
        mTvInputSession = session;
    }
+1 −1
Original line number Diff line number Diff line
@@ -282,7 +282,7 @@ public final class TvInputManager {
    }

    /**
     * Creates a {@link TvInputSession} interface for a given TV input.
     * Creates a {@link Session} for a given TV input.
     * <p>
     * The number of sessions that can be created at the same time is limited by the capability of
     * the given TV input.
+13 −30
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ public abstract class TvInputService extends Service {
    public abstract TvInputSessionImpl onCreateSession();

    /**
     * Base class for derived classes to implement to provide {@link TvInputSession}.
     * Base class for derived classes to implement to provide {@link TvInputManager.Session}.
     */
    public abstract static class TvInputSessionImpl {
        /**
@@ -155,52 +155,35 @@ public abstract class TvInputService extends Service {
         * @return {@code true} the tuning was successful, {@code false} otherwise.
         */
        public abstract boolean onTune(Uri channelUri);
    }

    /**
     * Internal implementation of {@link TvInputSession}. This takes care of basic maintenance of
     * the TV input session but most behavior must be implemented in {@link TvInputSessionImpl}
     * returned by {@link TvInputService#onCreateSession}.
     */
    private static class TvInputSessionImplInternal extends TvInputSession {
        private final TvInputSessionImpl mSessionImpl;

        public TvInputSessionImplInternal(TvInputSessionImpl sessionImpl) {
            mSessionImpl = sessionImpl;
        }

        /**
         * This method is called when the application would like to stop using the current input
         * session.
         */
        @Override
        public final void release() {
            mSessionImpl.onRelease();
        void release() {
            onRelease();
        }

        /**
         * Calls {@link TvInputSessionImpl#onSetSurface}.
         * Calls {@link onSetSurface}.
         */
        @Override
        public final void setSurface(Surface surface) {
            mSessionImpl.onSetSurface(surface);
        void setSurface(Surface surface) {
            onSetSurface(surface);
            // TODO: Handle failure.
        }

        /**
         * Calls {@link TvInputSessionImpl#onSetVolume}.
         * Calls {@link onSetVolume}.
         */
        @Override
        public final void setVolume(float volume) {
            mSessionImpl.onSetVolume(volume);
        void setVolume(float volume) {
            onSetVolume(volume);
        }

        /**
         * Calls {@link TvInputSessionImpl#onTune}.
         * Calls {@link onTune}.
         */
        @Override
        public final void tune(Uri channelUri) {
            mSessionImpl.onTune(channelUri);
        void tune(Uri channelUri) {
            onTune(channelUri);
            // TODO: Handle failure.
        }
    }
@@ -222,7 +205,7 @@ public abstract class TvInputService extends Service {
                            return;
                        }
                        ITvInputSession stub = new ITvInputSessionWrapper(TvInputService.this,
                                new TvInputSessionImplInternal(sessionImpl));
                                sessionImpl);
                        cb.onSessionCreated(stub);
                    } catch (RemoteException e) {
                        Log.e(TAG, "error in onSessionCreated");
+0 −55
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 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.tv;

import android.net.Uri;
import android.view.Surface;

/**
 * The TvInputSession provides the per-session functionality of TvInputService.
 */
public abstract class TvInputSession {
    /**
     * This method is called when the application would like to stop using the current input
     * session.
     */
    public void release() { }

    /**
     * Sets the {@link Surface} for the current input session on which the TV input renders video.
     *
     * @param surface {@link Surface} to be used for the video playback of this session.
     */
    public void setSurface(Surface surface) { }

    /**
     * This method is called when the application needs to handle the change of audio focus by
     * setting the relative volume of the current TV input service session.
     *
     * @param volume Volume scale from 0.0 to 1.0.
     */
    // TODO: Remove this once it becomes irrelevant for applications to handle audio focus. The plan
    // is to introduce some new concepts that will solve a number of problems in audio policy today.
    public void setVolume(float volume) { }

    /**
     * Tunes to a given channel.
     *
     * @param channelUri The URI of the channel.
     */
    public void tune(Uri channelUri) { }
}