diff options
author | Jae Seo <jaeseo@google.com> | 2015-04-21 22:36:28 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-04-21 22:36:29 +0000 |
commit | 03b5bf53a3b8f55ff44cd024e363e74ee7d5e5af (patch) | |
tree | 9552d9094c8bf6f8f5f9b0d4d67b2461debda1b9 /media | |
parent | 57c78290e4ba0ebd1fdb01c19db42a7c42e7664e (diff) | |
parent | 1da8fb39499e8f5a962f7307fefdfd2ab6b79224 (diff) | |
download | frameworks_base-03b5bf53a3b8f55ff44cd024e363e74ee7d5e5af.zip frameworks_base-03b5bf53a3b8f55ff44cd024e363e74ee7d5e5af.tar.gz frameworks_base-03b5bf53a3b8f55ff44cd024e363e74ee7d5e5af.tar.bz2 |
Merge "TIF: Cache the stream volume on TvView"
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/tv/TvInputService.java | 10 | ||||
-rw-r--r-- | media/java/android/media/tv/TvView.java | 31 |
2 files changed, 22 insertions, 19 deletions
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java index 343ffcb..9bdeb25 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. + * <p>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 024ffd1..9451f69 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<TvView> NULL_TV_VIEW = new WeakReference<>(null); private static final Object sMainTvViewLock = new Object(); @@ -85,9 +81,8 @@ public class TvView extends ViewGroup { private MySessionCallback mSessionCallback; private TvInputCallback mCallback; private OnUnhandledInputEventListener mOnUnhandledInputEventListener; - private boolean mHasStreamVolume; - private float mStreamVolume; - private int mCaptionEnabled; + private Float mStreamVolume; + private Boolean mCaptionEnabled; private String mAppPrivateCommandAction; private Bundle mAppPrivateCommandData; @@ -253,13 +248,16 @@ public class TvView extends ViewGroup { } /** - * Sets the relative stream volume of this session to handle a change of audio focus. + * Sets the relative stream volume of this TvView. + * + * <p>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 0.0f to 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); |