diff options
| author | 2016-02-06 11:11:35 +0900 | |
|---|---|---|
| committer | 2016-02-08 14:51:52 -0800 | |
| commit | 4eee6a73e476cd2d82a69f3a535628901047f140 (patch) | |
| tree | 9264462de23a4c5ed41d3ad6ab3b3089dd846340 | |
| parent | abda420b9d2959776093230cd2e157a6080f2f64 (diff) | |
TIF: Allow the application to indicate a TV program to record
Bug: 26962040
Change-Id: I2f062a4621c8a9a6765543826ba2cd607f1468d4
| -rw-r--r-- | api/current.txt | 4 | ||||
| -rw-r--r-- | api/system-current.txt | 4 | ||||
| -rw-r--r-- | api/test-current.txt | 4 | ||||
| -rw-r--r-- | media/java/android/media/tv/ITvInputManager.aidl | 2 | ||||
| -rw-r--r-- | media/java/android/media/tv/ITvInputSession.aidl | 2 | ||||
| -rw-r--r-- | media/java/android/media/tv/ITvInputSessionWrapper.java | 7 | ||||
| -rw-r--r-- | media/java/android/media/tv/TvInputManager.java | 11 | ||||
| -rw-r--r-- | media/java/android/media/tv/TvInputService.java | 22 | ||||
| -rw-r--r-- | media/java/android/media/tv/TvRecordingClient.java | 27 | ||||
| -rw-r--r-- | services/core/java/com/android/server/tv/TvInputManagerService.java | 20 |
10 files changed, 67 insertions, 36 deletions
diff --git a/api/current.txt b/api/current.txt index 6406f57fe577..93b10b1ddac1 100644 --- a/api/current.txt +++ b/api/current.txt @@ -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(); } diff --git a/api/system-current.txt b/api/system-current.txt index ed094f9c9691..e8c4c37d30c3 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -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(); } diff --git a/api/test-current.txt b/api/test-current.txt index 417107d30a6b..084aeab5ce94 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -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(); } diff --git a/media/java/android/media/tv/ITvInputManager.aidl b/media/java/android/media/tv/ITvInputManager.aidl index d18933385463..12a220f2974f 100644 --- a/media/java/android/media/tv/ITvInputManager.aidl +++ b/media/java/android/media/tv/ITvInputManager.aidl @@ -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 diff --git a/media/java/android/media/tv/ITvInputSession.aidl b/media/java/android/media/tv/ITvInputSession.aidl index 408a76277845..07781bc0a042 100644 --- a/media/java/android/media/tv/ITvInputSession.aidl +++ b/media/java/android/media/tv/ITvInputSession.aidl @@ -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(); } diff --git a/media/java/android/media/tv/ITvInputSessionWrapper.java b/media/java/android/media/tv/ITvInputSessionWrapper.java index 4ac58766ca94..b15acef583b0 100644 --- a/media/java/android/media/tv/ITvInputSessionWrapper.java +++ b/media/java/android/media/tv/ITvInputSessionWrapper.java @@ -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 diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java index 1cd19589cb94..d76408e3a9d3 100644 --- a/media/java/android/media/tv/TvInputManager.java +++ b/media/java/android/media/tv/TvInputManager.java @@ -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) { diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java index d48b2c8b0816..8ce304376101 100644 --- a/media/java/android/media/tv/TvInputService.java +++ b/media/java/android/media/tv/TvInputService.java @@ -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); } /** diff --git a/media/java/android/media/tv/TvRecordingClient.java b/media/java/android/media/tv/TvRecordingClient.java index 1d80068fbdf8..b943c3d5f559 100644 --- a/media/java/android/media/tv/TvRecordingClient.java +++ b/media/java/android/media/tv/TvRecordingClient.java @@ -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"); diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java index 3e99a4cfe01e..0f51c82eba37 100644 --- a/services/core/java/com/android/server/tv/TvInputManagerService.java +++ b/services/core/java/com/android/server/tv/TvInputManagerService.java @@ -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; |