OSDN Git Service

TIF: Separate service connection errors from recording errors
authorJae Seo <jaeseo@google.com>
Thu, 11 Feb 2016 08:59:10 +0000 (00:59 -0800)
committerJae Seo <jaeseo@google.com>
Thu, 11 Feb 2016 23:44:55 +0000 (15:44 -0800)
Also clarify the expected behaviors when an error has occurred in a
recording session.

Bug: 27110861
Change-Id: I811197e45ea94b1b0e151d534a1f030a84b89d10

api/current.txt
api/system-current.txt
api/test-current.txt
media/java/android/media/tv/TvInputManager.java
media/java/android/media/tv/TvInputService.java
media/java/android/media/tv/TvRecordingClient.java

index ab52161..ce2d3e7 100644 (file)
@@ -22950,10 +22950,8 @@ package android.media.tv {
     field public static final int INPUT_STATE_CONNECTED_STANDBY = 1; // 0x1
     field public static final int INPUT_STATE_DISCONNECTED = 2; // 0x2
     field public static final java.lang.String META_DATA_CONTENT_RATING_SYSTEMS = "android.media.tv.metadata.CONTENT_RATING_SYSTEMS";
-    field public static final int RECORDING_ERROR_CONNECTION_FAILED = 1; // 0x1
-    field public static final int RECORDING_ERROR_DISCONNECTED = 2; // 0x2
-    field public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 3; // 0x3
-    field public static final int RECORDING_ERROR_RESOURCE_BUSY = 4; // 0x4
+    field public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 1; // 0x1
+    field public static final int RECORDING_ERROR_RESOURCE_BUSY = 2; // 0x2
     field public static final int RECORDING_ERROR_UNKNOWN = 0; // 0x0
     field public static final long TIME_SHIFT_INVALID_TIME = -9223372036854775808L; // 0x8000000000000000L
     field public static final int TIME_SHIFT_STATUS_AVAILABLE = 3; // 0x3
@@ -23053,6 +23051,8 @@ package android.media.tv {
 
   public static abstract class TvRecordingClient.RecordingCallback {
     ctor public TvRecordingClient.RecordingCallback();
+    method public void onConnectionFailed(java.lang.String);
+    method public void onDisconnected(java.lang.String);
     method public void onError(int);
     method public void onRecordingStopped(android.net.Uri);
     method public void onTuned();
index 8ea1854..b3c148f 100644 (file)
@@ -24649,10 +24649,8 @@ package android.media.tv {
     field public static final int INPUT_STATE_CONNECTED_STANDBY = 1; // 0x1
     field public static final int INPUT_STATE_DISCONNECTED = 2; // 0x2
     field public static final java.lang.String META_DATA_CONTENT_RATING_SYSTEMS = "android.media.tv.metadata.CONTENT_RATING_SYSTEMS";
-    field public static final int RECORDING_ERROR_CONNECTION_FAILED = 1; // 0x1
-    field public static final int RECORDING_ERROR_DISCONNECTED = 2; // 0x2
-    field public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 3; // 0x3
-    field public static final int RECORDING_ERROR_RESOURCE_BUSY = 4; // 0x4
+    field public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 1; // 0x1
+    field public static final int RECORDING_ERROR_RESOURCE_BUSY = 2; // 0x2
     field public static final int RECORDING_ERROR_UNKNOWN = 0; // 0x0
     field public static final long TIME_SHIFT_INVALID_TIME = -9223372036854775808L; // 0x8000000000000000L
     field public static final int TIME_SHIFT_STATUS_AVAILABLE = 3; // 0x3
@@ -24811,6 +24809,8 @@ package android.media.tv {
 
   public static abstract class TvRecordingClient.RecordingCallback {
     ctor public TvRecordingClient.RecordingCallback();
+    method public void onConnectionFailed(java.lang.String);
+    method public void onDisconnected(java.lang.String);
     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);
index e716292..e1b15d0 100644 (file)
@@ -22959,10 +22959,8 @@ package android.media.tv {
     field public static final int INPUT_STATE_CONNECTED_STANDBY = 1; // 0x1
     field public static final int INPUT_STATE_DISCONNECTED = 2; // 0x2
     field public static final java.lang.String META_DATA_CONTENT_RATING_SYSTEMS = "android.media.tv.metadata.CONTENT_RATING_SYSTEMS";
-    field public static final int RECORDING_ERROR_CONNECTION_FAILED = 1; // 0x1
-    field public static final int RECORDING_ERROR_DISCONNECTED = 2; // 0x2
-    field public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 3; // 0x3
-    field public static final int RECORDING_ERROR_RESOURCE_BUSY = 4; // 0x4
+    field public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 1; // 0x1
+    field public static final int RECORDING_ERROR_RESOURCE_BUSY = 2; // 0x2
     field public static final int RECORDING_ERROR_UNKNOWN = 0; // 0x0
     field public static final long TIME_SHIFT_INVALID_TIME = -9223372036854775808L; // 0x8000000000000000L
     field public static final int TIME_SHIFT_STATUS_AVAILABLE = 3; // 0x3
@@ -23062,6 +23060,8 @@ package android.media.tv {
 
   public static abstract class TvRecordingClient.RecordingCallback {
     ctor public TvRecordingClient.RecordingCallback();
+    method public void onConnectionFailed(java.lang.String);
+    method public void onDisconnected(java.lang.String);
     method public void onError(int);
     method public void onRecordingStopped(android.net.Uri);
     method public void onTuned();
index 1320e38..00083e6 100644 (file)
@@ -157,35 +157,22 @@ public final class TvInputManager {
     public static final int RECORDING_ERROR_UNKNOWN = 0;
 
     /**
-     * Error for {@link TvRecordingClient.RecordingCallback#onError(int)}: The recording client has
-     * failed to establish a connection to a recording session.
-     */
-    public static final int RECORDING_ERROR_CONNECTION_FAILED = 1;
-
-    /**
-     * Error for {@link TvRecordingClient.RecordingCallback#onError(int)}: The recording client has
-     * been disconnected from the current recording session.
-     */
-    public static final int RECORDING_ERROR_DISCONNECTED = 2;
-
-    /**
      * Error for {@link TvInputService.RecordingSession#notifyError(int)} and
      * {@link TvRecordingClient.RecordingCallback#onError(int)}: Recording cannot proceed due to
      * insufficient storage space.
      */
-    public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 3;
+    public static final int RECORDING_ERROR_INSUFFICIENT_SPACE = 1;
 
     /**
      * Error for {@link TvInputService.RecordingSession#notifyError(int)} and
      * {@link TvRecordingClient.RecordingCallback#onError(int)}: Recording cannot proceed because
      * a required recording resource was not able to be allocated.
      */
-    public static final int RECORDING_ERROR_RESOURCE_BUSY = 4;
+    public static final int RECORDING_ERROR_RESOURCE_BUSY = 2;
 
     /** @hide */
     @Retention(RetentionPolicy.SOURCE)
-    @IntDef({RECORDING_ERROR_UNKNOWN, RECORDING_ERROR_CONNECTION_FAILED,
-            RECORDING_ERROR_DISCONNECTED, RECORDING_ERROR_INSUFFICIENT_SPACE,
+    @IntDef({RECORDING_ERROR_UNKNOWN, RECORDING_ERROR_INSUFFICIENT_SPACE,
             RECORDING_ERROR_RESOURCE_BUSY})
     public @interface RecordingError {}
 
index 334c84b..4ebd0fc 100644 (file)
@@ -1584,6 +1584,10 @@ public abstract class TvInputService extends Service {
          * new data entry in the {@link TvContract.RecordedPrograms} table that describes the newly
          * recorded program.
          *
+         * <p>The recording session must call this method in response to {@link #onStopRecording()}.
+         * The session may call it even before receiving a call to {@link #onStopRecording()} if a
+         * partially recorded program is available when there is an error.
+         *
          * @param recordedProgramUri The URI of the newly recorded program.
          */
         public void notifyRecordingStopped(final Uri recordedProgramUri) {
@@ -1604,8 +1608,14 @@ public abstract class TvInputService extends Service {
         }
 
         /**
-         * Informs the application that there is an error. It may be called at any time after this
-         * recording session is created until {@link #onRelease()} is called.
+         * Informs the application that there is an error and this recording session is no longer
+         * able to start or continue recording. It may be called at any time after the recording
+         * session is created until {@link #onRelease()} is called.
+         *
+         * <p>The application may release the current session upon receiving the error code through
+         * {@link TvRecordingClient.RecordingCallback#onError(int)}. The session may call
+         * {@link #notifyRecordingStopped(Uri)} if a partially recorded but still playable program
+         * is available, before calling this method.
          *
          * @param error The error code. Should be one of the followings.
          * <ul>
index 72606f5..1c920f5 100644 (file)
@@ -68,7 +68,7 @@ public class TvRecordingClient {
 
     /**
      * Tunes to a given channel for TV program recording. The first tune request will create a new
-     * recording session for the corresponding TV input and establish the connection between the
+     * recording session for the corresponding TV input and establish a connection between the
      * application and the session. If recording has already started in the current recording
      * session, this method throws an exception.
      *
@@ -88,7 +88,7 @@ public class TvRecordingClient {
 
     /**
      * Tunes to a given channel for TV program recording. The first tune request will create a new
-     * recording session for the corresponding TV input and establish the connection between the
+     * recording session for the corresponding TV input and establish a connection between the
      * application and the session. If recording has already started in the current recording
      * session, this method throws an exception.
      *
@@ -226,6 +226,23 @@ public class TvRecordingClient {
      */
     public abstract static class RecordingCallback {
         /**
+         * This is called when an error occurred while establishing a connection to the recording
+         * session for the corresponding TV input.
+         *
+         * @param inputId The ID of the TV input bound to the current TvRecordingClient.
+         */
+        public void onConnectionFailed(String inputId) {
+        }
+
+        /**
+         * This is called when the connection to the current recording session is lost.
+         *
+         * @param inputId The ID of the TV input bound to the current TvRecordingClient.
+         */
+        public void onDisconnected(String inputId) {
+        }
+
+        /**
          * This is called when the recording session has been tuned to the given channel and is
          * ready to start recording.
          */
@@ -249,8 +266,6 @@ public class TvRecordingClient {
          * @param error The error code. Should be one of the followings.
          * <ul>
          * <li>{@link TvInputManager#RECORDING_ERROR_UNKNOWN}
-         * <li>{@link TvInputManager#RECORDING_ERROR_CONNECTION_FAILED}
-         * <li>{@link TvInputManager#RECORDING_ERROR_DISCONNECTED}
          * <li>{@link TvInputManager#RECORDING_ERROR_INSUFFICIENT_SPACE}
          * <li>{@link TvInputManager#RECORDING_ERROR_RESOURCE_BUSY}
          * </ul>
@@ -305,7 +320,9 @@ public class TvRecordingClient {
                 mSession.tune(mChannelUri, mConnectionParams);
             } else {
                 mSessionCallback = null;
-                mCallback.onError(TvInputManager.RECORDING_ERROR_CONNECTION_FAILED);
+                if (mCallback != null) {
+                    mCallback.onConnectionFailed(mInputId);
+                }
             }
         }
 
@@ -331,11 +348,13 @@ public class TvRecordingClient {
                 Log.w(TAG, "onSessionReleased - session not created");
                 return;
             }
-            mSessionCallback = null;
-            mSession = null;
             mIsTuned = false;
             mIsRecordingStarted = false;
-            mCallback.onError(TvInputManager.RECORDING_ERROR_DISCONNECTED);
+            mSessionCallback = null;
+            mSession = null;
+            if (mCallback != null) {
+                mCallback.onDisconnected(mInputId);
+            }
         }
 
         @Override