aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Gates <lucasgates@google.com>2022-08-03 21:53:27 +0000
committerLucas Gates <lucasgates@google.com>2022-08-15 10:42:32 +0000
commit607799d39fa5a596884fed5e6c70a3f9abbb8cfa (patch)
tree12d9359865357214f51c97d22288809021e11714
parent2b7cf6ecffceee455295a359bc78cf3a62219545 (diff)
downloadTV-607799d39fa5a596884fed5e6c70a3f9abbb8cfa.tar.gz
LiveTv TIAS Integration ViewCallback data requests
The TvInteractiveAppView.TvInteractiveAppCallback contains many methods which act as requests for data from the application which the TIAS is currently running on top of. This CL implements these callback methods for the LiveTv MainActivity. Bug: 241110408 Test: Manually with Cuttlefish and SampleTIAS Change-Id: I46406c961206407ed49d006dca5bcdefcfe55419
-rw-r--r--src/com/android/tv/data/StreamInfo.java2
-rw-r--r--src/com/android/tv/interactive/IAppManager.java74
-rw-r--r--src/com/android/tv/ui/TunableTvView.java7
3 files changed, 78 insertions, 5 deletions
diff --git a/src/com/android/tv/data/StreamInfo.java b/src/com/android/tv/data/StreamInfo.java
index e4237bf4..f323423c 100644
--- a/src/com/android/tv/data/StreamInfo.java
+++ b/src/com/android/tv/data/StreamInfo.java
@@ -44,6 +44,8 @@ public interface StreamInfo {
int getAudioChannelCount();
+ float getStreamVolume();
+
boolean hasClosedCaption();
boolean isVideoAvailable();
diff --git a/src/com/android/tv/interactive/IAppManager.java b/src/com/android/tv/interactive/IAppManager.java
index 7d8069c5..9d78515c 100644
--- a/src/com/android/tv/interactive/IAppManager.java
+++ b/src/com/android/tv/interactive/IAppManager.java
@@ -18,6 +18,7 @@ package com.android.tv.interactive;
import android.annotation.TargetApi;
import android.graphics.Rect;
+import android.media.tv.TvTrackInfo;
import android.media.tv.interactive.TvInteractiveAppManager;
import android.media.tv.AitInfo;
import android.media.tv.interactive.TvInteractiveAppServiceInfo;
@@ -31,9 +32,11 @@ import android.view.View;
import com.android.tv.MainActivity;
import com.android.tv.R;
import com.android.tv.common.SoftPreconditions;
+import com.android.tv.data.api.Channel;
import com.android.tv.features.TvFeatures;
import com.android.tv.ui.TunableTvView;
+import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -175,19 +178,80 @@ public class IAppManager {
public void onSetVideoBounds(String iAppServiceId, Rect rect) {}
@Override
- public void onRequestCurrentChannelUri(String iAppServiceId) {}
+ public void onRequestCurrentChannelUri(String iAppServiceId) {
+ if (mTvIAppView == null) {
+ return;
+ }
+ Channel currentChannel = mMainActivity.getCurrentChannel();
+ Uri currentUri = (currentChannel == null)
+ ? null
+ : currentChannel.getUri();
+ mTvIAppView.sendCurrentChannelUri(currentUri);
+ }
@Override
- public void onRequestCurrentChannelLcn(String iAppServiceId) {}
+ public void onRequestCurrentChannelLcn(String iAppServiceId) {
+ if (mTvIAppView == null) {
+ return;
+ }
+ Channel currentChannel = mMainActivity.getCurrentChannel();
+ if (currentChannel == null || currentChannel.getDisplayNumber() == null) {
+ return;
+ }
+ // Expected format is major channel number, delimiter, minor channel number
+ String displayNumber = currentChannel.getDisplayNumber();
+ String format = "[0-9]+" + Channel.CHANNEL_NUMBER_DELIMITER + "[0-9]+";
+ if (!displayNumber.matches(format)) {
+ return;
+ }
+ // Major channel number is returned
+ String[] numbers = displayNumber.split(
+ String.valueOf(Channel.CHANNEL_NUMBER_DELIMITER));
+ mTvIAppView.sendCurrentChannelLcn(Integer.parseInt(numbers[0]));
+ }
@Override
- public void onRequestStreamVolume(String iAppServiceId) {}
+ public void onRequestStreamVolume(String iAppServiceId) {
+ if (mTvIAppView == null || mTvView == null) {
+ return;
+ }
+ mTvIAppView.sendStreamVolume(mTvView.getStreamVolume());
+ }
@Override
- public void onRequestTrackInfoList(String iAppServiceId) {}
+ public void onRequestTrackInfoList(String iAppServiceId) {
+ if (mTvIAppView == null || mTvView == null) {
+ return;
+ }
+ List<TvTrackInfo> allTracks = new ArrayList<>();
+ int[] trackTypes = new int[] {TvTrackInfo.TYPE_AUDIO,
+ TvTrackInfo.TYPE_VIDEO, TvTrackInfo.TYPE_SUBTITLE};
+
+ for (int trackType : trackTypes) {
+ List<TvTrackInfo> currentTracks = mTvView.getTracks(trackType);
+ if (currentTracks == null) {
+ continue;
+ }
+ for (TvTrackInfo track : currentTracks) {
+ if (track != null) {
+ allTracks.add(track);
+ }
+ }
+ }
+ mTvIAppView.sendTrackInfoList(allTracks);
+ }
@Override
- public void onRequestCurrentTvInputId(String iAppServiceId) {}
+ public void onRequestCurrentTvInputId(String iAppServiceId) {
+ if (mTvIAppView == null) {
+ return;
+ }
+ Channel currentChannel = mMainActivity.getCurrentChannel();
+ String currentInputId = (currentChannel == null)
+ ? null
+ : currentChannel.getInputId();
+ mTvIAppView.sendCurrentTvInputId(currentInputId);
+ }
@Override
public void onRequestSigning(String iAppServiceId, String signingId, String algorithm,
diff --git a/src/com/android/tv/ui/TunableTvView.java b/src/com/android/tv/ui/TunableTvView.java
index d402b205..0ccaad3a 100644
--- a/src/com/android/tv/ui/TunableTvView.java
+++ b/src/com/android/tv/ui/TunableTvView.java
@@ -736,6 +736,13 @@ public class TunableTvView extends FrameLayout implements StreamInfo, TunableTvV
}
}
+ @Override
+ public float getStreamVolume() {
+ return mIsMuted
+ ? 0
+ : mVolume;
+ }
+
/**
* Sets fixed size for the internal {@link android.view.Surface} of {@link
* android.media.tv.TvView}. If either {@code width} or {@code height} is non positive, the