summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt20
-rw-r--r--api/system-current.txt24
-rw-r--r--api/test-current.txt20
-rw-r--r--media/java/android/media/tv/ITvInputClient.aidl3
-rw-r--r--media/java/android/media/tv/ITvInputManager.aidl1
-rw-r--r--media/java/android/media/tv/ITvInputSession.aidl2
-rw-r--r--media/java/android/media/tv/ITvInputSessionCallback.aidl3
-rw-r--r--media/java/android/media/tv/ITvInputSessionWrapper.java69
-rw-r--r--media/java/android/media/tv/TvInputManager.java188
-rw-r--r--media/java/android/media/tv/TvInputService.java119
-rw-r--r--media/java/android/media/tv/TvRecordingClient.java165
-rw-r--r--media/java/android/media/tv/TvView.java4
-rw-r--r--services/core/java/com/android/server/tv/TvInputManagerService.java61
13 files changed, 299 insertions, 380 deletions
diff --git a/api/current.txt b/api/current.txt
index 1d891a6cae26..8b9274cbce9c 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -22950,8 +22950,9 @@ package android.media.tv {
field public static final int INPUT_STATE_DISCONNECTED = 2; // 0x2
field public static final java.lang.String META_DATA_CONTENT_RATING_SYSTEMS = "android.media.tv.metadata.CONTENT_RATING_SYSTEMS";
field public static final int RECORDING_ERROR_CONNECTION_FAILED = 1; // 0x1
- field public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 2; // 0x2
- field public static final int RECORDING_ERROR_RESOURCE_BUSY = 3; // 0x3
+ field public static final int RECORDING_ERROR_DISCONNECTED = 2; // 0x2
+ field public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 3; // 0x3
+ field public static final int RECORDING_ERROR_RESOURCE_BUSY = 4; // 0x4
field public static final int RECORDING_ERROR_UNKNOWN = 0; // 0x0
field public static final long TIME_SHIFT_INVALID_TIME = -9223372036854775808L; // 0x8000000000000000L
field public static final int TIME_SHIFT_STATUS_AVAILABLE = 3; // 0x3
@@ -22994,14 +22995,13 @@ package android.media.tv {
public static abstract class TvInputService.RecordingSession {
ctor public TvInputService.RecordingSession(android.content.Context);
- method public void notifyConnected();
method public void notifyError(int);
- method public void notifyRecordingStarted();
method public void notifyRecordingStopped(android.net.Uri);
- method public abstract void onConnect(android.net.Uri);
- method public abstract void onDisconnect();
+ method public void notifyTuned();
+ method public abstract void onRelease();
method public abstract void onStartRecording(android.net.Uri);
method public abstract void onStopRecording();
+ method public abstract void onTune(android.net.Uri);
}
public static abstract class TvInputService.Session implements android.view.KeyEvent.Callback {
@@ -23044,19 +23044,17 @@ package android.media.tv {
public class TvRecordingClient {
ctor public TvRecordingClient(android.content.Context, java.lang.String, android.media.tv.TvRecordingClient.RecordingCallback, android.os.Handler);
- method public void connect(java.lang.String, android.net.Uri);
- method public void disconnect();
+ method public void release();
method public void startRecording(android.net.Uri);
method public void stopRecording();
+ method public void tune(java.lang.String, android.net.Uri);
}
public static abstract class TvRecordingClient.RecordingCallback {
ctor public TvRecordingClient.RecordingCallback();
- method public void onConnected();
- method public void onDisconnected();
method public void onError(int);
- method public void onRecordingStarted();
method public void onRecordingStopped(android.net.Uri);
+ method public void onTuned();
}
public final class TvTrackInfo implements android.os.Parcelable {
diff --git a/api/system-current.txt b/api/system-current.txt
index 1ab5837c367e..43a787f4486e 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -24649,8 +24649,9 @@ package android.media.tv {
field public static final int INPUT_STATE_DISCONNECTED = 2; // 0x2
field public static final java.lang.String META_DATA_CONTENT_RATING_SYSTEMS = "android.media.tv.metadata.CONTENT_RATING_SYSTEMS";
field public static final int RECORDING_ERROR_CONNECTION_FAILED = 1; // 0x1
- field public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 2; // 0x2
- field public static final int RECORDING_ERROR_RESOURCE_BUSY = 3; // 0x3
+ field public static final int RECORDING_ERROR_DISCONNECTED = 2; // 0x2
+ field public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 3; // 0x3
+ field public static final int RECORDING_ERROR_RESOURCE_BUSY = 4; // 0x4
field public static final int RECORDING_ERROR_UNKNOWN = 0; // 0x0
field public static final long TIME_SHIFT_INVALID_TIME = -9223372036854775808L; // 0x8000000000000000L
field public static final int TIME_SHIFT_STATUS_AVAILABLE = 3; // 0x3
@@ -24743,17 +24744,16 @@ package android.media.tv {
public static abstract class TvInputService.RecordingSession {
ctor public TvInputService.RecordingSession(android.content.Context);
- method public void notifyConnected();
method public void notifyError(int);
- method public void notifyRecordingStarted();
method public void notifyRecordingStopped(android.net.Uri);
method public void notifySessionEvent(java.lang.String, android.os.Bundle);
+ method public void notifyTuned();
method public void onAppPrivateCommand(java.lang.String, android.os.Bundle);
- method public abstract void onConnect(android.net.Uri);
- method public void onConnect(android.net.Uri, android.os.Bundle);
- method public abstract void onDisconnect();
+ method public abstract void onRelease();
method public abstract void onStartRecording(android.net.Uri);
method public abstract void onStopRecording();
+ method public abstract void onTune(android.net.Uri);
+ method public void onTune(android.net.Uri, android.os.Bundle);
}
public static abstract class TvInputService.Session implements android.view.KeyEvent.Callback {
@@ -24800,22 +24800,20 @@ package android.media.tv {
public class TvRecordingClient {
ctor public TvRecordingClient(android.content.Context, java.lang.String, android.media.tv.TvRecordingClient.RecordingCallback, android.os.Handler);
- method public void connect(java.lang.String, android.net.Uri);
- method public void connect(java.lang.String, android.net.Uri, android.os.Bundle);
- method public void disconnect();
+ method public void release();
method public void sendAppPrivateCommand(java.lang.String, android.os.Bundle);
method public void startRecording(android.net.Uri);
method public void stopRecording();
+ method public void tune(java.lang.String, android.net.Uri);
+ method public void tune(java.lang.String, android.net.Uri, android.os.Bundle);
}
public static abstract class TvRecordingClient.RecordingCallback {
ctor public TvRecordingClient.RecordingCallback();
- method public void onConnected();
- method public void onDisconnected();
method public void onError(int);
method public void onEvent(java.lang.String, java.lang.String, android.os.Bundle);
- method public void onRecordingStarted();
method public void onRecordingStopped(android.net.Uri);
+ method public void onTuned();
}
public class TvStreamConfig implements android.os.Parcelable {
diff --git a/api/test-current.txt b/api/test-current.txt
index 49b8ffe3f4bf..428b359be05e 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -22959,8 +22959,9 @@ package android.media.tv {
field public static final int INPUT_STATE_DISCONNECTED = 2; // 0x2
field public static final java.lang.String META_DATA_CONTENT_RATING_SYSTEMS = "android.media.tv.metadata.CONTENT_RATING_SYSTEMS";
field public static final int RECORDING_ERROR_CONNECTION_FAILED = 1; // 0x1
- field public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 2; // 0x2
- field public static final int RECORDING_ERROR_RESOURCE_BUSY = 3; // 0x3
+ field public static final int RECORDING_ERROR_DISCONNECTED = 2; // 0x2
+ field public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 3; // 0x3
+ field public static final int RECORDING_ERROR_RESOURCE_BUSY = 4; // 0x4
field public static final int RECORDING_ERROR_UNKNOWN = 0; // 0x0
field public static final long TIME_SHIFT_INVALID_TIME = -9223372036854775808L; // 0x8000000000000000L
field public static final int TIME_SHIFT_STATUS_AVAILABLE = 3; // 0x3
@@ -23003,14 +23004,13 @@ package android.media.tv {
public static abstract class TvInputService.RecordingSession {
ctor public TvInputService.RecordingSession(android.content.Context);
- method public void notifyConnected();
method public void notifyError(int);
- method public void notifyRecordingStarted();
method public void notifyRecordingStopped(android.net.Uri);
- method public abstract void onConnect(android.net.Uri);
- method public abstract void onDisconnect();
+ method public void notifyTuned();
+ method public abstract void onRelease();
method public abstract void onStartRecording(android.net.Uri);
method public abstract void onStopRecording();
+ method public abstract void onTune(android.net.Uri);
}
public static abstract class TvInputService.Session implements android.view.KeyEvent.Callback {
@@ -23053,19 +23053,17 @@ package android.media.tv {
public class TvRecordingClient {
ctor public TvRecordingClient(android.content.Context, java.lang.String, android.media.tv.TvRecordingClient.RecordingCallback, android.os.Handler);
- method public void connect(java.lang.String, android.net.Uri);
- method public void disconnect();
+ method public void release();
method public void startRecording(android.net.Uri);
method public void stopRecording();
+ method public void tune(java.lang.String, android.net.Uri);
}
public static abstract class TvRecordingClient.RecordingCallback {
ctor public TvRecordingClient.RecordingCallback();
- method public void onConnected();
- method public void onDisconnected();
method public void onError(int);
- method public void onRecordingStarted();
method public void onRecordingStopped(android.net.Uri);
+ method public void onTuned();
}
public final class TvTrackInfo implements android.os.Parcelable {
diff --git a/media/java/android/media/tv/ITvInputClient.aidl b/media/java/android/media/tv/ITvInputClient.aidl
index 8ef5ca0f62d8..5dd4e85efa2c 100644
--- a/media/java/android/media/tv/ITvInputClient.aidl
+++ b/media/java/android/media/tv/ITvInputClient.aidl
@@ -45,8 +45,7 @@ oneway interface ITvInputClient {
void onTimeShiftCurrentPositionChanged(long timeMs, int seq);
// For the recording session
- void onConnected(int seq);
- void onRecordingStarted(int seq);
+ void onTuned(int seq);
void onRecordingStopped(in Uri recordedProgramUri, int seq);
void onError(int error, int seq);
}
diff --git a/media/java/android/media/tv/ITvInputManager.aidl b/media/java/android/media/tv/ITvInputManager.aidl
index 12a220f2974f..09d8b64e8dd4 100644
--- a/media/java/android/media/tv/ITvInputManager.aidl
+++ b/media/java/android/media/tv/ITvInputManager.aidl
@@ -87,7 +87,6 @@ interface ITvInputManager {
void timeShiftEnablePositionTracking(in IBinder sessionToken, boolean enable, int userId);
// For the recording session
- void connect(in IBinder sessionToken, in Uri channelUri, in Bundle params, int userId);
void startRecording(in IBinder sessionToken, in Uri programHint, int userId);
void stopRecording(in IBinder sessionToken, int userId);
diff --git a/media/java/android/media/tv/ITvInputSession.aidl b/media/java/android/media/tv/ITvInputSession.aidl
index 07781bc0a042..b1ce8d4975f8 100644
--- a/media/java/android/media/tv/ITvInputSession.aidl
+++ b/media/java/android/media/tv/ITvInputSession.aidl
@@ -56,8 +56,6 @@ oneway interface ITvInputSession {
void timeShiftEnablePositionTracking(boolean enable);
// For the recording session
- void connect(in Uri channelUri, in Bundle params);
- void disconnect();
void startRecording(in Uri programHint);
void stopRecording();
}
diff --git a/media/java/android/media/tv/ITvInputSessionCallback.aidl b/media/java/android/media/tv/ITvInputSessionCallback.aidl
index cb6a05e07b0d..60d6f0df9855 100644
--- a/media/java/android/media/tv/ITvInputSessionCallback.aidl
+++ b/media/java/android/media/tv/ITvInputSessionCallback.aidl
@@ -42,8 +42,7 @@ oneway interface ITvInputSessionCallback {
void onTimeShiftCurrentPositionChanged(long timeMs);
// For the recording session
- void onConnected();
- void onRecordingStarted();
+ void onTuned();
void onRecordingStopped(in Uri recordedProgramUri);
void onError(int error);
}
diff --git a/media/java/android/media/tv/ITvInputSessionWrapper.java b/media/java/android/media/tv/ITvInputSessionWrapper.java
index b15acef583b0..56103adc784d 100644
--- a/media/java/android/media/tv/ITvInputSessionWrapper.java
+++ b/media/java/android/media/tv/ITvInputSessionWrapper.java
@@ -66,10 +66,8 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
private static final int DO_TIME_SHIFT_SEEK_TO = 17;
private static final int DO_TIME_SHIFT_SET_PLAYBACK_PARAMS = 18;
private static final int DO_TIME_SHIFT_ENABLE_POSITION_TRACKING = 19;
- private static final int DO_CONNECT = 20;
- private static final int DO_DISCONNECT = 21;
- private static final int DO_START_RECORDING = 22;
- private static final int DO_STOP_RECORDING = 23;
+ private static final int DO_START_RECORDING = 20;
+ private static final int DO_STOP_RECORDING = 21;
private final boolean mIsRecordingSession;
private final HandlerCaller mCaller;
@@ -91,6 +89,7 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
}
}
+ // For the recording session
public ITvInputSessionWrapper(Context context,
TvInputService.RecordingSession recordingSessionImpl) {
mIsRecordingSession = true;
@@ -100,25 +99,28 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
@Override
public void executeMessage(Message msg) {
- if (!mIsRecordingSession && mTvInputSessionImpl == null) {
- return;
- }
- if (mIsRecordingSession && mTvInputRecordingSessionImpl == null) {
+ if ((mIsRecordingSession && mTvInputRecordingSessionImpl == null)
+ || (!mIsRecordingSession && mTvInputSessionImpl == null)) {
return;
}
long startTime = System.nanoTime();
switch (msg.what) {
case DO_RELEASE: {
- mTvInputSessionImpl.release();
- mTvInputSessionImpl = null;
- if (mReceiver != null) {
- mReceiver.dispose();
- mReceiver = null;
- }
- if (mChannel != null) {
- mChannel.dispose();
- mChannel = null;
+ if (mIsRecordingSession) {
+ mTvInputRecordingSessionImpl.release();
+ mTvInputRecordingSessionImpl = null;
+ } else {
+ mTvInputSessionImpl.release();
+ mTvInputSessionImpl = null;
+ if (mReceiver != null) {
+ mReceiver.dispose();
+ mReceiver = null;
+ }
+ if (mChannel != null) {
+ mChannel.dispose();
+ mChannel = null;
+ }
}
break;
}
@@ -142,7 +144,11 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
}
case DO_TUNE: {
SomeArgs args = (SomeArgs) msg.obj;
- mTvInputSessionImpl.tune((Uri) args.arg1, (Bundle) args.arg2);
+ if (mIsRecordingSession) {
+ mTvInputRecordingSessionImpl.tune((Uri) args.arg1, (Bundle) args.arg2);
+ } else {
+ mTvInputSessionImpl.tune((Uri) args.arg1, (Bundle) args.arg2);
+ }
args.recycle();
break;
}
@@ -209,17 +215,6 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
mTvInputSessionImpl.timeShiftEnablePositionTracking((Boolean) msg.obj);
break;
}
- case DO_CONNECT: {
- SomeArgs args = (SomeArgs) msg.obj;
- mTvInputRecordingSessionImpl.connect((Uri) args.arg1, (Bundle) args.arg2);
- args.recycle();
- break;
- }
- case DO_DISCONNECT: {
- mTvInputRecordingSessionImpl.disconnect();
- mTvInputRecordingSessionImpl = null;
- break;
- }
case DO_START_RECORDING: {
mTvInputRecordingSessionImpl.startRecording((Uri) msg.obj);
break;
@@ -251,7 +246,9 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
@Override
public void release() {
- mTvInputSessionImpl.scheduleOverlayViewCleanup();
+ if (!mIsRecordingSession) {
+ mTvInputSessionImpl.scheduleOverlayViewCleanup();
+ }
mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_RELEASE));
}
@@ -355,18 +352,6 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
}
@Override
- public void connect(Uri channelUri, Bundle params) {
- // Clear the pending connect requests.
- mCaller.removeMessages(DO_CONNECT);
- mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_CONNECT, channelUri, params));
- }
-
- @Override
- public void disconnect() {
- mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_DISCONNECT));
- }
-
- @Override
public void startRecording(@Nullable Uri programHint) {
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_START_RECORDING, programHint));
}
diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java
index d76408e3a9d3..1320e382a7ea 100644
--- a/media/java/android/media/tv/TvInputManager.java
+++ b/media/java/android/media/tv/TvInputManager.java
@@ -83,110 +83,140 @@ public final class TvInputManager {
static final int VIDEO_UNAVAILABLE_REASON_END = 4;
/**
- * A generic reason. Video is not available due to an unspecified error.
+ * Reason for {@link TvInputService.Session#notifyVideoUnavailable(int)} and
+ * {@link TvView.TvInputCallback#onVideoUnavailable(String, int)}: Video is unavailable due to
+ * an unspecified error.
*/
public static final int VIDEO_UNAVAILABLE_REASON_UNKNOWN = VIDEO_UNAVAILABLE_REASON_START;
/**
- * Video is not available because the TV input is in the middle of tuning to a new channel.
+ * Reason for {@link TvInputService.Session#notifyVideoUnavailable(int)} and
+ * {@link TvView.TvInputCallback#onVideoUnavailable(String, int)}: Video is unavailable because
+ * the corresponding TV input is in the middle of tuning to a new channel.
*/
public static final int VIDEO_UNAVAILABLE_REASON_TUNING = 1;
/**
- * Video is not available due to the weak TV signal.
+ * Reason for {@link TvInputService.Session#notifyVideoUnavailable(int)} and
+ * {@link TvView.TvInputCallback#onVideoUnavailable(String, int)}: Video is unavailable due to
+ * weak TV signal.
*/
public static final int VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL = 2;
/**
- * Video is not available because the TV input stopped the playback temporarily to buffer more
- * data.
+ * Reason for {@link TvInputService.Session#notifyVideoUnavailable(int)} and
+ * {@link TvView.TvInputCallback#onVideoUnavailable(String, int)}: Video is unavailable because
+ * the corresponding TV input has stopped playback temporarily to buffer more data.
*/
public static final int VIDEO_UNAVAILABLE_REASON_BUFFERING = 3;
/**
- * Video is not available because the current program is audio-only.
+ * Reason for {@link TvInputService.Session#notifyVideoUnavailable(int)} and
+ * {@link TvView.TvInputCallback#onVideoUnavailable(String, int)}: Video is unavailable because
+ * the current TV program is audio-only.
*/
public static final int VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY = VIDEO_UNAVAILABLE_REASON_END;
/**
- * Status prior to calling {@link TvInputService.Session#notifyTimeShiftStatusChanged}.
+ * Status for {@link TvInputService.Session#notifyTimeShiftStatusChanged(int)} and
+ * {@link TvView.TvInputCallback#onTimeShiftStatusChanged(String, int)}: Unknown status. Also
+ * the status prior to calling {@code notifyTimeShiftStatusChanged}.
*/
public static final int TIME_SHIFT_STATUS_UNKNOWN = 0;
/**
- * The TV input does not support time shifting.
+ * Status for {@link TvInputService.Session#notifyTimeShiftStatusChanged(int)} and
+ * {@link TvView.TvInputCallback#onTimeShiftStatusChanged(String, int)}: The current TV input
+ * does not support time shifting.
*/
public static final int TIME_SHIFT_STATUS_UNSUPPORTED = 1;
/**
- * Time shifting is currently not available but might work again later.
+ * Status for {@link TvInputService.Session#notifyTimeShiftStatusChanged(int)} and
+ * {@link TvView.TvInputCallback#onTimeShiftStatusChanged(String, int)}: Time shifting is
+ * currently unavailable but might work again later.
*/
public static final int TIME_SHIFT_STATUS_UNAVAILABLE = 2;
/**
- * Time shifting is currently available. In this status, the application assumes it can
- * pause/resume playback, seek to a specified time position and set playback rate and audio
- * mode.
+ * Status for {@link TvInputService.Session#notifyTimeShiftStatusChanged(int)} and
+ * {@link TvView.TvInputCallback#onTimeShiftStatusChanged(String, int)}: Time shifting is
+ * currently available. In this status, the application assumes it can pause/resume playback,
+ * seek to a specified time position and set playback rate and audio mode.
*/
public static final int TIME_SHIFT_STATUS_AVAILABLE = 3;
+ /**
+ * Value returned by {@link TvInputService.Session#onTimeShiftGetCurrentPosition()} and
+ * {@link TvInputService.Session#onTimeShiftGetStartPosition()} when time shifting has not
+ * yet started.
+ */
public static final long TIME_SHIFT_INVALID_TIME = Long.MIN_VALUE;
/**
- * RecordingError when a requested operation cannot be completed due to a problem that does not
- * fit under any other error code.
+ * Error for {@link TvInputService.RecordingSession#notifyError(int)} and
+ * {@link TvRecordingClient.RecordingCallback#onError(int)}: The requested operation cannot be
+ * completed due to a problem that does not fit under any other error codes.
*/
public static final int RECORDING_ERROR_UNKNOWN = 0;
/**
- * RecordingError when an attempt to connect to a recording session has failed or the
- * established connection has been disconnected without a known reason.
+ * Error for {@link TvRecordingClient.RecordingCallback#onError(int)}: The recording client has
+ * failed to establish a connection to a recording session.
*/
public static final int RECORDING_ERROR_CONNECTION_FAILED = 1;
/**
- * RecordingError when recording cannot proceed due to insufficient storage space.
+ * Error for {@link TvRecordingClient.RecordingCallback#onError(int)}: The recording client has
+ * been disconnected from the current recording session.
*/
- public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 2;
+ public static final int RECORDING_ERROR_DISCONNECTED = 2;
/**
- * RecordingError when recording cannot proceed because the required recording resource is not
- * able to be allocated.
+ * Error for {@link TvInputService.RecordingSession#notifyError(int)} and
+ * {@link TvRecordingClient.RecordingCallback#onError(int)}: Recording cannot proceed due to
+ * insufficient storage space.
*/
- public static final int RECORDING_ERROR_RESOURCE_BUSY = 3;
+ public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 3;
+
+ /**
+ * Error for {@link TvInputService.RecordingSession#notifyError(int)} and
+ * {@link TvRecordingClient.RecordingCallback#onError(int)}: Recording cannot proceed because
+ * a required recording resource was not able to be allocated.
+ */
+ public static final int RECORDING_ERROR_RESOURCE_BUSY = 4;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef({RECORDING_ERROR_UNKNOWN, RECORDING_ERROR_CONNECTION_FAILED,
- RECORDING_ERROR_INSUFFICIENT_SPACE, RECORDING_ERROR_RESOURCE_BUSY})
+ RECORDING_ERROR_DISCONNECTED, RECORDING_ERROR_INSUFFICIENT_SPACE,
+ RECORDING_ERROR_RESOURCE_BUSY})
public @interface RecordingError {}
/**
- * The TV input is connected.
+ * State for {@link #getInputState(String)} and
+ * {@link TvInputCallback#onInputStateChanged(String, int)}: The input source is connected.
*
- * <p>This state indicates that a source device is connected to the input port and is in the
- * normal operation mode. It is mostly relevant to hardware inputs such as HDMI input.
+ * <p>This state indicates that a source device is connected to the input port and in the normal
+ * operation mode. It is mostly relevant to hardware inputs such as HDMI input.
* Non-hardware inputs are considered connected all the time.
- *
- * @see #getInputState
- * @see TvInputManager.TvInputCallback#onInputStateChanged
*/
public static final int INPUT_STATE_CONNECTED = 0;
+
/**
- * The TV input is connected but in standby mode.
+ * State for {@link #getInputState(String)} and
+ * {@link TvInputCallback#onInputStateChanged(String, int)}: The input source is connected but
+ * in standby mode.
*
- * <p>This state indicates that a source device is connected to the input port but is in standby
- * or low power mode. It is mostly relevant to hardware inputs such as HDMI inputs and Component
+ * <p>This state indicates that a source device is connected to the input port and in standby or
+ * low power mode. It is mostly relevant to hardware inputs such as HDMI inputs and Component
* inputs.
- *
- * @see #getInputState
- * @see TvInputManager.TvInputCallback#onInputStateChanged
*/
public static final int INPUT_STATE_CONNECTED_STANDBY = 1;
+
/**
- * The TV input is disconnected.
+ * State for {@link #getInputState(String)} and
+ * {@link TvInputCallback#onInputStateChanged(String, int)}: The input source is disconnected.
*
* <p>This state indicates that a source device is disconnected from the input port. It is
* mostly relevant to hardware inputs such as HDMI input.
*
- * @see #getInputState
- * @see TvInputManager.TvInputCallback#onInputStateChanged
*/
public static final int INPUT_STATE_DISCONNECTED = 2;
@@ -449,33 +479,29 @@ public final class TvInputManager {
public void onTimeShiftCurrentPositionChanged(Session session, long timeMs) {
}
+ // For the recording session only
/**
- * This is called when a recording session initiated by a call to {@link
- * TvRecordingClient#connect(String, Uri)} has been established.
- */
- void onConnected(Session session) {
- }
-
- /**
- * This is called when TV program recording on the current channel has started.
- *
- * @param session A {@link TvInputManager.Session} associated with this callback.
+ * This is called when the recording session has been tuned to the given channel and is
+ * ready to start recording.
*/
- void onRecordingStarted(Session session) {
+ void onTuned(Session session) {
}
+ // For the recording session only
/**
- * This is called when TV program recording on the current channel has stopped. The passed
- * URI contains information about the new recorded program.
+ * This is called when the current recording session has stopped recording and created a
+ * new data entry in the {@link TvContract.RecordedPrograms} table that describes the newly
+ * recorded program.
*
- * @param recordedProgramUri The URI for the new recorded program.
- * @see android.media.tv.TvContract.RecordedPrograms
+ * @param recordedProgramUri The URI for the newly recorded program.
**/
void onRecordingStopped(Session session, Uri recordedProgramUri) {
}
+ // For the recording session only
/**
- * This is called when an issue has occurred before or during recording.
+ * This is called when an issue has occurred. It may be called at any time after the current
+ * recording session is created until it is released.
*
* @param error The error code.
*/
@@ -632,21 +658,11 @@ public final class TvInputManager {
}
// For the recording session only
- void postConnected() {
- mHandler.post(new Runnable() {
- @Override
- public void run() {
- mSessionCallback.onConnected(mSession);
- }
- });
- }
-
- // For the recording session only
- void postRecordingStarted() {
+ void postTuned() {
mHandler.post(new Runnable() {
@Override
public void run() {
- mSessionCallback.onRecordingStarted(mSession);
+ mSessionCallback.onTuned(mSession);
}
});
}
@@ -998,26 +1014,14 @@ public final class TvInputManager {
}
@Override
- public void onConnected(int seq) {
- synchronized (mSessionCallbackRecordMap) {
- SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
- if (record == null) {
- Log.e(TAG, "Callback not found for seq " + seq);
- return;
- }
- record.postConnected();
- }
- }
-
- @Override
- public void onRecordingStarted(int seq) {
+ public void onTuned(int seq) {
synchronized (mSessionCallbackRecordMap) {
SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
if (record == null) {
Log.e(TAG, "Callback not found for seq " + seq);
return;
}
- record.postRecordingStarted();
+ record.postTuned();
}
}
@@ -2013,32 +2017,6 @@ public final class TvInputManager {
}
/**
- * Connects to a given channel for TV program recording.
- */
- void connect(Uri channelUri) {
- connect(channelUri, null);
- }
-
- /**
- * Tunes to a given channel.
- *
- * @param channelUri The URI of a channel.
- * @param params Extra parameters.
- */
- void connect(@NonNull Uri channelUri, Bundle params) {
- Preconditions.checkNotNull(channelUri);
- if (mToken == null) {
- Log.w(TAG, "The session has been already released");
- return;
- }
- try {
- mService.connect(mToken, channelUri, params, mUserId);
- } catch (RemoteException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
* Starts TV program recording in the current recording session.
*
* @param programHint The URI for the TV program to record as a hint, built by
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java
index 91f1ee9f7e33..334c84b1f35e 100644
--- a/media/java/android/media/tv/TvInputService.java
+++ b/media/java/android/media/tv/TvInputService.java
@@ -1545,7 +1545,7 @@ public abstract class TvInputService extends Service {
private final List<Runnable> mPendingActions = new ArrayList<>();
/**
- * Creates a new Recording Session for TV program recording.
+ * Creates a new RecordingSession.
*
* @param context The context of the application
*/
@@ -1554,51 +1554,37 @@ public abstract class TvInputService extends Service {
}
/**
- * Informs the application that recording session has been connected.
- */
- public void notifyConnected() {
- executeOrPostRunnableOnMainThread(new Runnable() {
- @MainThread
- @Override
- public void run() {
- try {
- if (DEBUG) Log.d(TAG, "notifyConnected");
- if (mSessionCallback != null) {
- mSessionCallback.onConnected();
- }
- } catch (RemoteException e) {
- Log.w(TAG, "error in notifyConnected", e);
- }
- }
- });
- }
-
- /**
- * Informs the application that recording has started.
+ * Informs the application that this recording session has been tuned to the given channel
+ * and is ready to start recording.
+ *
+ * <p>Upon receiving a call to {@link #onTune(Uri)}, the session is expected to tune to the
+ * passed channel and call this method to indicate that it is now available for immediate
+ * recording. When {@link #onStartRecording(Uri)} is called, recording must start with
+ * minimal delay.
*/
- public void notifyRecordingStarted() {
+ public void notifyTuned() {
executeOrPostRunnableOnMainThread(new Runnable() {
@MainThread
@Override
public void run() {
try {
- if (DEBUG) Log.d(TAG, "notifyRecordingStarted");
+ if (DEBUG) Log.d(TAG, "notifyTuned");
if (mSessionCallback != null) {
- mSessionCallback.onRecordingStarted();
+ mSessionCallback.onTuned();
}
} catch (RemoteException e) {
- Log.w(TAG, "error in notifyRecordingStarted", e);
+ Log.w(TAG, "error in notifyTuned", e);
}
}
});
}
/**
- * Informs the application that recording has stopped successfully. Each TV input service
- * should create a new data entry in the recorded programs table upon completion of the
- * recording and send its URI.
+ * Informs the application that this recording session has stopped recording and created a
+ * new data entry in the {@link TvContract.RecordedPrograms} table that describes the newly
+ * recorded program.
*
- * @param recordedProgramUri The URI of the new recorded program.
+ * @param recordedProgramUri The URI of the newly recorded program.
*/
public void notifyRecordingStopped(final Uri recordedProgramUri) {
executeOrPostRunnableOnMainThread(new Runnable() {
@@ -1618,12 +1604,12 @@ public abstract class TvInputService extends Service {
}
/**
- * Sends an error to the application at any moment.
+ * Informs the application that there is an error. It may be called at any time after this
+ * recording session is created until {@link #onRelease()} is called.
*
* @param error The error code. Should be one of the followings.
* <ul>
* <li>{@link TvInputManager#RECORDING_ERROR_UNKNOWN}
- * <li>{@link TvInputManager#RECORDING_ERROR_CONNECTION_FAILED}
* <li>{@link TvInputManager#RECORDING_ERROR_INSUFFICIENT_SPACE}
* <li>{@link TvInputManager#RECORDING_ERROR_RESOURCE_BUSY}
* </ul>
@@ -1672,32 +1658,39 @@ public abstract class TvInputService extends Service {
}
/**
- * Called when the recording session is connected.
+ * Called when the application requests to tune to a given channel for TV program recording.
*
- * @param channelUri The URI of the channel.
+ * <p>The application may call this method before starting or after stopping recording, but
+ * not during recording.
+ *
+ * <p>The session must call {@link #notifyTuned()} if the tune request was fulfilled, or
+ * {@link #notifyError(int)} otherwise.
+ *
+ * @param channelUri The URI of a channel.
*/
- public abstract void onConnect(Uri channelUri);
+ public abstract void onTune(Uri channelUri);
/**
- * Called when the recording session is connected.
+ * Called when the application requests to tune to a given channel for TV program recording.
*
- * @param channelUri The URI of the channel.
+ * <p>The application may call this method before starting or after stopping recording, but
+ * not during recording.
+ *
+ * <p>The session must call {@link #notifyTuned()} if the tune request was fulfilled, or
+ * {@link #notifyError(int)} otherwise.
+ *
+ * @param channelUri The URI of a channel.
* @param params Extra parameters.
* @hide
*/
@SystemApi
- public void onConnect(Uri channelUri, Bundle params) {
- onConnect(channelUri);
+ public void onTune(Uri channelUri, Bundle params) {
+ onTune(channelUri);
}
/**
- * Called when the application requests to disconnect the current recording session.
- */
- public abstract void onDisconnect();
-
- /**
- * Called when the application requests to start recording. Recording must start
- * immediately.
+ * Called when the application requests to start TV program recording. Recording must start
+ * immediately when this method is called.
*
* <p>The application may supply the URI for a TV program as a hint for filling in program
* specific data fields in the {@link android.media.tv.TvContract.RecordedPrograms} table.
@@ -1706,8 +1699,8 @@ public abstract class TvInputService extends Service {
* recording can span across multiple TV programs. In either case, the application must call
* {@link TvRecordingClient#stopRecording()} to stop the recording.
*
- * <p>The session must call either {@link #notifyRecordingStarted()} or
- * {@link #notifyError(int)}.
+ * <p>The session must call {@link #notifyError(int)} if the start request cannot be
+ * fulfilled.
*
* @param programHint The URI for the TV program to record as a hint, built by
* {@link TvContract#buildProgramUri(long)}. Can be {@code null}.
@@ -1715,13 +1708,25 @@ public abstract class TvInputService extends Service {
public abstract void onStartRecording(@Nullable Uri programHint);
/**
- * Called when the application requests to stop recording. Recording must stop immediately.
+ * Called when the application requests to stop TV program recording. Recording must stop
+ * immediately when this method is called.
+ *
+ * <p>The session must create a new data entry in the
+ * {@link android.media.tv.TvContract.RecordedPrograms} table that describes the newly
+ * recorded program and call {@link #notifyRecordingStopped(Uri)} with the URI to that
+ * entry.
+ * If the stop request cannot be fulfilled, the session must call {@link #notifyError(int)}.
*
- * <p>The session must call either {@link #notifyRecordingStopped(Uri)} or
- * {@link #notifyError(int)}.
*/
public abstract void onStopRecording();
+
+ /**
+ * Called when the application requests to release all the resources held by this recording
+ * session.
+ */
+ public abstract void onRelease();
+
/**
* Processes a private command sent from the application to the TV input. This can be used
* to provide domain-specific features that are only known between certain TV inputs and
@@ -1738,19 +1743,19 @@ public abstract class TvInputService extends Service {
}
/**
- * Calls {@link #onConnect(Uri, Bundle)}.
+ * Calls {@link #onTune(Uri, Bundle)}.
*
*/
- void connect(Uri channelUri, Bundle params) {
- onConnect(channelUri, params);
+ void tune(Uri channelUri, Bundle params) {
+ onTune(channelUri, params);
}
/**
- * Calls {@link #onDisconnect()}.
+ * Calls {@link #onRelease()}.
*
*/
- void disconnect() {
- onDisconnect();
+ void release() {
+ onRelease();
}
/**
diff --git a/media/java/android/media/tv/TvRecordingClient.java b/media/java/android/media/tv/TvRecordingClient.java
index b943c3d5f559..72606f59f53b 100644
--- a/media/java/android/media/tv/TvRecordingClient.java
+++ b/media/java/android/media/tv/TvRecordingClient.java
@@ -20,6 +20,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.content.Context;
+import android.media.tv.TvInputManager;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -46,12 +47,14 @@ public class TvRecordingClient {
private TvInputManager.Session mSession;
private MySessionCallback mSessionCallback;
+ private boolean mIsRecordingStarted;
+ private boolean mIsTuned;
private final Queue<Pair<String, Bundle>> mPendingAppPrivateCommands = new ArrayDeque<>();
/**
* Creates a new TvRecordingClient object.
*
- * @param context The application context to create the TvRecordingClient with.
+ * @param context The application context to create a TvRecordingClient with.
* @param tag A short name for debugging purposes.
* @param callback The callback to receive recording status changes.
* @param handler The handler to invoke the callback on.
@@ -64,25 +67,37 @@ public class TvRecordingClient {
}
/**
- * Connects to a given input for TV program recording. This will create a new recording session
- * from the TV input and establishes the connection between the application and the session.
+ * Tunes to a given channel for TV program recording. The first tune request will create a new
+ * recording session for the corresponding TV input and establish the connection between the
+ * application and the session. If recording has already started in the current recording
+ * session, this method throws an exception.
+ *
+ * <p>The application may call this method before starting or after stopping recording, but not
+ * during recording.
*
* <p>The recording session will respond by calling
- * {@link RecordingCallback#onConnected()} or {@link RecordingCallback#onError(int)}.
+ * {@link RecordingCallback#onTuned()} if the tune request was fulfilled, or
+ * {@link RecordingCallback#onError(int)} otherwise.
*
* @param inputId The ID of the TV input for the given channel.
* @param channelUri The URI of a channel.
*/
- public void connect(String inputId, Uri channelUri) {
- connect(inputId, channelUri, null);
+ public void tune(String inputId, Uri channelUri) {
+ tune(inputId, channelUri, null);
}
/**
- * Connects to a given input for TV program recording. This will create a new recording session
- * from the TV input and establishes the connection between the application and the session.
+ * Tunes to a given channel for TV program recording. The first tune request will create a new
+ * recording session for the corresponding TV input and establish the connection between the
+ * application and the session. If recording has already started in the current recording
+ * session, this method throws an exception.
+ *
+ * <p>The application may call this method before starting or after stopping recording, but not
+ * during recording.
*
* <p>The recording session will respond by calling
- * {@link RecordingCallback#onConnected()} or {@link RecordingCallback#onError(int)}.
+ * {@link RecordingCallback#onTuned()} if the tune request was fulfilled, or
+ * {@link RecordingCallback#onError(int)} otherwise.
*
* @param inputId The ID of the TV input for the given channel.
* @param channelUri The URI of a channel.
@@ -90,14 +105,17 @@ public class TvRecordingClient {
* @hide
*/
@SystemApi
- public void connect(String inputId, Uri channelUri, Bundle params) {
- if (DEBUG) Log.d(TAG, "connect(" + channelUri + ")");
+ public void tune(String inputId, Uri channelUri, Bundle params) {
+ if (DEBUG) Log.d(TAG, "tune(" + channelUri + ")");
if (TextUtils.isEmpty(inputId)) {
throw new IllegalArgumentException("inputId cannot be null or an empty string");
}
+ if (mIsRecordingStarted) {
+ throw new IllegalStateException("tune failed - recording already started");
+ }
if (mSessionCallback != null && TextUtils.equals(mSessionCallback.mInputId, inputId)) {
if (mSession != null) {
- mSession.connect(channelUri, params);
+ mSession.tune(channelUri, params);
} else {
mSessionCallback.mChannelUri = channelUri;
mSessionCallback.mConnectionParams = params;
@@ -112,13 +130,11 @@ public class TvRecordingClient {
}
/**
- * Disconnects the established connection between the application and the recording session.
- *
- * <p>The recording session will respond by calling
- * {@link RecordingCallback#onDisconnected()} or {@link RecordingCallback#onError(int)}.
+ * Releases the resources in the current recording session immediately. This may be called at
+ * any time, however if the session is already released, it does nothing.
*/
- public void disconnect() {
- if (DEBUG) Log.d(TAG, "disconnect()");
+ public void release() {
+ if (DEBUG) Log.d(TAG, "release()");
resetInternal();
}
@@ -132,45 +148,57 @@ public class TvRecordingClient {
}
/**
- * Starts TV program recording in the current recording session. It is expected that recording
- * starts immediately after calling this method.
+ * Starts TV program recording in the current recording session. Recording is expected to start
+ * immediately when this method is called. If the current recording session has not yet tuned to
+ * any channel, this method throws an exception.
*
- * <p>The application may supply the URI for a TV program as a hint to the corresponding TV
- * input service for filling in program specific data fields in the
- * {@link android.media.tv.TvContract.RecordedPrograms} table. A non-null {@code programHint}
- * implies the started recording should be of that specific program, whereas null
- * {@code programHint} does not impose such a requirement and the recording can span across
- * multiple TV programs. In either case, the caller must call {@link #stopRecording()} to stop
- * the recording.
+ * <p>The application may supply the URI for a TV program as a hint for filling in program
+ * specific data fields in the {@link android.media.tv.TvContract.RecordedPrograms} table.
+ * A non-null {@code programHint} implies the started recording should be of that specific
+ * program, whereas null {@code programHint} does not impose such a requirement and the
+ * recording can span across multiple TV programs. In either case, the application must call
+ * {@link TvRecordingClient#stopRecording()} to stop the recording.
*
- * <p>The recording session will respond by calling
- * {@link RecordingCallback#onRecordingStarted()} or {@link RecordingCallback#onError(int)}.
+ * <p>The recording session will respond by calling {@link RecordingCallback#onError(int)} if
+ * the start request cannot be fulfilled.
*
* @param programHint The URI for the TV program to record as a hint, built by
- * {@link TvContract#buildProgramUri(long)}. Can be null.
+ * {@link TvContract#buildProgramUri(long)}. Can be {@code null}.
*/
- public void startRecording(@Nullable Uri programHint) {
+ public void startRecording(@Nullable Uri programHint) {
+ if (!mIsTuned) {
+ throw new IllegalStateException("startRecording failed - not yet tuned");
+ }
if (mSession != null) {
mSession.startRecording(programHint);
+ mIsRecordingStarted = true;
}
}
/**
- * Stops TV program recording in the current recording session. It is expected that recording
- * stops immediately after calling this method.
+ * Stops TV program recording in the current recording session. Recording is expected to stop
+ * immediately when this method is called. If recording has not yet started in the current
+ * recording session, this method does nothing.
*
- * <p>The recording session will respond by calling
- * {@link RecordingCallback#onRecordingStopped(Uri)} or {@link RecordingCallback#onError(int)}.
+ * <p>The recording session is expected to create a new data entry in the
+ * {@link android.media.tv.TvContract.RecordedPrograms} table that describes the newly
+ * recorded program and pass the URI to that entry through to
+ * {@link RecordingCallback#onRecordingStopped(Uri)}.
+ * If the stop request cannot be fulfilled, the recording session will respond by calling
+ * {@link RecordingCallback#onError(int)}.
*/
public void stopRecording() {
+ if (!mIsRecordingStarted) {
+ Log.w(TAG, "stopRecording failed - recording not yet started");
+ }
if (mSession != null) {
mSession.stopRecording();
}
}
/**
- * Calls {@link TvInputService.RecordingSession#appPrivateCommand(String, Bundle)
- * TvInputService.RecordingSession.appPrivateCommand()} on the current TvView.
+ * Calls {@link TvInputService.RecordingSession#appPrivateCommand(String, Bundle)} for the
+ * current recording session.
*
* @param action The name of the private command to send. This <em>must</em> be a scoped name,
* i.e. prefixed with a package name you own, so that different developers will not
@@ -198,46 +226,31 @@ public class TvRecordingClient {
*/
public abstract static class RecordingCallback {
/**
- * This is called when a recording session initiated by a call to
- * {@link #connect(String, Uri)} has been established.
- */
- public void onConnected() {
- }
-
- /**
- * This is called when the established connection between the application and the recording
- * session has been disconnected. Disconnection can be initiated either by an explicit
- * request (i.e. a call to {@link #disconnect()} or by an error on the TV input service
- * side.
+ * This is called when the recording session has been tuned to the given channel and is
+ * ready to start recording.
*/
- public void onDisconnected() {
+ public void onTuned() {
}
/**
- * This is called when TV program recording on the current channel has started.
- */
- public void onRecordingStarted() {
- }
-
- /**
- * This is called when TV program recording on the current channel has stopped. The passed
- * URI contains information about the new recorded program.
+ * This is called when the current recording session has stopped recording and created a
+ * new data entry in the {@link TvContract.RecordedPrograms} table that describes the newly
+ * recorded program.
*
- * @param recordedProgramUri The URI for the new recorded program.
- * @see android.media.tv.TvContract.RecordedPrograms
+ * @param recordedProgramUri The URI for the newly recorded program.
*/
public void onRecordingStopped(Uri recordedProgramUri) {
}
/**
- * This is called when an issue has occurred before or during recording. If the TV input
- * service cannot proceed recording due to this error, a call to {@link #onDisconnected()}
- * is expected to follow.
+ * This is called when an issue has occurred. It may be called at any time after the current
+ * recording session is created until it is released.
*
* @param error The error code. Should be one of the followings.
* <ul>
* <li>{@link TvInputManager#RECORDING_ERROR_UNKNOWN}
* <li>{@link TvInputManager#RECORDING_ERROR_CONNECTION_FAILED}
+ * <li>{@link TvInputManager#RECORDING_ERROR_DISCONNECTED}
* <li>{@link TvInputManager#RECORDING_ERROR_INSUFFICIENT_SPACE}
* <li>{@link TvInputManager#RECORDING_ERROR_RESOURCE_BUSY}
* </ul>
@@ -289,7 +302,7 @@ public class TvRecordingClient {
mSession.sendAppPrivateCommand(command.first, command.second);
}
mPendingAppPrivateCommands.clear();
- mSession.connect(mChannelUri, mConnectionParams);
+ mSession.tune(mChannelUri, mConnectionParams);
} else {
mSessionCallback = null;
mCallback.onError(TvInputManager.RECORDING_ERROR_CONNECTION_FAILED);
@@ -297,15 +310,16 @@ public class TvRecordingClient {
}
@Override
- void onConnected(TvInputManager.Session session) {
+ void onTuned(TvInputManager.Session session) {
if (DEBUG) {
- Log.d(TAG, "onConnected()");
+ Log.d(TAG, "onTuned()");
}
if (this != mSessionCallback) {
- Log.w(TAG, "onConnected - session not created");
+ Log.w(TAG, "onTuned - session not created");
return;
}
- mCallback.onConnected();
+ mIsTuned = true;
+ mCallback.onTuned();
}
@Override
@@ -319,19 +333,9 @@ public class TvRecordingClient {
}
mSessionCallback = null;
mSession = null;
- mCallback.onDisconnected();
- }
-
- @Override
- public void onRecordingStarted(TvInputManager.Session session) {
- if (DEBUG) {
- Log.d(TAG, "onRecordingStarted()");
- }
- if (this != mSessionCallback) {
- Log.w(TAG, "onRecordingStarted - session not created");
- return;
- }
- mCallback.onRecordingStarted();
+ mIsTuned = false;
+ mIsRecordingStarted = false;
+ mCallback.onError(TvInputManager.RECORDING_ERROR_DISCONNECTED);
}
@Override
@@ -343,6 +347,7 @@ public class TvRecordingClient {
Log.w(TAG, "onRecordingStopped - session not created");
return;
}
+ mIsRecordingStarted = false;
mCallback.onRecordingStopped(recordedProgramUri);
}
diff --git a/media/java/android/media/tv/TvView.java b/media/java/android/media/tv/TvView.java
index 0132d2438470..5c4b52883391 100644
--- a/media/java/android/media/tv/TvView.java
+++ b/media/java/android/media/tv/TvView.java
@@ -539,8 +539,8 @@ public class TvView extends ViewGroup {
}
/**
- * Calls {@link TvInputService.Session#appPrivateCommand(String, Bundle)
- * TvInputService.Session.appPrivateCommand()} on the current TvView.
+ * Calls {@link TvInputService.Session#appPrivateCommand(String, Bundle)} for the current
+ * session.
*
* @param action The name of the private command to send. This <em>must</em> be a scoped name,
* i.e. prefixed with a package name you own, so that different developers will not
diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java
index 0f51c82eba37..55de06146fdf 100644
--- a/services/core/java/com/android/server/tv/TvInputManagerService.java
+++ b/services/core/java/com/android/server/tv/TvInputManagerService.java
@@ -438,11 +438,7 @@ public final class TvInputManagerService extends SystemService {
for (SessionState state : userState.sessionStateMap.values()) {
if (state.session != null) {
try {
- if (state.isRecordingSession) {
- state.session.disconnect();
- } else {
- state.session.release();
- }
+ state.session.release();
} catch (RemoteException e) {
Slog.e(TAG, "error in release", e);
}
@@ -643,11 +639,7 @@ public final class TvInputManagerService extends SystemService {
if (sessionToken == userState.mainSessionToken) {
setMainLocked(sessionToken, false, callingUid, userId);
}
- if (sessionState.isRecordingSession) {
- sessionState.session.disconnect();
- } else {
- sessionState.session.release();
- }
+ sessionState.session.release();
}
} catch (RemoteException | SessionNotFoundException e) {
Slog.e(TAG, "error in releaseSession", e);
@@ -1279,6 +1271,9 @@ public final class TvInputManagerService extends SystemService {
UserState userState = getOrCreateUserStateLocked(resolvedUserId);
SessionState sessionState = userState.sessionStateMap.get(sessionToken);
+ if (sessionState.isRecordingSession) {
+ return;
+ }
// Log the start of watch.
SomeArgs args = SomeArgs.obtain();
@@ -1563,26 +1558,6 @@ public final class TvInputManagerService extends SystemService {
}
@Override
- public void connect(IBinder sessionToken, final Uri channelUri, Bundle params, int userId) {
- final int callingUid = Binder.getCallingUid();
- final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
- userId, "connect");
- final long identity = Binder.clearCallingIdentity();
- try {
- synchronized (mLock) {
- try {
- getSessionLocked(sessionToken, callingUid, resolvedUserId).connect(
- channelUri, params);
- } catch (RemoteException | SessionNotFoundException e) {
- Slog.e(TAG, "error in connect", e);
- }
- }
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
- }
-
- @Override
public void startRecording(IBinder sessionToken, @Nullable Uri programHint, int userId) {
final int callingUid = Binder.getCallingUid();
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
@@ -2544,36 +2519,18 @@ public final class TvInputManagerService extends SystemService {
// For the recording session only
@Override
- public void onConnected() {
- synchronized (mLock) {
- if (DEBUG) {
- Slog.d(TAG, "onConnected()");
- }
- if (mSessionState.session == null || mSessionState.client == null) {
- return;
- }
- try {
- mSessionState.client.onConnected(mSessionState.seq);
- } catch (RemoteException e) {
- Slog.e(TAG, "error in onConnected", e);
- }
- }
- }
-
- // For the recording session only
- @Override
- public void onRecordingStarted() {
+ public void onTuned() {
synchronized (mLock) {
if (DEBUG) {
- Slog.d(TAG, "onRecordingStarted()");
+ Slog.d(TAG, "onTuned()");
}
if (mSessionState.session == null || mSessionState.client == null) {
return;
}
try {
- mSessionState.client.onRecordingStarted(mSessionState.seq);
+ mSessionState.client.onTuned(mSessionState.seq);
} catch (RemoteException e) {
- Slog.e(TAG, "error in onRecordingStarted", e);
+ Slog.e(TAG, "error in onTuned", e);
}
}
}