diff options
| author | 2014-06-17 14:53:37 +0900 | |
|---|---|---|
| committer | 2014-06-17 15:27:57 +0900 | |
| commit | dc952584e37fca96ad0e02e13b2438038fef6bef (patch) | |
| tree | db60b73a317a806208388b889e5bca7f0d95f25a | |
| parent | 2fc02ba031076414dd569d2044c1923b40e3bad4 (diff) | |
Print a warning message instead of throwing IllegalStateException
In TvInputManager.java, when postSessionReleased() is called but
onSessionReleased() is not called yet, mToken is null, and it's not
an illegal state.
Bug: 15095124
Change-Id: Icd2a84ae350d9979e3cef4dbd3a73699e05e7c2a
| -rw-r--r-- | media/java/android/media/tv/TvInputManager.java | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/media/java/android/media/tv/TvInputManager.java b/media/java/android/media/tv/TvInputManager.java index edfdd60defc6..daa700953466 100644 --- a/media/java/android/media/tv/TvInputManager.java +++ b/media/java/android/media/tv/TvInputManager.java @@ -533,12 +533,11 @@ public final class TvInputManager { /** * Releases this session. - * - * @throws IllegalStateException if the session has been already released. */ public void release() { if (mToken == null) { - throw new IllegalStateException("the session has been already released"); + Log.w(TAG, "The session has been already released"); + return; } try { mService.releaseSession(mToken, mUserId); @@ -553,12 +552,12 @@ public final class TvInputManager { * Sets the {@link android.view.Surface} for this session. * * @param surface A {@link android.view.Surface} used to render video. - * @throws IllegalStateException if the session has been already released. * @hide */ public void setSurface(Surface surface) { if (mToken == null) { - throw new IllegalStateException("the session has been already released"); + Log.w(TAG, "The session has been already released"); + return; } // surface can be null. try { @@ -573,11 +572,11 @@ public final class TvInputManager { * * @param volume A volume value between 0.0f to 1.0f. * @throws IllegalArgumentException if the volume value is out of range. - * @throws IllegalStateException if the session has been already released. */ public void setStreamVolume(float volume) { if (mToken == null) { - throw new IllegalStateException("the session has been already released"); + Log.w(TAG, "The session has been already released"); + return; } try { if (volume < 0.0f || volume > 1.0f) { @@ -594,14 +593,14 @@ public final class TvInputManager { * * @param channelUri The URI of a channel. * @throws IllegalArgumentException if the argument is {@code null}. - * @throws IllegalStateException if the session has been already released. */ public void tune(Uri channelUri) { if (channelUri == null) { throw new IllegalArgumentException("channelUri cannot be null"); } if (mToken == null) { - throw new IllegalStateException("the session has been already released"); + Log.w(TAG, "The session has been already released"); + return; } try { mService.tune(mToken, channelUri, mUserId); @@ -620,8 +619,7 @@ public final class TvInputManager { * @param view A view playing TV. * @param frame A position of the overlay view. * @throws IllegalArgumentException if any of the arguments is {@code null}. - * @throws IllegalStateException if {@code view} is not attached to a window or - * if the session has been already released. + * @throws IllegalStateException if {@code view} is not attached to a window. */ void createOverlayView(View view, Rect frame) { if (view == null) { @@ -634,7 +632,8 @@ public final class TvInputManager { throw new IllegalStateException("view must be attached to a window"); } if (mToken == null) { - throw new IllegalStateException("the session has been already released"); + Log.w(TAG, "The session has been already released"); + return; } try { mService.createOverlayView(mToken, view.getWindowToken(), frame, mUserId); @@ -648,14 +647,14 @@ public final class TvInputManager { * * @param frame A new position of the overlay view. * @throws IllegalArgumentException if the arguments is {@code null}. - * @throws IllegalStateException if the session has been already released. */ void relayoutOverlayView(Rect frame) { if (frame == null) { throw new IllegalArgumentException("frame cannot be null"); } if (mToken == null) { - throw new IllegalStateException("the session has been already released"); + Log.w(TAG, "The session has been already released"); + return; } try { mService.relayoutOverlayView(mToken, frame, mUserId); @@ -666,12 +665,11 @@ public final class TvInputManager { /** * Removes the current overlay view. - * - * @throws IllegalStateException if the session has been already released. */ void removeOverlayView() { if (mToken == null) { - throw new IllegalStateException("the session has been already released"); + Log.w(TAG, "The session has been already released"); + return; } try { mService.removeOverlayView(mToken, mUserId); |