From 0550a7221be0581b0bd421a9d70400ff8699a6e7 Mon Sep 17 00:00:00 2001 From: Nick Chalko Date: Tue, 9 May 2017 14:07:44 -0700 Subject: Sync to ub-tv-dev at lost+ hash 550cbec17259717c5453f6be1eb05736ba10ef1d Bug: 37849928 Test: tested on vendor branch Change-Id: I82190481d2bcef2b89e78414b6b92ed97720749d Merged-In: I4199ec04cacb4a78be58b85302a39d917658dc28 --- src/com/android/tv/InputSessionManager.java | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'src/com/android/tv/InputSessionManager.java') diff --git a/src/com/android/tv/InputSessionManager.java b/src/com/android/tv/InputSessionManager.java index e4b0f456..faf76555 100644 --- a/src/com/android/tv/InputSessionManager.java +++ b/src/com/android/tv/InputSessionManager.java @@ -37,7 +37,6 @@ import android.text.TextUtils; import android.util.ArraySet; import android.util.Log; -import com.android.tv.common.SoftPreconditions; import com.android.tv.data.Channel; import com.android.tv.ui.TunableTvView; import com.android.tv.ui.TunableTvView.OnTuneListener; @@ -73,6 +72,8 @@ public class InputSessionManager { Collections.synchronizedSet(new ArraySet<>()); private final Set mOnTvViewChannelChangeListeners = new ArraySet<>(); + private final Set mOnRecordingSessionChangeListeners = + new ArraySet<>(); public InputSessionManager(Context context) { mContext = context.getApplicationContext(); @@ -113,6 +114,9 @@ public class InputSessionManager { RecordingSession session = new RecordingSession(inputId, tag, callback, handler, endTimeMs); mRecordingSessions.add(session); if (DEBUG) Log.d(TAG, "Recording session created: " + session); + for (OnRecordingSessionChangeListener listener : mOnRecordingSessionChangeListeners) { + listener.onRecordingSessionChange(true, mRecordingSessions.size()); + } return session; } @@ -123,6 +127,9 @@ public class InputSessionManager { mRecordingSessions.remove(session); session.release(); if (DEBUG) Log.d(TAG, "Recording session released: " + session); + for (OnRecordingSessionChangeListener listener : mOnRecordingSessionChangeListeners) { + listener.onRecordingSessionChange(false, mRecordingSessions.size()); + } } /** @@ -148,9 +155,17 @@ public class InputSessionManager { } } - /** - * Returns the current {@link TvView} channel. - */ + /** Adds the {@link OnRecordingSessionChangeListener}. */ + public void addOnRecordingSessionChangeListener(OnRecordingSessionChangeListener listener) { + mOnRecordingSessionChangeListeners.add(listener); + } + + /** Removes the {@link OnRecordingSessionChangeListener}. */ + public void removeRecordingSessionChangeListener(OnRecordingSessionChangeListener listener) { + mOnRecordingSessionChangeListeners.remove(listener); + } + + /** Returns the current {@link TvView} channel. */ @MainThread public Uri getCurrentTvViewChannelUri() { for (TvViewSession session : mTvViewSessions) { @@ -546,4 +561,9 @@ public class InputSessionManager { public interface OnTvViewChannelChangeListener { void onTvViewChannelChange(@Nullable Uri channelUri); } + + /** Called when recording session is created or destroyed. */ + public interface OnRecordingSessionChangeListener { + void onRecordingSessionChange(boolean create, int count); + } } -- cgit v1.2.3