TIF: Allow the application to indicate a TV program to record

Bug: 26962040
Change-Id: I2f062a4621c8a9a6765543826ba2cd607f1468d4
This commit is contained in:
Jae Seo
2016-02-06 11:11:35 +09:00
parent abda420b9d
commit 4eee6a73e4
10 changed files with 67 additions and 36 deletions

View File

@@ -22990,7 +22990,7 @@ package android.media.tv {
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();
}
@@ -23036,7 +23036,7 @@ package android.media.tv {
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();
}

View File

@@ -24741,7 +24741,7 @@ package android.media.tv {
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();
}
@@ -24793,7 +24793,7 @@ package android.media.tv {
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();
}

View File

@@ -22999,7 +22999,7 @@ package android.media.tv {
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();
}
@@ -23045,7 +23045,7 @@ package android.media.tv {
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();
}

View File

@@ -88,7 +88,7 @@ interface ITvInputManager {
// 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

View File

@@ -58,6 +58,6 @@ oneway interface ITvInputSession {
// For the recording session
void connect(in Uri channelUri, in Bundle params);
void disconnect();
void startRecording();
void startRecording(in Uri programHint);
void stopRecording();
}

View File

@@ -16,6 +16,7 @@
package android.media.tv;
import android.annotation.Nullable;
import android.content.Context;
import android.graphics.Rect;
import android.media.PlaybackParams;
@@ -220,7 +221,7 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
break;
}
case DO_START_RECORDING: {
mTvInputRecordingSessionImpl.startRecording();
mTvInputRecordingSessionImpl.startRecording((Uri) msg.obj);
break;
}
case DO_STOP_RECORDING: {
@@ -366,8 +367,8 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
}
@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

View File

@@ -2039,22 +2039,25 @@ public final class TvInputManager {
}
/**
* 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) {

View File

@@ -1699,16 +1699,26 @@ public abstract class TvInputService extends Service {
* 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();
@@ -1744,11 +1754,11 @@ public abstract class TvInputService extends Service {
}
/**
* Calls {@link #onStartRecording()}.
* Calls {@link #onStartRecording(Uri)}.
*
*/
void startRecording() {
onStartRecording();
void startRecording(@Nullable Uri programHint) {
onStartRecording(programHint);
}
/**

View File

@@ -17,6 +17,7 @@
package android.media.tv;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.content.Context;
import android.net.Uri;
@@ -131,20 +132,31 @@ public class TvRecordingClient {
}
/**
* 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
@@ -325,7 +337,7 @@ public class TvRecordingClient {
@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");
@@ -337,7 +349,7 @@ public class TvRecordingClient {
@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");
@@ -350,7 +362,8 @@ public class TvRecordingClient {
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");

View File

@@ -19,6 +19,7 @@ package com.android.server.tv;
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;
@@ -1582,7 +1583,7 @@ public final class TvInputManagerService extends SystemService {
}
@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");
@@ -1590,7 +1591,8 @@ public final class TvInputManagerService extends SystemService {
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);
}
@@ -2474,7 +2476,8 @@ public final class TvInputManagerService extends SystemService {
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;
@@ -2491,7 +2494,7 @@ public final class TvInputManagerService extends SystemService {
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;
@@ -2508,7 +2511,7 @@ public final class TvInputManagerService extends SystemService {
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;
@@ -2525,7 +2528,7 @@ public final class TvInputManagerService extends SystemService {
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;
@@ -2580,7 +2583,8 @@ public final class TvInputManagerService extends SystemService {
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;
@@ -2598,7 +2602,7 @@ public final class TvInputManagerService extends SystemService {
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;