diff options
author | Nick Chalko <nchalko@google.com> | 2019-10-04 10:08:07 -0700 |
---|---|---|
committer | Nick Chalko <nchalko@google.com> | 2019-10-04 19:26:36 +0000 |
commit | 03629f873a11b778455fa5bb4fcb575277009a77 (patch) | |
tree | b172d85d22d687bd2c44cf20883a68687b4c2607 /src | |
parent | e67b599087f04cc309dde3a95dcce5f28d12f556 (diff) | |
download | TV-03629f873a11b778455fa5bb4fcb575277009a77.tar.gz |
Add flag for channels per programs fetch.
Bugs: 142080666
PiperOrigin-RevId: 272900034
Change-Id: Ia8a7cc4b99da404de83bc84f72049bd11f6527f5
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/tv/data/epg/EpgFetcherImpl.java | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/src/com/android/tv/data/epg/EpgFetcherImpl.java b/src/com/android/tv/data/epg/EpgFetcherImpl.java index be530994..27d7f8d5 100644 --- a/src/com/android/tv/data/epg/EpgFetcherImpl.java +++ b/src/com/android/tv/data/epg/EpgFetcherImpl.java @@ -56,6 +56,7 @@ import com.android.tv.data.ChannelLogoFetcher; import com.android.tv.data.Lineup; import com.android.tv.data.api.Channel; import com.android.tv.data.api.Program; +import com.android.tv.data.epg.EpgReader.EpgChannel; import com.android.tv.features.TvFeatures; import com.android.tv.perf.EventNames; import com.android.tv.perf.PerformanceMonitor; @@ -65,6 +66,7 @@ import com.android.tv.util.Utils; import com.google.android.tv.partner.support.EpgInput; import com.google.android.tv.partner.support.EpgInputs; import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; import com.android.tv.common.flags.BackendKnobsFlags; @@ -116,7 +118,6 @@ public class EpgFetcherImpl implements EpgFetcher { private static final int MSG_FINISH_FETCH_DURING_SCAN = 3; private static final int MSG_RETRY_PREPARE_FETCH_DURING_SCAN = 4; - private static final int QUERY_CHANNEL_COUNT = 50; private static final int MINIMUM_CHANNELS_TO_DECIDE_LINEUP = 3; private final Context mContext; @@ -454,16 +455,9 @@ public class EpgFetcherImpl implements EpgFetcher { if (epgChannels.size() == 0) { return; } - Set<EpgReader.EpgChannel> batch = new HashSet<>(QUERY_CHANNEL_COUNT); - for (EpgReader.EpgChannel epgChannel : epgChannels) { - batch.add(epgChannel); - if (batch.size() >= QUERY_CHANNEL_COUNT) { - batchUpdateEpg(mEpgReader.getPrograms(batch, durationSec)); - batch.clear(); - } - } - if (!batch.isEmpty()) { - batchUpdateEpg(mEpgReader.getPrograms(batch, durationSec)); + int batchSize = (int) Math.max(1, mBackendKnobsFlags.epgFetcherChannelsPerProgramFetch()); + for (Iterable<EpgChannel> batch : Iterables.partition(epgChannels, batchSize)) { + batchUpdateEpg(mEpgReader.getPrograms(ImmutableSet.copyOf(batch), durationSec)); } } |