1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.tv.data.epg; 18 19 import android.support.annotation.AnyThread; 20 import android.support.annotation.NonNull; 21 import android.support.annotation.WorkerThread; 22 23 import com.android.tv.data.Channel; 24 import com.android.tv.data.Lineup; 25 import com.android.tv.data.Program; 26 import com.android.tv.dvr.data.SeriesInfo; 27 28 import java.util.List; 29 import java.util.Map; 30 31 /** 32 * An interface used to retrieve the EPG data. This class should be used in worker thread. 33 */ 34 @WorkerThread 35 public interface EpgReader { 36 /** 37 * Checks if the reader is available. 38 */ isAvailable()39 boolean isAvailable(); 40 41 /** 42 * Returns the timestamp of the current EPG. 43 * The format should be YYYYMMDDHHmmSS as a long value. ex) 20160308141500 44 */ getEpgTimestamp()45 long getEpgTimestamp(); 46 47 /** Sets the region code. */ setRegionCode(String regionCode)48 void setRegionCode(String regionCode); 49 50 /** Returns the lineups list. */ getLineups(@onNull String postalCode)51 List<Lineup> getLineups(@NonNull String postalCode); 52 53 /** 54 * Returns the list of channel numbers (unsorted) for the given lineup. The result is used to 55 * choose the most appropriate lineup among others by comparing the channel numbers of the 56 * existing channels on the device. 57 */ getChannelNumbers(@onNull String lineupId)58 List<String> getChannelNumbers(@NonNull String lineupId); 59 60 /** 61 * Returns the list of channels for the given lineup. The returned channels should map into the 62 * existing channels on the device. This method is usually called after selecting the lineup. 63 */ getChannels(@onNull String lineupId)64 List<Channel> getChannels(@NonNull String lineupId); 65 66 /** Pre-loads and caches channels for a given lineup. */ preloadChannels(@onNull String lineupId)67 void preloadChannels(@NonNull String lineupId); 68 69 /** 70 * Clears cached channels for a given lineup. 71 */ 72 @AnyThread clearCachedChannels(@onNull String lineupId)73 void clearCachedChannels(@NonNull String lineupId); 74 75 /** 76 * Returns the programs for the given channel. Must call {@link #getChannels(String)} 77 * beforehand. Note that the {@code Program} doesn't have valid program ID because it's not 78 * retrieved from TvProvider. 79 */ getPrograms(long channelId)80 List<Program> getPrograms(long channelId); 81 82 /** 83 * Returns the programs for the given channels. Note that the {@code Program} doesn't have valid 84 * program ID because it's not retrieved from TvProvider. This method is only used to get 85 * programs for a short duration typically. 86 */ getPrograms(@onNull List<Long> channelIds, long duration)87 Map<Long, List<Program>> getPrograms(@NonNull List<Long> channelIds, long duration); 88 89 /** Returns the series information for the given series ID. */ getSeriesInfo(@onNull String seriesId)90 SeriesInfo getSeriesInfo(@NonNull String seriesId); 91 }