aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tv/InputSessionManager.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/tv/InputSessionManager.java')
-rw-r--r--src/com/android/tv/InputSessionManager.java30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/com/android/tv/InputSessionManager.java b/src/com/android/tv/InputSessionManager.java
index e4b0f456..2978f409 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<OnTvViewChannelChangeListener> mOnTvViewChannelChangeListeners =
new ArraySet<>();
+ private final Set<OnRecordingSessionChangeListener> 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) {
@@ -249,7 +264,7 @@ public class InputSessionManager {
mTvView.setCallback(new DelegateTvInputCallback(mCallback) {
@Override
public void onConnectionFailed(String inputId) {
- if (DEBUG) Log.d(TAG, "TvViewSession: commection failed");
+ if (DEBUG) Log.d(TAG, "TvViewSession: connection failed");
mTuned = false;
mNeedToBeRetuned = false;
super.onConnectionFailed(inputId);
@@ -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);
+ }
}