From bb3e2674b5ad095d9c1e5e6069cd6b8ee1c1c11e Mon Sep 17 00:00:00 2001 From: Dongwon Kang Date: Tue, 2 Jun 2015 15:05:33 +0900 Subject: [PATCH] TIF: Add sanitization code for the current position + More documentation on the currnet position Bug: 21573422 Change-Id: I51d184d03a61270d3ea36b36f880f1f052a99cd1 --- media/java/android/media/tv/TvInputService.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/media/java/android/media/tv/TvInputService.java b/media/java/android/media/tv/TvInputService.java index 4b84090861cdf..d4806963fffd3 100644 --- a/media/java/android/media/tv/TvInputService.java +++ b/media/java/android/media/tv/TvInputService.java @@ -933,6 +933,10 @@ public abstract class TvInputService extends Service { * Returns {@link TvInputManager#TIME_SHIFT_INVALID_TIME} if the position is unknown at the * moment. * + *

Note that the current playback position should be equal to or greater than the start + * playback position reported by {@link #onTimeShiftGetStartPosition}. Failure to notifying + * the correct current position might lead to bad user experience. + * * @see #onTimeShiftResume * @see #onTimeShiftPause * @see #onTimeShiftSeekTo @@ -1396,6 +1400,12 @@ public abstract class TvInputService extends Service { notifyTimeShiftStartPositionChanged(startPositionMs); } long currentPositionMs = onTimeShiftGetCurrentPosition(); + if (currentPositionMs < mStartPositionMs) { + Log.w(TAG, "Current position (" + currentPositionMs + ") cannot be earlier than" + + " start position (" + mStartPositionMs + "). Reset to the start " + + "position."); + currentPositionMs = mStartPositionMs; + } if (mCurrentPositionMs != currentPositionMs) { mCurrentPositionMs = currentPositionMs; notifyTimeShiftCurrentPositionChanged(currentPositionMs);