summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJi-Hwan Lee <jihwan@google.com>2014-08-18 22:01:55 +0900
committerJi-Hwan Lee <jihwan@google.com>2014-08-19 06:11:04 +0000
commit15c56aac985bc8d75f38fb4ecb92dda12d2ca06c (patch)
treea33c539b8a5bf20bb53cd0ee8b96729da4a09842 /media
parent8809f1e5473db09bc47315a2e423e58ba14fd670 (diff)
downloadframeworks_base-15c56aac985bc8d75f38fb4ecb92dda12d2ca06c.zip
frameworks_base-15c56aac985bc8d75f38fb4ecb92dda12d2ca06c.tar.gz
frameworks_base-15c56aac985bc8d75f38fb4ecb92dda12d2ca06c.tar.bz2
TIF: Call setMain(false) when session is released.
Also, rename setMainTvView() and setMainSession() to setMain(), except ITvInputManager. Change-Id: I586e3fd42720f07a75d6f31b1ee955ce5c29dd68
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/tv/ITvInputSession.aidl2
-rw-r--r--media/java/android/media/tv/ITvInputSessionWrapper.java10
-rw-r--r--media/java/android/media/tv/TvInputManager.java8
-rw-r--r--media/java/android/media/tv/TvInputService.java39
-rw-r--r--media/java/android/media/tv/TvView.java36
5 files changed, 54 insertions, 41 deletions
diff --git a/media/java/android/media/tv/ITvInputSession.aidl b/media/java/android/media/tv/ITvInputSession.aidl
index 99fb911..1aad2fa 100644
--- a/media/java/android/media/tv/ITvInputSession.aidl
+++ b/media/java/android/media/tv/ITvInputSession.aidl
@@ -29,7 +29,7 @@ import android.view.Surface;
oneway interface ITvInputSession {
void release();
- void setMainSession(boolean isMainSession);
+ void setMain(boolean isMain);
void setSurface(in Surface surface);
void dispatchSurfaceChanged(int format, int width, int height);
// TODO: Remove this once it becomes irrelevant for applications to handle audio focus. The plan
diff --git a/media/java/android/media/tv/ITvInputSessionWrapper.java b/media/java/android/media/tv/ITvInputSessionWrapper.java
index 5022cc1..58e46f0 100644
--- a/media/java/android/media/tv/ITvInputSessionWrapper.java
+++ b/media/java/android/media/tv/ITvInputSessionWrapper.java
@@ -42,7 +42,7 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
private static final String TAG = "TvInputSessionWrapper";
private static final int DO_RELEASE = 1;
- private static final int DO_SET_MAIN_SESSION = 2;
+ private static final int DO_SET_MAIN = 2;
private static final int DO_SET_SURFACE = 3;
private static final int DO_DISPATCH_SURFACE_CHANGED = 4;
private static final int DO_SET_STREAM_VOLUME = 5;
@@ -91,8 +91,8 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
}
return;
}
- case DO_SET_MAIN_SESSION: {
- mTvInputSessionImpl.setMainSession((Boolean) msg.obj);
+ case DO_SET_MAIN: {
+ mTvInputSessionImpl.setMain((Boolean) msg.obj);
return;
}
case DO_SET_SURFACE: {
@@ -162,8 +162,8 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
}
@Override
- public void setMainSession(boolean isMain) {
- mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_MAIN_SESSION, isMain));
+ public void setMain(boolean isMain) {
+ mCaller.executeOrSendMessage(mCaller.obtainMessageO(DO_SET_MAIN, isMain));
}
@Override
diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java
index 815ba52..45aa6d6 100644
--- a/media/java/android/media/tv/TvInputManager.java
+++ b/media/java/android/media/tv/TvInputManager.java
@@ -1023,10 +1023,12 @@ public final class TvInputManager {
}
/**
- * Sets this as main session. See {@link TvView#setMainTvView} for about meaning of "main".
- * @hide
+ * Sets this as the main session. The main session is a session whose corresponding TV
+ * input determines the HDMI-CEC active source device.
+ *
+ * @see TvView#setMain
*/
- public void setMainSession() {
+ void setMain() {
if (mToken == null) {
Log.w(TAG, "The session has been already released");
return;
diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java
index f34f695..e3292b6 100644
--- a/media/java/android/media/tv/TvInputService.java
+++ b/media/java/android/media/tv/TvInputService.java
@@ -551,29 +551,30 @@ public abstract class TvInputService extends Service {
public abstract void onRelease();
/**
- * Set the current session as the "main" session. See {@link TvView#setMainTvView} for the
- * meaning of "main".
+ * Sets the current session as the main session. The main session is a session whose
+ * corresponding TV input determines the HDMI-CEC active source device.
* <p>
- * This is primarily for HDMI-CEC active source management. TV input service that manages
- * HDMI-CEC logical device should make sure not only to select the corresponding HDMI
- * logical device as source device on {@code onSetMainSession(true)}, but also to select
- * internal device on {@code onSetMainSession(false)}. Also, if surface is set to non-main
- * session, it needs to select internal device after temporarily selecting corresponding
- * HDMI logical device for set up.
+ * TV input service that manages HDMI-CEC logical device should implement {@link
+ * #onSetMain} to (1) select the corresponding HDMI logical device as the source device
+ * when {@code isMain} is {@code true}, and to (2) select the internal device (= TV itself)
+ * as the source device when {@code isMain} is {@code false} and the session is still main.
+ * Also, if a surface is passed to a non-main session and active source is changed to
+ * initiate the surface, the active source should be returned to the main session.
* </p><p>
- * It is guaranteed that {@code onSetMainSession(true)} for new session is called first,
- * and {@code onSetMainSession(false)} for old session is called afterwards. This allows
- * {@code onSetMainSession(false)} to be no-op when TV input service knows that the next
- * main session corresponds to another HDMI logical device. Practically, this implies that
- * one TV input service should handle all HDMI port and HDMI-CEC logical devices for smooth
- * active source transition.
+ * {@link TvView} guarantees that, when tuning involves a session transition, {@code
+ * onSetMain(true)} for new session is called first, {@code onSetMain(false)} for old
+ * session is called afterwards. This allows {@code onSetMain(false)} to be no-op when TV
+ * input service knows that the next main session corresponds to another HDMI logical
+ * device. Practically, this implies that one TV input service should handle all HDMI port
+ * and HDMI-CEC logical devices for smooth active source transition.
* </p>
*
- * @param isMainSession If true, session is main.
+ * @param isMain If true, session should become main.
+ * @see TvView#setMain
* @hide
*/
@SystemApi
- public void onSetMainSession(boolean isMainSession) {
+ public void onSetMain(boolean isMain) {
}
/**
@@ -841,10 +842,10 @@ public abstract class TvInputService extends Service {
}
/**
- * Calls {@link #onSetMainSession}.
+ * Calls {@link #onSetMain}.
*/
- void setMainSession(boolean isMainSession) {
- onSetMainSession(isMainSession);
+ void setMain(boolean isMain) {
+ onSetMain(isMain);
}
/**
diff --git a/media/java/android/media/tv/TvView.java b/media/java/android/media/tv/TvView.java
index 591f543..445194e 100644
--- a/media/java/android/media/tv/TvView.java
+++ b/media/java/android/media/tv/TvView.java
@@ -116,8 +116,10 @@ public class TvView extends ViewGroup {
private final SurfaceHolder.Callback mSurfaceHolderCallback = new SurfaceHolder.Callback() {
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
- Log.d(TAG, "surfaceChanged(holder=" + holder + ", format=" + format + ", width=" + width
- + ", height=" + height + ")");
+ if (DEBUG) {
+ Log.d(TAG, "surfaceChanged(holder=" + holder + ", format=" + format + ", width="
+ + width + ", height=" + height + ")");
+ }
mSurfaceFormat = format;
mSurfaceWidth = width;
mSurfaceHeight = height;
@@ -188,24 +190,27 @@ public class TvView extends ViewGroup {
}
/**
- * Sets this as main TvView.
+ * Sets this as the main {@link TvView}.
* <p>
- * Main TvView is the TvView which user is watching and interacting mainly. It is used for
- * determining internal behavior of hardware TV input devices. For example, this influences
- * how HDMI-CEC active source will be managed.
+ * The main {@link TvView} is a {@link TvView} whose corresponding TV input determines the
+ * HDMI-CEC active source device. For an HDMI port input, one of source devices that is
+ * connected to that HDMI port becomes the active source. For an HDMI-CEC logical device input,
+ * the corresponding HDMI-CEC logical device becomes the active source. For any non-HDMI input
+ * (including the tuner, composite, S-Video, etc.), the internal device (= TV itself) becomes
+ * the active source.
* </p><p>
- * First tuned TvView becomes main automatically, and keeps to be main until setMainTvView() is
- * called for other TvView. Note that main TvView won't be reset even when current main TvView
- * is removed from view hierarchy.
+ * First tuned {@link TvView} becomes main automatically, and keeps to be main until {@link
+ * #setMain} is called for other {@link TvView}. Note that main {@link TvView} won't be reset
+ * even when current main {@link TvView} is removed from view hierarchy.
* </p>
* @hide
*/
@SystemApi
- public void setMainTvView() {
+ public void setMain() {
synchronized (sMainTvViewLock) {
sMainTvView = this;
if (hasWindowFocus() && mSession != null) {
- mSession.setMainSession();
+ mSession.setMain();
}
}
}
@@ -327,6 +332,7 @@ public class TvView extends ViewGroup {
* This method is primarily used to un-tune the current TvView.
*/
public void reset() {
+ if (DEBUG) Log.d(TAG, "reset()");
if (mSession != null) {
release();
resetSurfaceView();
@@ -538,7 +544,7 @@ public class TvView extends ViewGroup {
// Set main again to regain main session.
synchronized (sMainTvViewLock) {
if (hasFocus && this == sMainTvView && mSession != null) {
- mSession.setMainSession();
+ mSession.setMain();
}
}
}
@@ -596,6 +602,7 @@ public class TvView extends ViewGroup {
mSurfaceView.getHolder().removeCallback(mSurfaceHolderCallback);
removeView(mSurfaceView);
}
+ mSurface = null;
mSurfaceView = new SurfaceView(getContext(), mAttrs, mDefStyleAttr) {
@Override
protected void updateWindow(boolean force, boolean redrawNeeded) {
@@ -821,11 +828,14 @@ public class TvView extends ViewGroup {
}
return;
}
+ if (DEBUG) {
+ Log.d(TAG, "onSessionCreated()");
+ }
mSession = session;
if (session != null) {
synchronized (sMainTvViewLock) {
if (hasWindowFocus() && TvView.this == sMainTvView) {
- mSession.setMainSession();
+ mSession.setMain();
}
}
// mSurface may not be ready yet as soon as starting an application.