aboutsummaryrefslogtreecommitdiff
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/tv/MainActivity.java15
-rw-r--r--src/com/android/tv/data/ChannelDataManager.java16
-rw-r--r--src/com/android/tv/onboarding/OnboardingActivity.java6
-rw-r--r--src/com/android/tv/onboarding/SetupSourcesFragment.java2
-rw-r--r--src/com/android/tv/util/SetupUtils.java16
5 files changed, 43 insertions, 12 deletions
diff --git a/src/com/android/tv/MainActivity.java b/src/com/android/tv/MainActivity.java
index cea293de..9de94013 100644
--- a/src/com/android/tv/MainActivity.java
+++ b/src/com/android/tv/MainActivity.java
@@ -455,7 +455,7 @@ public class MainActivity extends Activity
public void onLoadFinished() {
Debug.getTimer(Debug.TAG_START_UP_TIMER)
.log("MainActivity.mChannelTunerListener.onLoadFinished");
- mSetupUtils.markNewChannelsBrowsable();
+ mSetupUtils.markNewChannelsBrowsableIfEnabled();
if (mActivityResumed) {
resumeTvIfNeeded();
}
@@ -922,7 +922,7 @@ public class MainActivity extends Activity
}
if (mChannelTuner.areAllChannelsLoaded()) {
- mSetupUtils.markNewChannelsBrowsable();
+ mSetupUtils.markNewChannelsBrowsableIfEnabled();
resumeTvIfNeeded();
}
mOverlayManager.showMenuWithTimeShiftPauseIfNeeded();
@@ -1094,7 +1094,10 @@ public class MainActivity extends Activity
}
if (channelUri == null) {
- mChannelTuner.moveToChannel(mChannelTuner.findNearestBrowsableChannel(0));
+ if (!mChannelTuner.moveToChannel(mChannelTuner.findNearestBrowsableChannel(0))) {
+ Log.w(TAG, "No browsable channel, show setup");
+ showSettingsFragment();
+ }
} else {
if (TvContract.isChannelUriForPassthroughInput(channelUri)) {
ChannelImpl channel = ChannelImpl.createPassthroughChannel(channelUri);
@@ -1103,13 +1106,17 @@ public class MainActivity extends Activity
long channelId = ContentUris.parseId(channelUri);
Channel channel = mChannelDataManager.getChannel(channelId);
if (channel == null || !mChannelTuner.moveToChannel(channel)) {
- mChannelTuner.moveToChannel(mChannelTuner.findNearestBrowsableChannel(0));
Log.w(
TAG,
"The requested channel (id="
+ channelId
+ ") doesn't exist. "
+ "The first channel will be tuned to.");
+ if (!mChannelTuner.moveToChannel(
+ mChannelTuner.findNearestBrowsableChannel(0))) {
+ Log.w(TAG, "No browsable channel, show setup");
+ showSettingsFragment();
+ }
}
}
}
diff --git a/src/com/android/tv/data/ChannelDataManager.java b/src/com/android/tv/data/ChannelDataManager.java
index 67c32309..fb7ab02a 100644
--- a/src/com/android/tv/data/ChannelDataManager.java
+++ b/src/com/android/tv/data/ChannelDataManager.java
@@ -301,6 +301,22 @@ public class ChannelDataManager {
}
/**
+ * Returns the total browsable channel count for a given input.
+ *
+ * @param inputId The ID of the input.
+ */
+ public int getBrowsableChannelCountForInput(String inputId) {
+ int count = 0;
+ for (Channel channel : mData.channels) {
+ if (channel.getInputId().equals(inputId) && channel.isBrowsable()) {
+ count++;
+ }
+ }
+ return count;
+ }
+
+
+ /**
* Checks if the channel exists in DB.
*
* <p>Note that the channels of the removed inputs can not be obtained from {@link #getChannel}.
diff --git a/src/com/android/tv/onboarding/OnboardingActivity.java b/src/com/android/tv/onboarding/OnboardingActivity.java
index 0ce5d931..6eb1a894 100644
--- a/src/com/android/tv/onboarding/OnboardingActivity.java
+++ b/src/com/android/tv/onboarding/OnboardingActivity.java
@@ -66,7 +66,7 @@ public class OnboardingActivity extends SetupActivity {
@Override
public void onLoadFinished() {
mChannelDataManager.removeListener(this);
- mSetupUtils.markNewChannelsBrowsable();
+ mSetupUtils.markNewChannelsBrowsableIfEnabled();
}
@Override
@@ -97,9 +97,9 @@ public class OnboardingActivity extends SetupActivity {
mInputManager = singletons.getTvInputManagerHelper();
if (PermissionUtils.hasAccessAllEpg(this) || PermissionUtils.hasReadTvListings(this)) {
// Make the channels of the new inputs which have been setup outside TV app
- // browsable.
+ // browsable if enabled.
if (mChannelDataManager.isDbLoadFinished()) {
- mSetupUtils.markNewChannelsBrowsable();
+ mSetupUtils.markNewChannelsBrowsableIfEnabled();
} else {
mChannelDataManager.addListener(mChannelListener);
}
diff --git a/src/com/android/tv/onboarding/SetupSourcesFragment.java b/src/com/android/tv/onboarding/SetupSourcesFragment.java
index b97c7801..855fb274 100644
--- a/src/com/android/tv/onboarding/SetupSourcesFragment.java
+++ b/src/com/android/tv/onboarding/SetupSourcesFragment.java
@@ -313,7 +313,7 @@ public class SetupSourcesFragment extends SetupMultiPaneFragment {
TvInputInfo input = mInputs.get(i);
String inputId = input.getId();
String description;
- int channelCount = mChannelDataManager.getChannelCountForInput(inputId);
+ int channelCount = mChannelDataManager.getBrowsableChannelCountForInput(inputId);
if (mSetupUtils.isSetupDone(inputId) || channelCount > 0) {
if (channelCount == 0) {
description = getString(R.string.setup_input_no_channels);
diff --git a/src/com/android/tv/util/SetupUtils.java b/src/com/android/tv/util/SetupUtils.java
index aaee1047..858114d5 100644
--- a/src/com/android/tv/util/SetupUtils.java
+++ b/src/com/android/tv/util/SetupUtils.java
@@ -63,6 +63,8 @@ public class SetupUtils {
// Recognized inputs means that the user already knows the inputs are installed.
private static final String PREF_KEY_RECOGNIZED_INPUTS = "recognized_inputs";
private static final String PREF_KEY_IS_FIRST_TUNE = "is_first_tune";
+ // Whether to mark new channels to browsable.
+ private static final boolean MARK_NEW_CHANNELS_BROWSABLE = false;
private final Context mContext;
private final SharedPreferences mSharedPreferences;
@@ -132,11 +134,11 @@ public class SetupUtils {
boolean browsableChanged = false;
for (Channel channel : manager.getChannelList()) {
if (channel.getInputId().equals(inputId)) {
- if (!channel.isBrowsable()) {
+ if (!channel.isBrowsable() && MARK_NEW_CHANNELS_BROWSABLE) {
manager.updateBrowsable(channel.getId(), true, true);
browsableChanged = true;
}
- if (firstChannelForInput == null) {
+ if (firstChannelForInput == null && channel.isBrowsable()) {
firstChannelForInput = channel;
}
}
@@ -154,9 +156,15 @@ public class SetupUtils {
});
}
- /** Marks the channels in newly installed inputs browsable. */
+ /** Marks the channels in newly installed inputs browsable if enabled. */
@UiThread
- public void markNewChannelsBrowsable() {
+ public void markNewChannelsBrowsableIfEnabled() {
+ // TODO(b/288499376): Handle browsable field for channels added outside Live TV app in a
+ // better way.
+ if (!MARK_NEW_CHANNELS_BROWSABLE) {
+ return;
+ }
+
Set<String> newInputsWithChannels = new HashSet<>();
TvSingletons singletons = TvSingletons.getSingletons(mContext);
TvInputManagerHelper tvInputManagerHelper = singletons.getTvInputManagerHelper();