Merge "TIF: More annotations" into nyc-dev

This commit is contained in:
TreeHugger Robot
2016-04-14 00:05:03 +00:00
committed by Android (Google) Code Review
5 changed files with 45 additions and 22 deletions

View File

@@ -16,7 +16,9 @@
package android.media.tv; package android.media.tv;
import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.StringRes;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
@@ -48,6 +50,8 @@ import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Locale; import java.util.Locale;
@@ -62,6 +66,12 @@ public final class TvInputInfo implements Parcelable {
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
private static final String TAG = "TvInputInfo"; private static final String TAG = "TvInputInfo";
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef({TYPE_TUNER, TYPE_OTHER, TYPE_COMPOSITE, TYPE_SVIDEO, TYPE_SCART, TYPE_COMPONENT,
TYPE_VGA, TYPE_DVI, TYPE_HDMI, TYPE_DISPLAY_PORT})
public @interface Type {}
// Should be in sync with frameworks/base/core/res/res/values/attrs.xml // Should be in sync with frameworks/base/core/res/res/values/attrs.xml
/** /**
* TV input type: the TV input service is a tuner which provides channels. * TV input type: the TV input service is a tuner which provides channels.
@@ -343,6 +353,7 @@ public final class TvInputInfo implements Parcelable {
/** /**
* Returns the type of this TV input. * Returns the type of this TV input.
*/ */
@Type
public int getType() { public int getType() {
return mType; return mType;
} }
@@ -768,7 +779,7 @@ public final class TvInputInfo implements Parcelable {
* @hide * @hide
*/ */
@SystemApi @SystemApi
public Builder setLabel(int resId) { public Builder setLabel(@StringRes int resId) {
if (mLabel != null) { if (mLabel != null) {
throw new IllegalStateException("Label text is already set."); throw new IllegalStateException("Label text is already set.");
} }

View File

@@ -99,6 +99,13 @@ public final class TvInputManager {
*/ */
public static final int DVB_DEVICE_FRONTEND = DVB_DEVICE_END; public static final int DVB_DEVICE_FRONTEND = DVB_DEVICE_END;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef({VIDEO_UNAVAILABLE_REASON_UNKNOWN, VIDEO_UNAVAILABLE_REASON_TUNING,
VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL, VIDEO_UNAVAILABLE_REASON_BUFFERING,
VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY})
public @interface VideoUnavailableReason {}
static final int VIDEO_UNAVAILABLE_REASON_START = 0; static final int VIDEO_UNAVAILABLE_REASON_START = 0;
static final int VIDEO_UNAVAILABLE_REASON_END = 4; static final int VIDEO_UNAVAILABLE_REASON_END = 4;
@@ -135,10 +142,9 @@ public final class TvInputManager {
/** @hide */ /** @hide */
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({VIDEO_UNAVAILABLE_REASON_UNKNOWN, VIDEO_UNAVAILABLE_REASON_TUNING, @IntDef({TIME_SHIFT_STATUS_UNKNOWN, TIME_SHIFT_STATUS_UNSUPPORTED,
VIDEO_UNAVAILABLE_REASON_WEAK_SIGNAL, VIDEO_UNAVAILABLE_REASON_BUFFERING, TIME_SHIFT_STATUS_UNAVAILABLE, TIME_SHIFT_STATUS_AVAILABLE})
VIDEO_UNAVAILABLE_REASON_AUDIO_ONLY}) public @interface TimeShiftStatus {}
public @interface VideoUnavailableReason {}
/** /**
* Status for {@link TvInputService.Session#notifyTimeShiftStatusChanged(int)} and * Status for {@link TvInputService.Session#notifyTimeShiftStatusChanged(int)} and
@@ -169,12 +175,6 @@ public final class TvInputManager {
*/ */
public static final int TIME_SHIFT_STATUS_AVAILABLE = 3; public static final int TIME_SHIFT_STATUS_AVAILABLE = 3;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef({TIME_SHIFT_STATUS_UNKNOWN, TIME_SHIFT_STATUS_UNSUPPORTED,
TIME_SHIFT_STATUS_UNAVAILABLE, TIME_SHIFT_STATUS_AVAILABLE})
public @interface TimeShiftStatus {}
/** /**
* Value returned by {@link TvInputService.Session#onTimeShiftGetCurrentPosition()} and * Value returned by {@link TvInputService.Session#onTimeShiftGetCurrentPosition()} and
* {@link TvInputService.Session#onTimeShiftGetStartPosition()} when time shifting has not * {@link TvInputService.Session#onTimeShiftGetStartPosition()} when time shifting has not
@@ -182,6 +182,12 @@ public final class TvInputManager {
*/ */
public static final long TIME_SHIFT_INVALID_TIME = Long.MIN_VALUE; public static final long TIME_SHIFT_INVALID_TIME = Long.MIN_VALUE;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef({RECORDING_ERROR_UNKNOWN, RECORDING_ERROR_INSUFFICIENT_SPACE,
RECORDING_ERROR_RESOURCE_BUSY})
public @interface RecordingError {}
/** /**
* Error for {@link TvInputService.RecordingSession#notifyError(int)} and * Error for {@link TvInputService.RecordingSession#notifyError(int)} and
* {@link TvRecordingClient.RecordingCallback#onError(int)}: The requested operation cannot be * {@link TvRecordingClient.RecordingCallback#onError(int)}: The requested operation cannot be
@@ -205,9 +211,8 @@ public final class TvInputManager {
/** @hide */ /** @hide */
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
@IntDef({RECORDING_ERROR_UNKNOWN, RECORDING_ERROR_INSUFFICIENT_SPACE, @IntDef({INPUT_STATE_CONNECTED, INPUT_STATE_CONNECTED_STANDBY, INPUT_STATE_DISCONNECTED})
RECORDING_ERROR_RESOURCE_BUSY}) public @interface InputState {}
public @interface RecordingError {}
/** /**
* State for {@link #getInputState(String)} and * State for {@link #getInputState(String)} and
@@ -240,11 +245,6 @@ public final class TvInputManager {
*/ */
public static final int INPUT_STATE_DISCONNECTED = 2; public static final int INPUT_STATE_DISCONNECTED = 2;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef({INPUT_STATE_CONNECTED, INPUT_STATE_CONNECTED_STANDBY, INPUT_STATE_DISCONNECTED})
public @interface InputState {}
/** /**
* Broadcast intent action when the user blocked content ratings change. For use with the * Broadcast intent action when the user blocked content ratings change. For use with the
* {@link #isRatingBlocked}. * {@link #isRatingBlocked}.

View File

@@ -16,6 +16,7 @@
package android.media.tv; package android.media.tv;
import android.annotation.FloatRange;
import android.annotation.MainThread; import android.annotation.MainThread;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
@@ -823,7 +824,7 @@ public abstract class TvInputService extends Service {
* *
* @param volume A volume value between {@code 0.0f} to {@code 1.0f}. * @param volume A volume value between {@code 0.0f} to {@code 1.0f}.
*/ */
public abstract void onSetStreamVolume(float volume); public abstract void onSetStreamVolume(@FloatRange(from = 0.0, to = 1.0) float volume);
/** /**
* Tunes to a given channel. * Tunes to a given channel.

View File

@@ -16,6 +16,7 @@
package android.media.tv; package android.media.tv;
import android.annotation.IntDef;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.os.Bundle; import android.os.Bundle;
import android.os.Parcel; import android.os.Parcel;
@@ -24,12 +25,20 @@ import android.text.TextUtils;
import com.android.internal.util.Preconditions; import com.android.internal.util.Preconditions;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Objects; import java.util.Objects;
/** /**
* Encapsulates the format of tracks played in {@link TvInputService}. * Encapsulates the format of tracks played in {@link TvInputService}.
*/ */
public final class TvTrackInfo implements Parcelable { public final class TvTrackInfo implements Parcelable {
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef({TYPE_AUDIO, TYPE_VIDEO, TYPE_SUBTITLE})
public @interface Type {}
/** /**
* The type value for audio tracks. * The type value for audio tracks.
*/ */
@@ -96,6 +105,7 @@ public final class TvTrackInfo implements Parcelable {
* Returns the type of the track. The type should be one of the followings: * Returns the type of the track. The type should be one of the followings:
* {@link #TYPE_AUDIO}, {@link #TYPE_VIDEO} and {@link #TYPE_SUBTITLE}. * {@link #TYPE_AUDIO}, {@link #TYPE_VIDEO} and {@link #TYPE_SUBTITLE}.
*/ */
@Type
public final int getType() { public final int getType() {
return mType; return mType;
} }
@@ -319,7 +329,7 @@ public final class TvTrackInfo implements Parcelable {
* @throws IllegalArgumentException if the type is not any of {@link #TYPE_AUDIO}, * @throws IllegalArgumentException if the type is not any of {@link #TYPE_AUDIO},
* {@link #TYPE_VIDEO} and {@link #TYPE_SUBTITLE} * {@link #TYPE_VIDEO} and {@link #TYPE_SUBTITLE}
*/ */
public Builder(int type, @NonNull String id) { public Builder(@Type int type, @NonNull String id) {
if (type != TYPE_AUDIO if (type != TYPE_AUDIO
&& type != TYPE_VIDEO && type != TYPE_VIDEO
&& type != TYPE_SUBTITLE) { && type != TYPE_SUBTITLE) {

View File

@@ -16,6 +16,7 @@
package android.media.tv; package android.media.tv;
import android.annotation.FloatRange;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.RequiresPermission; import android.annotation.RequiresPermission;
@@ -271,7 +272,7 @@ public class TvView extends ViewGroup {
* *
* @param volume A volume value between {@code 0.0f} to {@code 1.0f}. * @param volume A volume value between {@code 0.0f} to {@code 1.0f}.
*/ */
public void setStreamVolume(float volume) { public void setStreamVolume(@FloatRange(from = 0.0, to = 1.0) float volume) {
if (DEBUG) Log.d(TAG, "setStreamVolume(" + volume + ")"); if (DEBUG) Log.d(TAG, "setStreamVolume(" + volume + ")");
mStreamVolume = volume; mStreamVolume = volume;
if (mSession == null) { if (mSession == null) {