diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java index 343ffcb8bf114..9bdeb2540e4e2 100644 --- a/media/java/android/media/tv/TvInputService.java +++ b/media/java/android/media/tv/TvInputService.java @@ -736,10 +736,14 @@ public abstract class TvInputService extends Service { } /** - * Sets the relative stream volume of the current TV input session to handle the change of - * audio focus by setting. + * Sets the relative stream volume of the current TV input session. * - * @param volume Volume scale from 0.0 to 1.0. + *
The implementation should honor this request in order to handle audio focus changes or
+ * mute the current session when multiple sessions, possibly from different inputs are
+ * active. If the method has not yet been called, the implementation should assume the
+ * default value of {@code 1.0f}.
+ *
+ * @param volume A volume value between {@code 0.0f} to {@code 1.0f}.
*/
public abstract void onSetStreamVolume(float volume);
diff --git a/media/java/android/media/tv/TvView.java b/media/java/android/media/tv/TvView.java
index 024ffd19b0da4..9451f69aa49ca 100644
--- a/media/java/android/media/tv/TvView.java
+++ b/media/java/android/media/tv/TvView.java
@@ -66,10 +66,6 @@ public class TvView extends ViewGroup {
private static final int ZORDER_MEDIA_OVERLAY = 1;
private static final int ZORDER_ON_TOP = 2;
- private static final int CAPTION_DEFAULT = 0;
- private static final int CAPTION_ENABLED = 1;
- private static final int CAPTION_DISABLED = 2;
-
private static final WeakReference This method is primarily used to handle audio focus changes or mute a specific TvView when
+ * multiple views are displayed. If the method has not yet been called, the TvView assumes the
+ * default value of {@code 1.0f}.
+ *
+ * @param volume A volume value between {@code 0.0f} to {@code 1.0f}.
*/
public void setStreamVolume(float volume) {
if (DEBUG) Log.d(TAG, "setStreamVolume(" + volume + ")");
- mHasStreamVolume = true;
mStreamVolume = volume;
if (mSession == null) {
// Volume will be set once the connection has been made.
@@ -367,7 +365,8 @@ public class TvView extends ViewGroup {
* @param enabled {@code true} to enable, {@code false} to disable.
*/
public void setCaptionEnabled(boolean enabled) {
- mCaptionEnabled = enabled ? CAPTION_ENABLED : CAPTION_DISABLED;
+ if (DEBUG) Log.d(TAG, "setCaptionEnabled(" + enabled + ")");
+ mCaptionEnabled = enabled;
if (mSession != null) {
mSession.setCaptionEnabled(enabled);
}
@@ -1018,13 +1017,13 @@ public class TvView extends ViewGroup {
}
}
createSessionOverlayView();
- if (mCaptionEnabled != CAPTION_DEFAULT) {
- mSession.setCaptionEnabled(mCaptionEnabled == CAPTION_ENABLED);
- }
- mSession.tune(mChannelUri, mTuneParams);
- if (mHasStreamVolume) {
+ if (mStreamVolume != null) {
mSession.setStreamVolume(mStreamVolume);
}
+ if (mCaptionEnabled != null) {
+ mSession.setCaptionEnabled(mCaptionEnabled);
+ }
+ mSession.tune(mChannelUri, mTuneParams);
if (mAppPrivateCommandAction != null) {
mSession.sendAppPrivateCommand(
mAppPrivateCommandAction, mAppPrivateCommandData);