TIF: Address API review comments
Bug: 27386052
Change-Id: I242819e0817723e247b8fe646d534899ab50af76
diff --git a/api/current.txt b/api/current.txt
index 0376380..2c172b4 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -22976,7 +22976,7 @@
}
public static final class TvInputInfo.Builder {
- ctor public TvInputInfo.Builder(android.content.Context, java.lang.Class<?>);
+ ctor public TvInputInfo.Builder(android.content.Context, android.content.ComponentName);
method public android.media.tv.TvInputInfo build() throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
method public android.media.tv.TvInputInfo.Builder setCanRecord(boolean);
method public android.media.tv.TvInputInfo.Builder setTunerCount(int);
@@ -23044,7 +23044,7 @@
ctor public TvInputService.RecordingSession(android.content.Context);
method public void notifyError(int);
method public void notifyRecordingStopped(android.net.Uri);
- method public void notifyTuned();
+ method public void notifyTuned(android.net.Uri);
method public abstract void onRelease();
method public abstract void onStartRecording(android.net.Uri);
method public abstract void onStopRecording();
@@ -23103,7 +23103,7 @@
method public void onDisconnected(java.lang.String);
method public void onError(int);
method public void onRecordingStopped(android.net.Uri);
- method public void onTuned();
+ method public void onTuned(android.net.Uri);
}
public final class TvTrackInfo implements android.os.Parcelable {
diff --git a/api/system-current.txt b/api/system-current.txt
index b4d0c39..53a3785 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -24663,7 +24663,7 @@
}
public static final class TvInputInfo.Builder {
- ctor public TvInputInfo.Builder(android.content.Context, java.lang.Class<?>);
+ ctor public TvInputInfo.Builder(android.content.Context, android.content.ComponentName);
method public android.media.tv.TvInputInfo build() throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
method public android.media.tv.TvInputInfo.Builder setCanRecord(boolean);
method public android.media.tv.TvInputInfo.Builder setHdmiDeviceInfo(android.hardware.hdmi.HdmiDeviceInfo);
@@ -24808,7 +24808,7 @@
method public void notifyError(int);
method public void notifyRecordingStopped(android.net.Uri);
method public void notifySessionEvent(java.lang.String, android.os.Bundle);
- method public void notifyTuned();
+ method public void notifyTuned(android.net.Uri);
method public void onAppPrivateCommand(java.lang.String, android.os.Bundle);
method public abstract void onRelease();
method public abstract void onStartRecording(android.net.Uri);
@@ -24876,7 +24876,7 @@
method public void onError(int);
method public void onEvent(java.lang.String, java.lang.String, android.os.Bundle);
method public void onRecordingStopped(android.net.Uri);
- method public void onTuned();
+ method public void onTuned(android.net.Uri);
}
public class TvStreamConfig implements android.os.Parcelable {
diff --git a/api/test-current.txt b/api/test-current.txt
index ebeae1c..003d7b83 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -22985,7 +22985,7 @@
}
public static final class TvInputInfo.Builder {
- ctor public TvInputInfo.Builder(android.content.Context, java.lang.Class<?>);
+ ctor public TvInputInfo.Builder(android.content.Context, android.content.ComponentName);
method public android.media.tv.TvInputInfo build() throws java.io.IOException, org.xmlpull.v1.XmlPullParserException;
method public android.media.tv.TvInputInfo.Builder setCanRecord(boolean);
method public android.media.tv.TvInputInfo.Builder setTunerCount(int);
@@ -23053,7 +23053,7 @@
ctor public TvInputService.RecordingSession(android.content.Context);
method public void notifyError(int);
method public void notifyRecordingStopped(android.net.Uri);
- method public void notifyTuned();
+ method public void notifyTuned(android.net.Uri);
method public abstract void onRelease();
method public abstract void onStartRecording(android.net.Uri);
method public abstract void onStopRecording();
@@ -23112,7 +23112,7 @@
method public void onDisconnected(java.lang.String);
method public void onError(int);
method public void onRecordingStopped(android.net.Uri);
- method public void onTuned();
+ method public void onTuned(android.net.Uri);
}
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 5dd4e85..72f8b57 100644
--- a/media/java/android/media/tv/ITvInputClient.aidl
+++ b/media/java/android/media/tv/ITvInputClient.aidl
@@ -45,7 +45,7 @@
void onTimeShiftCurrentPositionChanged(long timeMs, int seq);
// For the recording session
- void onTuned(int seq);
+ void onTuned(int seq, in Uri channelUri);
void onRecordingStopped(in Uri recordedProgramUri, int seq);
void onError(int error, int seq);
}
diff --git a/media/java/android/media/tv/ITvInputSessionCallback.aidl b/media/java/android/media/tv/ITvInputSessionCallback.aidl
index 60d6f0d..af76f90 100644
--- a/media/java/android/media/tv/ITvInputSessionCallback.aidl
+++ b/media/java/android/media/tv/ITvInputSessionCallback.aidl
@@ -42,7 +42,7 @@
void onTimeShiftCurrentPositionChanged(long timeMs);
// For the recording session
- void onTuned();
+ void onTuned(in Uri channelUri);
void onRecordingStopped(in Uri recordedProgramUri);
void onError(int error);
}
diff --git a/media/java/android/media/tv/TvInputInfo.java b/media/java/android/media/tv/TvInputInfo.java
index 6e0f5f2..63e3edc 100644
--- a/media/java/android/media/tv/TvInputInfo.java
+++ b/media/java/android/media/tv/TvInputInfo.java
@@ -677,11 +677,12 @@
* Constructs a new builder for {@link TvInputInfo}.
*
* @param context A Context of the application package implementing this class.
- * @param cls The component class that is to be used for the {@link TvInputService}.
+ * @param component The name of the application component to be used for the
+ * {@link TvInputService}.
*/
- public Builder(Context context, Class<?> cls) {
+ public Builder(Context context, ComponentName component) {
mContext = context;
- Intent intent = new Intent(TvInputService.SERVICE_INTERFACE).setClass(context, cls);
+ Intent intent = new Intent(TvInputService.SERVICE_INTERFACE).setComponent(component);
mResolveInfo = context.getPackageManager().resolveService(intent,
PackageManager.GET_SERVICES | PackageManager.GET_META_DATA);
}
diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java
index 2703b1a..59dfbee 100644
--- a/media/java/android/media/tv/TvInputManager.java
+++ b/media/java/android/media/tv/TvInputManager.java
@@ -478,8 +478,10 @@
/**
* This is called when the recording session has been tuned to the given channel and is
* ready to start recording.
+ *
+ * @param channelUri The URI of a channel.
*/
- void onTuned(Session session) {
+ void onTuned(Session session, Uri channelUri) {
}
// For the recording session only
@@ -653,11 +655,11 @@
}
// For the recording session only
- void postTuned() {
+ void postTuned(final Uri channelUri) {
mHandler.post(new Runnable() {
@Override
public void run() {
- mSessionCallback.onTuned(mSession);
+ mSessionCallback.onTuned(mSession, channelUri);
}
});
}
@@ -1013,14 +1015,14 @@
}
@Override
- public void onTuned(int seq) {
+ public void onTuned(int seq, Uri channelUri) {
synchronized (mSessionCallbackRecordMap) {
SessionCallbackRecord record = mSessionCallbackRecordMap.get(seq);
if (record == null) {
Log.e(TAG, "Callback not found for seq " + seq);
return;
}
- record.postTuned();
+ record.postTuned(channelUri);
}
}
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java
index db851a3..8fb58b5 100644
--- a/media/java/android/media/tv/TvInputService.java
+++ b/media/java/android/media/tv/TvInputService.java
@@ -1567,8 +1567,10 @@
* 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.
+ *
+ * @param channelUri The URI of a channel.
*/
- public void notifyTuned() {
+ public void notifyTuned(Uri channelUri) {
executeOrPostRunnableOnMainThread(new Runnable() {
@MainThread
@Override
@@ -1576,7 +1578,7 @@
try {
if (DEBUG) Log.d(TAG, "notifyTuned");
if (mSessionCallback != null) {
- mSessionCallback.onTuned();
+ mSessionCallback.onTuned(channelUri);
}
} catch (RemoteException e) {
Log.w(TAG, "error in notifyTuned", e);
@@ -1679,7 +1681,7 @@
* <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
+ * <p>The session must call {@link #notifyTuned(Uri)} if the tune request was fulfilled, or
* {@link #notifyError(int)} otherwise.
*
* @param channelUri The URI of a channel.
@@ -1708,8 +1710,8 @@
* 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.
+ * <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 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
@@ -1718,10 +1720,10 @@
* <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
+ * @param programUri The URI for the TV program to record, built by
* {@link TvContract#buildProgramUri(long)}. Can be {@code null}.
*/
- public abstract void onStartRecording(@Nullable Uri programHint);
+ public abstract void onStartRecording(@Nullable Uri programUri);
/**
* Called when the application requests to stop TV program recording. Recording must stop
diff --git a/media/java/android/media/tv/TvRecordingClient.java b/media/java/android/media/tv/TvRecordingClient.java
index 1c920f5..d48ea21e 100644
--- a/media/java/android/media/tv/TvRecordingClient.java
+++ b/media/java/android/media/tv/TvRecordingClient.java
@@ -76,11 +76,12 @@
* during recording.
*
* <p>The recording session will respond by calling
- * {@link RecordingCallback#onTuned()} if the tune request was fulfilled, or
+ * {@link RecordingCallback#onTuned(Uri)} 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.
+ * @throws IllegalStateException If recording is already started.
*/
public void tune(String inputId, Uri channelUri) {
tune(inputId, channelUri, null);
@@ -102,6 +103,7 @@
* @param inputId The ID of the TV input for the given channel.
* @param channelUri The URI of a channel.
* @param params Extra parameters.
+ * @throws IllegalStateException If recording is already started.
* @hide
*/
@SystemApi
@@ -152,8 +154,8 @@
* 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 for filling in program
- * specific data fields in the {@link android.media.tv.TvContract.RecordedPrograms} table.
+ * <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 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
@@ -162,15 +164,16 @@
* <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
+ * @param programUri The URI for the TV program to record, built by
* {@link TvContract#buildProgramUri(long)}. Can be {@code null}.
+ * @throws IllegalStateException If {@link #tune} request hasn't been handled yet.
*/
- public void startRecording(@Nullable Uri programHint) {
+ public void startRecording(@Nullable Uri programUri) {
if (!mIsTuned) {
throw new IllegalStateException("startRecording failed - not yet tuned");
}
if (mSession != null) {
- mSession.startRecording(programHint);
+ mSession.startRecording(programUri);
mIsRecordingStarted = true;
}
}
@@ -245,8 +248,10 @@
/**
* This is called when the recording session has been tuned to the given channel and is
* ready to start recording.
+ *
+ * @param channelUri The URI of a channel.
*/
- public void onTuned() {
+ public void onTuned(Uri channelUri) {
}
/**
@@ -327,7 +332,7 @@
}
@Override
- void onTuned(TvInputManager.Session session) {
+ void onTuned(TvInputManager.Session session, Uri channelUri) {
if (DEBUG) {
Log.d(TAG, "onTuned()");
}
@@ -336,7 +341,7 @@
return;
}
mIsTuned = true;
- mCallback.onTuned();
+ mCallback.onTuned(channelUri);
}
@Override
diff --git a/services/core/java/com/android/server/tv/TvInputManagerService.java b/services/core/java/com/android/server/tv/TvInputManagerService.java
index 8a2729e..49aaa4a 100644
--- a/services/core/java/com/android/server/tv/TvInputManagerService.java
+++ b/services/core/java/com/android/server/tv/TvInputManagerService.java
@@ -2512,7 +2512,7 @@
// For the recording session only
@Override
- public void onTuned() {
+ public void onTuned(Uri channelUri) {
synchronized (mLock) {
if (DEBUG) {
Slog.d(TAG, "onTuned()");
@@ -2521,7 +2521,7 @@
return;
}
try {
- mSessionState.client.onTuned(mSessionState.seq);
+ mSessionState.client.onTuned(mSessionState.seq, channelUri);
} catch (RemoteException e) {
Slog.e(TAG, "error in onTuned", e);
}