summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDongwon Kang <dwkang@google.com>2014-11-18 14:29:50 +0900
committerDongwon Kang <dwkang@google.com>2014-11-18 15:49:08 +0900
commitc918172508e8becdb89fc540bdfd5a9f7d3974e8 (patch)
tree1c40afbfba94e4b966a974b2243cef0f3b5f5ce0
parent4d269ba32037485bfa5ffba4dd23f796cbf10c43 (diff)
downloadframeworks_base-c918172508e8becdb89fc540bdfd5a9f7d3974e8.zip
frameworks_base-c918172508e8becdb89fc540bdfd5a9f7d3974e8.tar.gz
frameworks_base-c918172508e8becdb89fc540bdfd5a9f7d3974e8.tar.bz2
TIF: make the tune request handling more efficient
- Clear the pending tune operations to handle consecutive tune requests efficiently. - Add time out for onTune() to make developers not to handle whole tune process in the onTune() method. Bug: 18179595 Change-Id: I571e55b78d7c4d17c7237c5ce70203941bec2130
-rw-r--r--media/java/android/media/tv/ITvInputSessionWrapper.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/media/java/android/media/tv/ITvInputSessionWrapper.java b/media/java/android/media/tv/ITvInputSessionWrapper.java
index 1ac80c1..da6f3fc 100644
--- a/media/java/android/media/tv/ITvInputSessionWrapper.java
+++ b/media/java/android/media/tv/ITvInputSessionWrapper.java
@@ -42,6 +42,7 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
private static final String TAG = "TvInputSessionWrapper";
private static final int MESSAGE_HANDLING_DURATION_THRESHOLD_MILLIS = 50;
+ private static final int MESSAGE_TUNE_DURATION_THRESHOLD_MILLIS = 1000;
private static final int DO_RELEASE = 1;
private static final int DO_SET_MAIN = 2;
@@ -161,6 +162,11 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
if (duration > MESSAGE_HANDLING_DURATION_THRESHOLD_MILLIS) {
Log.w(TAG, "Handling message (" + msg.what + ") took too long time (duration="
+ duration + "ms)");
+ if (msg.what == DO_TUNE && duration > MESSAGE_TUNE_DURATION_THRESHOLD_MILLIS) {
+ throw new RuntimeException("Too much time to handle tune request. (" + duration
+ + "ms > " + MESSAGE_TUNE_DURATION_THRESHOLD_MILLIS + "ms) "
+ + "Consider handling the tune request in a separate thread.");
+ }
}
}
@@ -193,6 +199,8 @@ public class ITvInputSessionWrapper extends ITvInputSession.Stub implements Hand
@Override
public void tune(Uri channelUri, Bundle params) {
+ // Clear the pending tune requests.
+ mCaller.removeMessages(DO_TUNE);
mCaller.executeOrSendMessage(mCaller.obtainMessageOO(DO_TUNE, channelUri, params));
}