Merge "TIF: DVR API customization"

This commit is contained in:
TreeHugger Robot
2020-01-28 07:57:33 +00:00
committed by Android (Google) Code Review
8 changed files with 78 additions and 12 deletions

View File

@@ -29200,6 +29200,7 @@ package android.media.tv {
method public void onAppPrivateCommand(@NonNull String, android.os.Bundle);
method public abstract void onRelease();
method public abstract void onStartRecording(@Nullable android.net.Uri);
method public void onStartRecording(@Nullable android.net.Uri, @NonNull android.os.Bundle);
method public abstract void onStopRecording();
method public abstract void onTune(android.net.Uri);
method public void onTune(android.net.Uri, android.os.Bundle);
@@ -29250,6 +29251,7 @@ package android.media.tv {
method public void release();
method public void sendAppPrivateCommand(@NonNull String, android.os.Bundle);
method public void startRecording(@Nullable android.net.Uri);
method public void startRecording(@Nullable android.net.Uri, @NonNull android.os.Bundle);
method public void stopRecording();
method public void tune(String, android.net.Uri);
method public void tune(String, android.net.Uri, android.os.Bundle);

View File

@@ -89,7 +89,7 @@ interface ITvInputManager {
void timeShiftEnablePositionTracking(in IBinder sessionToken, boolean enable, int userId);
// For the recording session
void startRecording(in IBinder sessionToken, in Uri programUri, int userId);
void startRecording(in IBinder sessionToken, in Uri programUri, in Bundle params, int userId);
void stopRecording(in IBinder sessionToken, int userId);
// For TV input hardware binding

View File

@@ -56,6 +56,6 @@ oneway interface ITvInputSession {
void timeShiftEnablePositionTracking(boolean enable);
// For the recording session
void startRecording(in Uri programUri);
void startRecording(in Uri programUri, in Bundle params);
void stopRecording();
}

View File

@@ -216,7 +216,8 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
break;
}
case DO_START_RECORDING: {
mTvInputRecordingSessionImpl.startRecording((Uri) msg.obj);
SomeArgs args = (SomeArgs) msg.obj;
mTvInputRecordingSessionImpl.startRecording((Uri) args.arg1, (Bundle) args.arg2);
break;
}
case DO_STOP_RECORDING: {
@@ -352,8 +353,9 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
}
@Override
public void startRecording(@Nullable Uri programUri) {
mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_START_RECORDING, programUri));
public void startRecording(@Nullable Uri programUri, @Nullable Bundle params) {
mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_START_RECORDING, programUri,
params));
}
@Override

View File

@@ -2381,12 +2381,23 @@ public final class TvInputManager {
* {@link TvContract#buildProgramUri(long)}. Can be {@code null}.
*/
void startRecording(@Nullable Uri programUri) {
startRecording(programUri, null);
}
/**
* Starts TV program recording in the current recording session.
*
* @param programUri The URI for the TV program to record as a hint, built by
* {@link TvContract#buildProgramUri(long)}. Can be {@code null}.
* @param params A set of extra parameters which might be handled with this event.
*/
void startRecording(@Nullable Uri programUri, @Nullable Bundle params) {
if (mToken == null) {
Log.w(TAG, "The session has been already released");
return;
}
try {
mService.startRecording(mToken, programUri, mUserId);
mService.startRecording(mToken, programUri, params, mUserId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}

View File

@@ -1817,6 +1817,30 @@ public abstract class TvInputService extends Service {
*/
public abstract void onStartRecording(@Nullable Uri programUri);
/**
* 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 for filling in program specific
* data fields in the {@link android.media.tv.TvContract.RecordedPrograms} table.
* A non-null {@code programUri} implies the started recording should be of that specific
* program, whereas null {@code programUri} 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 session must call {@link #notifyError(int)} if the start request cannot be
* fulfilled.
*
* @param programUri The URI for the TV program to record, built by
* {@link TvContract#buildProgramUri(long)}. Can be {@code null}.
* @param params Domain-specific data for this tune request. Keys <em>must</em> be a scoped
* name, i.e. prefixed with a package name you own, so that different developers
* will not create conflicting keys.
*/
public void onStartRecording(@Nullable Uri programUri, @NonNull Bundle params) {
onStartRecording(programUri);
}
/**
* Called when the application requests to stop TV program recording. Recording must stop
* immediately when this method is called.
@@ -1867,11 +1891,11 @@ public abstract class TvInputService extends Service {
}
/**
* Calls {@link #onStartRecording(Uri)}.
* Calls {@link #onStartRecording(Uri, Bundle)}.
*
*/
void startRecording(@Nullable Uri programUri) {
onStartRecording(programUri);
void startRecording(@Nullable Uri programUri, @NonNull Bundle params) {
onStartRecording(programUri, params);
}
/**

View File

@@ -170,11 +170,37 @@ public class TvRecordingClient {
* @throws IllegalStateException If {@link #tune} request hasn't been handled yet.
*/
public void startRecording(@Nullable Uri programUri) {
startRecording(programUri, Bundle.EMPTY);
}
/**
* 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 for filling in program specific data
* fields in the {@link android.media.tv.TvContract.RecordedPrograms} table.
* A non-null {@code programUri} implies the started recording should be of that specific
* program, whereas null {@code programUri} 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#onError(int)} if
* the start request cannot be fulfilled.
*
* @param programUri The URI for the TV program to record, built by
* {@link TvContract#buildProgramUri(long)}. Can be {@code null}.
* @param params Domain-specific data for this request. Keys <em>must</em> be a scoped
* name, i.e. prefixed with a package name you own, so that different developers will
* not create conflicting keys.
* @throws IllegalStateException If {@link #tune} request hasn't been handled yet.
*/
public void startRecording(@Nullable Uri programUri, @NonNull Bundle params) {
if (!mIsTuned) {
throw new IllegalStateException("startRecording failed - not yet tuned");
}
if (mSession != null) {
mSession.startRecording(programUri);
mSession.startRecording(programUri, params);
mIsRecordingStarted = true;
}
}

View File

@@ -1681,7 +1681,8 @@ public final class TvInputManagerService extends SystemService {
}
@Override
public void startRecording(IBinder sessionToken, @Nullable Uri programUri, int userId) {
public void startRecording(IBinder sessionToken, @Nullable Uri programUri,
@Nullable Bundle params, int userId) {
final int callingUid = Binder.getCallingUid();
final int resolvedUserId = resolveCallingUserId(Binder.getCallingPid(), callingUid,
userId, "startRecording");
@@ -1690,7 +1691,7 @@ public final class TvInputManagerService extends SystemService {
synchronized (mLock) {
try {
getSessionLocked(sessionToken, callingUid, resolvedUserId).startRecording(
programUri);
programUri, params);
} catch (RemoteException | SessionNotFoundException e) {
Slog.e(TAG, "error in startRecording", e);
}