diff options
author | shubang <shubang@google.com> | 2019-05-21 15:57:18 -0700 |
---|---|---|
committer | Nick Chalko <nchalko@google.com> | 2019-05-22 09:12:11 -0700 |
commit | 691770383c64a881ac896a1162eed53e65ba46db (patch) | |
tree | 534812296fcc5dd6beb6ebad9e93886f49e13800 /src | |
parent | 22cd5f258d1d37aa196b6e640cdb2d9be7a6a436 (diff) | |
download | TV-691770383c64a881ac896a1162eed53e65ba46db.tar.gz |
Fix NPE at TunableTvView.tuneTo
setFixedSize should be called after TvView.tune() because the new surface view is not created before it's called.
PiperOrigin-RevId: 249343229
Change-Id: I5e7f24048ab71d433ffde40ca701a5876a9b4700
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/tv/ui/TunableTvView.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/com/android/tv/ui/TunableTvView.java b/src/com/android/tv/ui/TunableTvView.java index 5a99b8be..597bd07e 100644 --- a/src/com/android/tv/ui/TunableTvView.java +++ b/src/com/android/tv/ui/TunableTvView.java @@ -661,17 +661,22 @@ public class TunableTvView extends FrameLayout implements StreamInfo, TunableTvV // To reduce the IPCs, unregister the callback here and register it when necessary. mTvView.setTimeShiftPositionCallback(null); setTimeShiftAvailable(false); - if (needSurfaceSizeUpdate && mFixedSurfaceWidth > 0 && mFixedSurfaceHeight > 0) { - // When the input is changed, TvView recreates its SurfaceView internally. - // So we need to call SurfaceHolder.setFixedSize for the new SurfaceView. - getSurfaceView().getHolder().setFixedSize(mFixedSurfaceWidth, mFixedSurfaceHeight); - } mVideoUnavailableReason = TvInputManager.VIDEO_UNAVAILABLE_REASON_TUNING; if (mTvViewSession != null) { mTvViewSession.tune(channel, params, listener); } else { mTvView.tune(mInputInfo.getId(), mCurrentChannel.getUri(), params); } + if (needSurfaceSizeUpdate && mFixedSurfaceWidth > 0 && mFixedSurfaceHeight > 0) { + // When the input is changed, TvView recreates its SurfaceView internally. + // So we need to call SurfaceHolder.setFixedSize for the new SurfaceView. + SurfaceView surfaceView = getSurfaceView(); + if (surfaceView != null) { + surfaceView.getHolder().setFixedSize(mFixedSurfaceWidth, mFixedSurfaceHeight); + } else { + Log.w(TAG, "Failed to set fixed size for surface view: Null surface view"); + } + } updateBlockScreenAndMuting(); if (mOnTuneListener != null) { mOnTuneListener.onStreamInfoChanged(this, true); |