method public void notifyRecordingStopped(android.net.Uri);
method public abstract void onConnect(android.net.Uri);
method public abstract void onDisconnect();
- method public abstract void onStartRecording();
+ method public abstract void onStartRecording(android.net.Uri);
method public abstract void onStopRecording();
}
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 startRecording();
+ method public void startRecording(android.net.Uri);
method public void stopRecording();
}
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 onStartRecording();
+ method public abstract void onStartRecording(android.net.Uri);
method public abstract void onStopRecording();
}
method public void connect(java.lang.String, android.net.Uri, android.os.Bundle);
method public void disconnect();
method public void sendAppPrivateCommand(java.lang.String, android.os.Bundle);
- method public void startRecording();
+ method public void startRecording(android.net.Uri);
method public void stopRecording();
}
method public void notifyRecordingStopped(android.net.Uri);
method public abstract void onConnect(android.net.Uri);
method public abstract void onDisconnect();
- method public abstract void onStartRecording();
+ method public abstract void onStartRecording(android.net.Uri);
method public abstract void onStopRecording();
}
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 startRecording();
+ method public void startRecording(android.net.Uri);
method public void stopRecording();
}
// For the recording session
void connect(in IBinder sessionToken, in Uri channelUri, in Bundle params, int userId);
- void startRecording(in IBinder sessionToken, int userId);
+ void startRecording(in IBinder sessionToken, in Uri programHint, int userId);
void stopRecording(in IBinder sessionToken, int userId);
// For TV input hardware binding
// For the recording session
void connect(in Uri channelUri, in Bundle params);
void disconnect();
- void startRecording();
+ void startRecording(in Uri programHint);
void stopRecording();
}
package android.media.tv;
+import android.annotation.Nullable;
import android.content.Context;
import android.graphics.Rect;
import android.media.PlaybackParams;
break;
}
case DO_START_RECORDING: {
- mTvInputRecordingSessionImpl.startRecording();
+ mTvInputRecordingSessionImpl.startRecording((Uri) msg.obj);
break;
}
case DO_STOP_RECORDING: {
}
@Override
- public void startRecording() {
- mCaller.executeOrSendMessage(mCaller.obtainMessage(DO_START_RECORDING));
+ public void startRecording(@Nullable Uri programHint) {
+ mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_START_RECORDING, programHint));
}
@Override
}
/**
- * Starts TV program recording for the current recording session.
+ * Starts TV program recording in the current recording session.
+ *
+ * @param programHint The URI for the TV program to record as a hint, built by
+ * {@link TvContract#buildProgramUri(long)}. Can be {@code null}.
*/
- void startRecording() {
+ void startRecording(@Nullable Uri programHint) {
if (mToken == null) {
Log.w(TAG, "The session has been already released");
return;
}
try {
- mService.startRecording(mToken, mUserId);
+ mService.startRecording(mToken, programHint, mUserId);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
}
/**
- * Stops TV program recording for the current recording session.
+ * Stops TV program recording in the current recording session.
*/
void stopRecording() {
if (mToken == null) {
* Called when the application requests to start recording. Recording must start
* immediately.
*
+ * <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 #stopRecording()} to stop the recording.
+ *
* <p>The session must call either {@link #notifyRecordingStarted()} or
- * {@link #notifyError(int)}}.
+ * {@link #notifyError(int)}.
+ *
+ * @param programHint The URI for the TV program to record as a hint, built by
+ * {@link TvContract#buildProgramUri(long)}. Can be {@code null}.
*/
- public abstract void onStartRecording();
+ public abstract void onStartRecording(@Nullable Uri programHint);
/**
* Called when the application requests to stop recording. Recording must stop immediately.
*
* <p>The session must call either {@link #notifyRecordingStopped(Uri)} or
- * {@link #notifyError(int)}}.
+ * {@link #notifyError(int)}.
*/
public abstract void onStopRecording();
}
/**
- * Calls {@link #onStartRecording()}.
+ * Calls {@link #onStartRecording(Uri)}.
*
*/
- void startRecording() {
- onStartRecording();
+ void startRecording(@Nullable Uri programHint) {
+ onStartRecording(programHint);
}
/**
package android.media.tv;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.content.Context;
import android.net.Uri;
}
/**
- * Starts TV program recording for the current recording session. It is expected that recording
+ * Starts TV program recording in the current recording session. It is expected that recording
* starts immediately after calling this method.
*
+ * <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 recording session will respond by calling
* {@link RecordingCallback#onRecordingStarted()} or {@link RecordingCallback#onError(int)}.
+ *
+ * @param programHint The URI for the TV program to record as a hint, built by
+ * {@link TvContract#buildProgramUri(long)}. Can be null.
*/
- public void startRecording() {
+ public void startRecording(@Nullable Uri programHint) {
if (mSession != null) {
- mSession.startRecording();
+ mSession.startRecording(programHint);
}
}
/**
- * Stops TV program recording for the current recording session. It is expected that recording
+ * Stops TV program recording in the current recording session. It is expected that recording
* stops immediately after calling this method.
*
* <p>The recording session will respond by calling
@Override
public void onRecordingStopped(TvInputManager.Session session, Uri recordedProgramUri) {
if (DEBUG) {
- Log.d(TAG, "onRecordingStopped()");
+ Log.d(TAG, "onRecordingStopped(recordedProgramUri= " + recordedProgramUri + ")");
}
if (this != mSessionCallback) {
Log.w(TAG, "onRecordingStopped - session not created");
@Override
public void onError(TvInputManager.Session session, int error) {
if (DEBUG) {
- Log.d(TAG, "onError()");
+ Log.d(TAG, "onError(error=" + error + ")");
}
if (this != mSessionCallback) {
Log.w(TAG, "onError - session not created");
public void onSessionEvent(TvInputManager.Session session, String eventType,
Bundle eventArgs) {
if (DEBUG) {
- Log.d(TAG, "onSessionEvent(" + eventType + ")");
+ Log.d(TAG, "onSessionEvent(eventType=" + eventType + ", eventArgs=" + eventArgs
+ + ")");
}
if (this != mSessionCallback) {
Log.w(TAG, "onSessionEvent - session not created");
import static android.media.tv.TvInputManager.INPUT_STATE_CONNECTED;
import static android.media.tv.TvInputManager.INPUT_STATE_CONNECTED_STANDBY;
+import android.annotation.Nullable;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
}
@Override
- public void startRecording(IBinder sessionToken, int userId) {
+ public void startRecording(IBinder sessionToken, @Nullable Uri programHint, int userId) {
final int callingUid = Binder.getCallingUid();
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
userId, "startRecording");
try {
synchronized (mLock) {
try {
- getSessionLocked(sessionToken, callingUid, resolvedUserId).startRecording();
+ getSessionLocked(sessionToken, callingUid, resolvedUserId).startRecording(
+ programHint);
} catch (RemoteException | SessionNotFoundException e) {
Slog.e(TAG, "error in startRecording", e);
}
public void onSessionEvent(String eventType, Bundle eventArgs) {
synchronized (mLock) {
if (DEBUG) {
- Slog.d(TAG, "onEvent(what=" + eventType + ", data=" + eventArgs + ")");
+ Slog.d(TAG, "onEvent(eventType=" + eventType + ", eventArgs=" + eventArgs
+ + ")");
}
if (mSessionState.session == null || mSessionState.client == null) {
return;
public void onTimeShiftStatusChanged(int status) {
synchronized (mLock) {
if (DEBUG) {
- Slog.d(TAG, "onTimeShiftStatusChanged()");
+ Slog.d(TAG, "onTimeShiftStatusChanged(status=" + status + ")");
}
if (mSessionState.session == null || mSessionState.client == null) {
return;
public void onTimeShiftStartPositionChanged(long timeMs) {
synchronized (mLock) {
if (DEBUG) {
- Slog.d(TAG, "onTimeShiftStartPositionChanged()");
+ Slog.d(TAG, "onTimeShiftStartPositionChanged(timeMs=" + timeMs + ")");
}
if (mSessionState.session == null || mSessionState.client == null) {
return;
public void onTimeShiftCurrentPositionChanged(long timeMs) {
synchronized (mLock) {
if (DEBUG) {
- Slog.d(TAG, "onTimeShiftCurrentPositionChanged()");
+ Slog.d(TAG, "onTimeShiftCurrentPositionChanged(timeMs=" + timeMs + ")");
}
if (mSessionState.session == null || mSessionState.client == null) {
return;
public void onRecordingStopped(Uri recordedProgramUri) {
synchronized (mLock) {
if (DEBUG) {
- Slog.d(TAG, "onRecordingStopped()");
+ Slog.d(TAG, "onRecordingStopped(recordedProgramUri=" + recordedProgramUri
+ + ")");
}
if (mSessionState.session == null || mSessionState.client == null) {
return;
public void onError(int error) {
synchronized (mLock) {
if (DEBUG) {
- Slog.d(TAG, "onError()");
+ Slog.d(TAG, "onError(error=" + error + ")");
}
if (mSessionState.session == null || mSessionState.client == null) {
return;