Java Code Examples for android.media.tv.TvContract#buildChannelUri()
The following examples show how to use
android.media.tv.TvContract#buildChannelUri() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EpgSyncWithAdsJobServiceTest.java From androidtv-sample-inputs with Apache License 2.0 | 7 votes |
@Test public void testOriginalChannelsProgramSync() throws EpgSyncException { // Tests that programs and channels were correctly obtained from the EpgSyncJobService Uri channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(0)); Channel firstChannel = mChannelList.get(0); assertEquals("Test Channel", firstChannel.getDisplayName()); assertNotNull(firstChannel.getInternalProviderData()); assertTrue(firstChannel.getInternalProviderData().isRepeatable()); mProgramList = mSampleJobService.getOriginalProgramsForChannel( channelUri, firstChannel, mStartMs, mEndMs); assertEquals(1, mProgramList.size()); channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(1)); Channel secondChannel = mChannelList.get(1); assertEquals("XML Test Channel", secondChannel.getDisplayName()); assertNotNull(secondChannel.getInternalProviderData()); assertTrue(secondChannel.getInternalProviderData().isRepeatable()); mProgramList = mSampleJobService.getOriginalProgramsForChannel( channelUri, secondChannel, mStartMs, mEndMs); assertEquals(5, mProgramList.size()); }
Example 2
Source File: EpgSyncJobServiceTest.java From xipl with Apache License 2.0 | 6 votes |
@Test public void testChannelsProgramSync() { // Tests that programs and channels were correctly obtained from the EpgSyncJobService Uri channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(0)); Channel firstChannel = mChannelList.get(0); assertEquals("Test Channel", firstChannel.getDisplayName()); assertNotNull(firstChannel.getInternalProviderData()); assertTrue(firstChannel.getInternalProviderData().isRepeatable()); mProgramList = mSampleJobService.getProgramsForChannel(channelUri, firstChannel, mStartMs, mEndMs); assertEquals(1, mProgramList.size()); channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(1)); Channel secondChannel = mChannelList.get(1); assertEquals("XML Test Channel", secondChannel.getDisplayName()); assertNotNull(secondChannel.getInternalProviderData()); assertTrue(secondChannel.getInternalProviderData().isRepeatable()); mProgramList = mSampleJobService.getProgramsForChannel(channelUri, secondChannel, mStartMs, mEndMs); assertEquals(5, mProgramList.size()); }
Example 3
Source File: EpgSyncJobServiceTest.java From xipl with Apache License 2.0 | 5 votes |
@Override public void beforeActivityLaunched() { super.beforeActivityLaunched(); getActivity(); // Delete all channels getActivity().getContentResolver().delete(TvContract.buildChannelsUriForInput( TestTvInputService.INPUT_ID), null, null); mSampleJobService = new TestJobService(); mSampleJobService.mContext = getActivity(); mChannelList = mSampleJobService.getChannels(); ModelUtils.updateChannels(getActivity(), TestTvInputService.INPUT_ID, mChannelList, null); mChannelMap = ModelUtils.buildChannelMap(getActivity().getContentResolver(), TestTvInputService.INPUT_ID); assertNotNull(mChannelMap); assertEquals(2, mChannelMap.size()); // Round start time to the current hour mStartMs = System.currentTimeMillis() - System.currentTimeMillis() % (1000 * 60 * 60); mEndMs = mStartMs + 1000 * 60 * 60 * 24 * 7 * 2; // Two week long sync period assertTrue(mStartMs < mEndMs); Uri channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(0)); Channel firstChannel = mChannelList.get(0); assertEquals("Test Channel", firstChannel.getDisplayName()); assertNotNull(firstChannel.getInternalProviderData()); assertTrue(firstChannel.getInternalProviderData().isRepeatable()); mProgramList = mSampleJobService.getProgramsForChannel(channelUri, firstChannel, mStartMs, mEndMs); }
Example 4
Source File: EpgSyncJobServiceTest.java From xipl with Apache License 2.0 | 5 votes |
@Test public void testEpgSyncTask_GetPrograms() { // For repeating channels, test that the program list will continually repeat for the // desired length of time Uri channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(0)); Channel firstChannel = mChannelList.get(0); TestJobService.TestEpgSyncTask epgSyncTask = mSampleJobService.getDefaultEpgSyncTask(); mProgramList = mSampleJobService.getProgramsForChannel(channelUri, firstChannel, mStartMs, mEndMs); List<Program> continuousProgramsList = epgSyncTask.getPrograms( firstChannel, mProgramList, mStartMs, mEndMs); // There are 336 hours in a two week period, and each program is 15m long assertEquals(336 * 60 / 15, continuousProgramsList.size()); }
Example 5
Source File: EpgSyncWithAdsJobServiceTest.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { super.setUp(); injectInstrumentation(InstrumentationRegistry.getInstrumentation()); getActivity(); // Delete all channels getActivity() .getContentResolver() .delete( TvContract.buildChannelsUriForInput(TestTvInputService.INPUT_ID), null, null); mSampleJobService = new TestJobService(); mSampleJobService.mContext = getActivity(); mChannelList = mSampleJobService.getChannels(); ModelUtils.updateChannels(getActivity(), TestTvInputService.INPUT_ID, mChannelList, null); mChannelMap = ModelUtils.buildChannelMap( getActivity().getContentResolver(), TestTvInputService.INPUT_ID); assertNotNull(mChannelMap); assertEquals(2, mChannelMap.size()); // Round start time to the current hour mStartMs = System.currentTimeMillis() - System.currentTimeMillis() % (1000 * 60 * 60); mEndMs = mStartMs + 1000 * 60 * 60 * 24 * 7 * 2; // Two week long sync period assertTrue(mStartMs < mEndMs); Uri channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(0)); Channel firstChannel = mChannelList.get(0); assertEquals("Test Channel", firstChannel.getDisplayName()); assertNotNull(firstChannel.getInternalProviderData()); assertTrue(firstChannel.getInternalProviderData().isRepeatable()); mProgramList = mSampleJobService.getProgramsForChannel(channelUri, firstChannel, mStartMs, mEndMs); }
Example 6
Source File: EpgSyncWithAdsJobServiceTest.java From androidtv-sample-inputs with Apache License 2.0 | 5 votes |
@Test public void testEpgSyncTask_GetPrograms() throws EpgSyncException { // For repeating channels, test that the program list will continually repeat for the // desired length of time Uri channelUri = TvContract.buildChannelUri(mChannelMap.keyAt(0)); Channel firstChannel = mChannelList.get(0); mProgramList = mSampleJobService.getProgramsForChannel(channelUri, firstChannel, mStartMs, mEndMs); assertEquals(336 * 60 / 15, mProgramList.size()); }
Example 7
Source File: SyncAdapter.java From ChannelSurfer with MIT License | 4 votes |
public void performSync(TvInputProvider provider, String inputId) { Log.d(TAG, "Actually begin the sync"); List<Channel> allChannels = provider.getAllChannels(getContext()); if(allChannels == null) { //You have no channels!! return; } Log.d(TAG, allChannels.toString()); for (int i = 0; i < allChannels.size(); i++) { if (allChannels.get(i).getOriginalNetworkId() == 0) allChannels.get(i).setOriginalNetworkId(i + 1); if (allChannels.get(i).getTransportStreamId() == 0) allChannels.get(i).setTransportStreamId(i + 1); } TvContractUtils.updateChannels(getContext(), inputId, allChannels); LongSparseArray<Channel> channelMap = TvContractUtils.buildChannelMap( mContext.getContentResolver(), inputId, allChannels); if (channelMap == null) { Log.d(TAG, "?"); Handler h = new Handler(Looper.getMainLooper()) { @Override public void handleMessage(Message msg) { super.handleMessage(msg); Toast.makeText(getContext(), "Couldn't find any channels. Uh-oh.", Toast.LENGTH_SHORT).show(); } }; h.sendEmptyMessage(0); //Let's not continue running return; } long startMs = new Date().getTime(); long endMs = startMs + FULL_SYNC_WINDOW_SEC * 1000; Log.d(TAG, "Now start to get programs"); for (int i = 0; i < channelMap.size(); ++i) { Uri channelUri = TvContract.buildChannelUri(channelMap.keyAt(i)); List<Program> programList = provider.getProgramsForChannel(getContext(), channelUri, channelMap.valueAt(i), startMs, endMs); Log.d(TAG, "Okay, we NEED to set the channel id first"); for(Program p: programList) { p.setChannelId(channelMap.keyAt(i)); } Log.d(TAG, "For " + channelMap.valueAt(i).toString()); Log.d(TAG, programList.toString()); updatePrograms(channelUri, programList); //Let's double check programs Uri programEditor = TvContract.buildProgramsUriForChannel(channelUri); } Log.d(TAG, "Sync performed"); }