• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 import com.android.tv.data.Lineup;
23 import com.android.tv.data.Program;
24 import com.android.tv.data.api.Channel;
25 import com.android.tv.dvr.data.SeriesInfo;
26 import java.util.Collection;
27 import java.util.List;
28 import java.util.Map;
29 import java.util.Set;
30 
31 /** An interface used to retrieve the EPG data. This class should be used in worker thread. */
32 @WorkerThread
33 public interface EpgReader {
34 
35     /** Value class that holds a EpgChannelId and its corresponding {@link Channel} */
36     // TODO(b/72052568): Get autovalue to work in aosp master
37     abstract class EpgChannel {
createEpgChannel(Channel channel, String epgChannelId)38         public static EpgChannel createEpgChannel(Channel channel, String epgChannelId) {
39             return new AutoValue_EpgReader_EpgChannel(channel, epgChannelId);
40         }
41 
getChannel()42         public abstract Channel getChannel();
43 
getEpgChannelId()44         public abstract String getEpgChannelId();
45     }
46 
47     /** Checks if the reader is available. */
isAvailable()48     boolean isAvailable();
49 
50     /**
51      * Returns the timestamp of the current EPG. The format should be YYYYMMDDHHmmSS as a long
52      * value. ex) 20160308141500
53      */
getEpgTimestamp()54     long getEpgTimestamp();
55 
56     /** Sets the region code. */
setRegionCode(String regionCode)57     void setRegionCode(String regionCode);
58 
59     /** Returns the lineups list. */
getLineups(@onNull String postalCode)60     List<Lineup> getLineups(@NonNull String postalCode);
61 
62     /**
63      * Returns the list of channel numbers (unsorted) for the given lineup. The result is used to
64      * choose the most appropriate lineup among others by comparing the channel numbers of the
65      * existing channels on the device.
66      */
getChannelNumbers(@onNull String lineupId)67     List<String> getChannelNumbers(@NonNull String lineupId);
68 
69     /**
70      * Returns the list of channels for the given lineup. The returned channels should map into the
71      * existing channels on the device. This method is usually called after selecting the lineup.
72      */
getChannels(Set<Channel> inputChannels, @NonNull String lineupId)73     Set<EpgChannel> getChannels(Set<Channel> inputChannels, @NonNull String lineupId);
74 
75     /** Pre-loads and caches channels for a given lineup. */
preloadChannels(@onNull String lineupId)76     void preloadChannels(@NonNull String lineupId);
77 
78     /** Clears cached channels for a given lineup. */
79     @AnyThread
clearCachedChannels(@onNull String lineupId)80     void clearCachedChannels(@NonNull String lineupId);
81 
82     /**
83      * Returns the programs for the given channel. Must call {@link #getChannels(Set, String)}
84      * beforehand. Note that the {@code Program} doesn't have valid program ID because it's not
85      * retrieved from TvProvider.
86      */
getPrograms(EpgChannel epgChannel)87     List<Program> getPrograms(EpgChannel epgChannel);
88 
89     /**
90      * Returns the programs for the given channels. Note that the {@code Program} doesn't have valid
91      * program ID because it's not retrieved from TvProvider. This method is only used to get
92      * programs for a short duration typically.
93      */
getPrograms( @onNull Set<EpgChannel> epgChannels, long duration)94     Map<EpgChannel, Collection<Program>> getPrograms(
95             @NonNull Set<EpgChannel> epgChannels, long duration);
96 
97     /** Returns the series information for the given series ID. */
getSeriesInfo(@onNull String seriesId)98     SeriesInfo getSeriesInfo(@NonNull String seriesId);
99 }
100