diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 8ff5856c..62ae5354 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -109,8 +109,6 @@
android:name=".client.ui.setup.capture.CaptureCardsActivity" />
-
-
@@ -118,6 +116,12 @@
+
+
+
+
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ae0abb05..4e3bc2eb 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -202,5 +202,6 @@
Syncing Program Guide
Syncing Recorded Programs
Syncing Upcoming Programs
-
+ Syncing Channels
+
diff --git a/src/org/mythtv/client/ui/AbstractLocationAwareFragmentActivity.java b/src/org/mythtv/client/ui/AbstractLocationAwareFragmentActivity.java
index d987a2d7..261beab7 100644
--- a/src/org/mythtv/client/ui/AbstractLocationAwareFragmentActivity.java
+++ b/src/org/mythtv/client/ui/AbstractLocationAwareFragmentActivity.java
@@ -20,6 +20,7 @@
import java.io.File;
+import org.mythtv.service.channel.ChannelDownloadService;
import org.mythtv.service.guide.ProgramGuideCleanupService;
import org.mythtv.service.guide.ProgramGuideDownloadService;
import org.mythtv.service.util.FileHelper;
@@ -45,6 +46,7 @@ public abstract class AbstractLocationAwareFragmentActivity extends AbstractMyth
private FileHelper mFileHelper;
private RunningServiceHelper mRunningServiceHelper;
+ private ChannelDownloadReceiver channelDownloadReceiver = new ChannelDownloadReceiver();
private ProgramGuideDownloadReceiver programGuideDownloadReceiver = new ProgramGuideDownloadReceiver();
private ProgramGuideCleanupReceiver programGuideCleanupReceiver = new ProgramGuideCleanupReceiver();
@@ -80,7 +82,11 @@ protected void onStart() {
Log.v( TAG, "onStart : enter" );
super.onStart();
- IntentFilter programGuideCleanupFilter = new IntentFilter();
+ IntentFilter channelDownloadFilter = new IntentFilter();
+ channelDownloadFilter.addAction( ChannelDownloadService.ACTION_COMPLETE );
+ registerReceiver( channelDownloadReceiver, channelDownloadFilter );
+
+ IntentFilter programGuideCleanupFilter = new IntentFilter();
programGuideCleanupFilter.addAction( ProgramGuideCleanupService.ACTION_COMPLETE );
registerReceiver( programGuideCleanupReceiver, programGuideCleanupFilter );
@@ -100,6 +106,7 @@ protected void onResume() {
Log.v( TAG, "onResume : enter" );
super.onResume();
+ startService( new Intent( ChannelDownloadService.ACTION_DOWNLOAD ) );
startService( new Intent( ProgramGuideCleanupService.ACTION_CLEANUP ) );
Log.v( TAG, "onResume : exit" );
@@ -114,6 +121,15 @@ protected void onStop() {
super.onStop();
// Unregister for broadcast
+ if( null != channelDownloadReceiver ) {
+ try {
+ unregisterReceiver( channelDownloadReceiver );
+ channelDownloadReceiver = null;
+ } catch( IllegalArgumentException e ) {
+ Log.e( TAG, "onStop : error", e );
+ }
+ }
+
if( null != programGuideCleanupReceiver ) {
try {
unregisterReceiver( programGuideCleanupReceiver );
@@ -158,6 +174,25 @@ public boolean onOptionsItemSelected( MenuItem item ) {
// internal helpers
+ private class ChannelDownloadReceiver extends BroadcastReceiver {
+
+ @Override
+ public void onReceive( Context context, Intent intent ) {
+
+ if ( intent.getAction().equals( ChannelDownloadService.ACTION_PROGRESS ) ) {
+ Log.i( TAG, "ProgramGuideDownloadReceiver.onReceive : progress=" + intent.getStringExtra( ProgramGuideDownloadService.EXTRA_PROGRESS ) );
+ }
+
+ if ( intent.getAction().equals( ChannelDownloadService.ACTION_COMPLETE ) ) {
+ Log.i( TAG, "ProgramGuideDownloadReceiver.onReceive : " + intent.getStringExtra( ProgramGuideDownloadService.EXTRA_COMPLETE ) );
+
+ // Toast.makeText( AbstractLocationAwareFragmentActivity.this, "Channels Loaded!", Toast.LENGTH_SHORT ).show();
+ }
+
+ }
+
+ }
+
private class ProgramGuideDownloadReceiver extends BroadcastReceiver {
@Override
diff --git a/src/org/mythtv/client/ui/dvr/RecordingRuleEditFragment.java b/src/org/mythtv/client/ui/dvr/RecordingRuleEditFragment.java
index f9b12599..c5b36335 100644
--- a/src/org/mythtv/client/ui/dvr/RecordingRuleEditFragment.java
+++ b/src/org/mythtv/client/ui/dvr/RecordingRuleEditFragment.java
@@ -144,11 +144,11 @@ private void setupForm( RecRule rule ) {
// - should we move this to a utility?
// - slow
String channel = "[Any]";
- //Cursor cursor = this.getActivity().getContentResolver().query( ChannelConstants.CONTENT_URI, new String[] { ChannelConstants.FIELD_CHAN_NUM }, ChannelConstants.FIELD_CHAN_ID + " = ?", new String[] { "" + rule.getChanId() }, null );
- //if( cursor.moveToFirst() ) {
- // channel = cursor.getString( cursor.getColumnIndexOrThrow( ChannelConstants.FIELD_CHAN_NUM ) );
- //}
- //cursor.close();
+ Cursor cursor = this.getActivity().getContentResolver().query( ChannelConstants.CONTENT_URI, new String[] { ChannelConstants.FIELD_CHAN_NUM }, ChannelConstants.FIELD_CHAN_ID + " = ?", new String[] { String.valueOf( rule.getChanId() ) }, null );
+ if( cursor.moveToFirst() ) {
+ channel = cursor.getString( cursor.getColumnIndexOrThrow( ChannelConstants.FIELD_CHAN_NUM ) );
+ }
+ cursor.close();
tView = (TextView) getActivity().findViewById( R.id.recording_rule_channel );
tView.setText( channel );
diff --git a/src/org/mythtv/client/ui/dvr/RecordingRuleFragment.java b/src/org/mythtv/client/ui/dvr/RecordingRuleFragment.java
index c1729524..31f14610 100644
--- a/src/org/mythtv/client/ui/dvr/RecordingRuleFragment.java
+++ b/src/org/mythtv/client/ui/dvr/RecordingRuleFragment.java
@@ -154,11 +154,11 @@ private void setup( RecRule rule ) {
// - should we move this to a utility?
// - slow
String channel = "[Any]";
- //Cursor cursor = this.getActivity().getContentResolver().query( ChannelConstants.CONTENT_URI, new String[] { ChannelConstants.FIELD_CHAN_NUM }, ChannelConstants.FIELD_CHAN_ID + " = ?", new String[] { "" + rule.getChanId() }, null );
- //if( cursor.moveToFirst() ) {
- // channel = cursor.getString( cursor.getColumnIndexOrThrow( ChannelConstants.FIELD_CHAN_NUM ) );
- //}
- //cursor.close();
+ Cursor cursor = this.getActivity().getContentResolver().query( ChannelConstants.CONTENT_URI, new String[] { ChannelConstants.FIELD_CHAN_NUM }, ChannelConstants.FIELD_CHAN_ID + " = ?", new String[] { String.valueOf( rule.getChanId() ) }, null );
+ if( cursor.moveToFirst() ) {
+ channel = cursor.getString( cursor.getColumnIndexOrThrow( ChannelConstants.FIELD_CHAN_NUM ) );
+ }
+ cursor.close();
tView = (TextView) getActivity().findViewById( R.id.recording_rule_channel );
tView.setText( channel );
diff --git a/src/org/mythtv/client/ui/dvr/RecordingRulesFragment.java b/src/org/mythtv/client/ui/dvr/RecordingRulesFragment.java
index f33e8970..a06ef81b 100644
--- a/src/org/mythtv/client/ui/dvr/RecordingRulesFragment.java
+++ b/src/org/mythtv/client/ui/dvr/RecordingRulesFragment.java
@@ -264,11 +264,11 @@ public View getView( int position, View convertView, ViewGroup parent ) {
RecRule rule = getItem( position );
String channel = "[Any]";
- //Cursor cursor = mContext.getContentResolver().query( ChannelConstants.CONTENT_URI, new String[] { ChannelConstants.FIELD_CHAN_NUM }, ChannelConstants.FIELD_CHAN_ID + " = ?", new String[] { "" + rule.getChanId() }, null );
- //if( cursor.moveToFirst() ) {
- // channel = cursor.getString( cursor.getColumnIndexOrThrow( ChannelConstants.FIELD_CHAN_NUM ) );
- //}
- //cursor.close();
+ Cursor cursor = mContext.getContentResolver().query( ChannelConstants.CONTENT_URI, new String[] { ChannelConstants.FIELD_CHAN_NUM }, ChannelConstants.FIELD_CHAN_ID + " = ?", new String[] { String.valueOf( rule.getChanId() ) }, null );
+ if( cursor.moveToFirst() ) {
+ channel = cursor.getString( cursor.getColumnIndexOrThrow( ChannelConstants.FIELD_CHAN_NUM ) );
+ }
+ cursor.close();
mHolder.category.setBackgroundColor( mProgramHelper.getCategoryColor( rule.getCategory() ) );
mHolder.title.setText( rule.getTitle() );
diff --git a/src/org/mythtv/db/DatabaseHelper.java b/src/org/mythtv/db/DatabaseHelper.java
index a1deba04..f937915f 100644
--- a/src/org/mythtv/db/DatabaseHelper.java
+++ b/src/org/mythtv/db/DatabaseHelper.java
@@ -44,7 +44,7 @@ public class DatabaseHelper extends SQLiteOpenHelper {
private static final String TAG = DatabaseHelper.class.getSimpleName();
private static final String DATABASE_NAME = "mythtvdb";
- private static final int DATABASE_VERSION = 46;
+ private static final int DATABASE_VERSION = 49;
public DatabaseHelper( Context context ) {
super( context, DATABASE_NAME, null, DATABASE_VERSION );
@@ -66,6 +66,9 @@ public void onCreate( SQLiteDatabase db ) {
dropEtag( db );
createEtag( db );
+ dropChannel( db );
+ createChannel( db );
+
dropProgram( db, ProgramConstants.TABLE_NAME_RECORDED );
createProgram( db, ProgramConstants.TABLE_NAME_RECORDED );
@@ -85,11 +88,14 @@ public void onCreate( SQLiteDatabase db ) {
public void onUpgrade( SQLiteDatabase db, int oldVersion, int newVersion ) {
Log.v( TAG, "onUpgrade : enter" );
- if( oldVersion < 46 ) {
- Log.v( TAG, "onUpgrade : upgrading to db version 46" );
+ if( oldVersion < 49 ) {
+ Log.v( TAG, "onUpgrade : upgrading to db version 49" );
dropEtag( db );
createEtag( db );
+
+ dropChannel( db );
+ createChannel( db );
}
@@ -461,47 +467,47 @@ private void dropRecording( SQLiteDatabase db ) {
Log.v( TAG, "dropRecording : exit" );
}
-// private void createChannel( SQLiteDatabase db ) {
-// Log.v( TAG, "createChannel : enter" );
-//
-// StringBuilder sqlBuilder = new StringBuilder();
-// sqlBuilder.append( "CREATE TABLE " + ChannelConstants.TABLE_NAME + " (" );
-// sqlBuilder.append( _ID ).append( " " ).append( ChannelConstants.FIELD_ID_DATA_TYPE ).append( " " ).append( ChannelConstants.FIELD_ID_PRIMARY_KEY ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_CHAN_ID ).append( " " ).append( ChannelConstants.FIELD_CHAN_ID_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_CHAN_NUM ).append( " " ).append( ChannelConstants.FIELD_CHAN_NUM_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_CALLSIGN ).append( " " ).append( ChannelConstants.FIELD_CALLSIGN_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_ICON_URL ).append( " " ).append( ChannelConstants.FIELD_ICON_URL_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_CHANNEL_NAME ).append( " " ).append( ChannelConstants.FIELD_CHANNEL_NAME_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_MPLEX_ID ).append( " " ).append( ChannelConstants.FIELD_MPLEX_ID_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_TRANSPORT_ID ).append( " " ).append( ChannelConstants.FIELD_TRANSPORT_ID_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_SERVICE_ID ).append( " " ).append( ChannelConstants.FIELD_SERVICE_ID_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_NETWORK_ID ).append( " " ).append( ChannelConstants.FIELD_NETWORK_ID_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_ATSC_MAJOR_CHAN ).append( " " ).append( ChannelConstants.FIELD_ATSC_MAJOR_CHAN_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_ATSC_MINOR_CHAN ).append( " " ).append( ChannelConstants.FIELD_ATSC_MINOR_CHAN_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_FORMAT ).append( " " ).append( ChannelConstants.FIELD_FORMAT_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_MODULATION ).append( " " ).append( ChannelConstants.FIELD_MODULATION_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_FREQUENCY ).append( " " ).append( ChannelConstants.FIELD_FREQUENCY_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_FREQUENCY_ID ).append( " " ).append( ChannelConstants.FIELD_FREQUENCY_ID_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_FREQUENCY_TABLE ).append( " " ).append( ChannelConstants.FIELD_FREQUENCY_TABLE_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_FINE_TUNE ).append( " " ).append( ChannelConstants.FIELD_FINE_TUNE_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_SIS_STANDARD ).append( " " ).append( ChannelConstants.FIELD_SIS_STANDARD_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_CHAN_FILTERS ).append( " " ).append( ChannelConstants.FIELD_CHAN_FILTERS_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_SOURCE_ID ).append( " " ).append( ChannelConstants.FIELD_SOURCE_ID_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_INPUT_ID ).append( " " ).append( ChannelConstants.FIELD_INPUT_ID_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_COMM_FREE ).append( " " ).append( ChannelConstants.FIELD_COMM_FREE_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_USE_EIT ).append( " " ).append( ChannelConstants.FIELD_USE_EIT_DATA_TYPE ).append( " default " ).append( ChannelConstants.FIELD_USE_EIT_DEFAULT ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_VISIBLE ).append( " " ).append( ChannelConstants.FIELD_VISIBLE_DATA_TYPE ).append( " default " ).append( ChannelConstants.FIELD_VISIBLE_DEFAULT ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_XMLTV_ID ).append( " " ).append( ChannelConstants.FIELD_XMLTV_ID_DATA_TYPE ).append( ", " );
-// sqlBuilder.append( ChannelConstants.FIELD_DEFAULT_AUTH ).append( " " ).append( ChannelConstants.FIELD_DEFAULT_AUTH_DATA_TYPE );
-// sqlBuilder.append( ");" );
-// String sql = sqlBuilder.toString();
-// if( Log.isLoggable( TAG, Log.VERBOSE ) ) {
-// Log.v( TAG, "createChannel : sql=" + sql );
-// }
-// db.execSQL( sql );
-//
-// Log.v( TAG, "createChannel : exit" );
-// }
+ private void createChannel( SQLiteDatabase db ) {
+ Log.v( TAG, "createChannel : enter" );
+
+ StringBuilder sqlBuilder = new StringBuilder();
+ sqlBuilder.append( "CREATE TABLE " + ChannelConstants.TABLE_NAME + " (" );
+ sqlBuilder.append( _ID ).append( " " ).append( ChannelConstants.FIELD_ID_DATA_TYPE ).append( " " ).append( ChannelConstants.FIELD_ID_PRIMARY_KEY ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_CHAN_ID ).append( " " ).append( ChannelConstants.FIELD_CHAN_ID_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_CHAN_NUM ).append( " " ).append( ChannelConstants.FIELD_CHAN_NUM_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_CALLSIGN ).append( " " ).append( ChannelConstants.FIELD_CALLSIGN_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_ICON_URL ).append( " " ).append( ChannelConstants.FIELD_ICON_URL_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_CHANNEL_NAME ).append( " " ).append( ChannelConstants.FIELD_CHANNEL_NAME_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_MPLEX_ID ).append( " " ).append( ChannelConstants.FIELD_MPLEX_ID_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_TRANSPORT_ID ).append( " " ).append( ChannelConstants.FIELD_TRANSPORT_ID_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_SERVICE_ID ).append( " " ).append( ChannelConstants.FIELD_SERVICE_ID_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_NETWORK_ID ).append( " " ).append( ChannelConstants.FIELD_NETWORK_ID_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_ATSC_MAJOR_CHAN ).append( " " ).append( ChannelConstants.FIELD_ATSC_MAJOR_CHAN_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_ATSC_MINOR_CHAN ).append( " " ).append( ChannelConstants.FIELD_ATSC_MINOR_CHAN_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_FORMAT ).append( " " ).append( ChannelConstants.FIELD_FORMAT_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_MODULATION ).append( " " ).append( ChannelConstants.FIELD_MODULATION_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_FREQUENCY ).append( " " ).append( ChannelConstants.FIELD_FREQUENCY_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_FREQUENCY_ID ).append( " " ).append( ChannelConstants.FIELD_FREQUENCY_ID_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_FREQUENCY_TABLE ).append( " " ).append( ChannelConstants.FIELD_FREQUENCY_TABLE_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_FINE_TUNE ).append( " " ).append( ChannelConstants.FIELD_FINE_TUNE_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_SIS_STANDARD ).append( " " ).append( ChannelConstants.FIELD_SIS_STANDARD_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_CHAN_FILTERS ).append( " " ).append( ChannelConstants.FIELD_CHAN_FILTERS_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_SOURCE_ID ).append( " " ).append( ChannelConstants.FIELD_SOURCE_ID_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_INPUT_ID ).append( " " ).append( ChannelConstants.FIELD_INPUT_ID_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_COMM_FREE ).append( " " ).append( ChannelConstants.FIELD_COMM_FREE_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_USE_EIT ).append( " " ).append( ChannelConstants.FIELD_USE_EIT_DATA_TYPE ).append( " default " ).append( ChannelConstants.FIELD_USE_EIT_DEFAULT ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_VISIBLE ).append( " " ).append( ChannelConstants.FIELD_VISIBLE_DATA_TYPE ).append( " default " ).append( ChannelConstants.FIELD_VISIBLE_DEFAULT ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_XMLTV_ID ).append( " " ).append( ChannelConstants.FIELD_XMLTV_ID_DATA_TYPE ).append( ", " );
+ sqlBuilder.append( ChannelConstants.FIELD_DEFAULT_AUTH ).append( " " ).append( ChannelConstants.FIELD_DEFAULT_AUTH_DATA_TYPE );
+ sqlBuilder.append( ");" );
+ String sql = sqlBuilder.toString();
+ if( Log.isLoggable( TAG, Log.VERBOSE ) ) {
+ Log.v( TAG, "createChannel : sql=" + sql );
+ }
+ db.execSQL( sql );
+
+ Log.v( TAG, "createChannel : exit" );
+ }
private void dropChannel( SQLiteDatabase db ) {
Log.v( TAG, "dropChannel : enter" );
diff --git a/src/org/mythtv/service/channel/ChannelDownloadService.java b/src/org/mythtv/service/channel/ChannelDownloadService.java
new file mode 100644
index 00000000..bef8acc6
--- /dev/null
+++ b/src/org/mythtv/service/channel/ChannelDownloadService.java
@@ -0,0 +1,354 @@
+/**
+ * This file is part of MythTV Android Frontend
+ *
+ * MythTV Android Frontend is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * MythTV Android Frontend is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with MythTV Android Frontend. If not, see .
+ *
+ * This software can be found at
+ */
+package org.mythtv.service.channel;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.io.FileUtils;
+import org.joda.time.DateTime;
+import org.mythtv.R;
+import org.mythtv.db.channel.ChannelConstants;
+import org.mythtv.db.http.EtagConstants;
+import org.mythtv.service.MythtvService;
+import org.mythtv.services.api.ETagInfo;
+import org.mythtv.services.api.channel.ChannelInfoList;
+import org.mythtv.services.api.channel.ChannelInfos;
+import org.mythtv.services.api.channel.VideoSource;
+import org.mythtv.services.api.channel.VideoSourceList;
+import org.mythtv.services.api.channel.impl.ChannelTemplate.Endpoint;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.ContentUris;
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
+import android.util.Log;
+
+import com.fasterxml.jackson.core.JsonGenerationException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+
+/**
+ * @author Daniel Frey
+ *
+ */
+public class ChannelDownloadService extends MythtvService {
+
+ private static final String TAG = ChannelDownloadService.class.getSimpleName();
+
+ public static final String CHANNELS_FILE = "channels.json";
+ public static final String CALLSIGN_EXT = ".jpg";
+
+ public static final String ACTION_DOWNLOAD = "org.mythtv.background.channelDownload.ACTION_DOWNLOAD";
+ public static final String ACTION_PROGRESS = "org.mythtv.background.channelDownload.ACTION_PROGRESS";
+ public static final String ACTION_COMPLETE = "org.mythtv.background.channelDownload.ACTION_COMPLETE";
+
+ public static final String EXTRA_PROGRESS = "PROGRESS";
+ public static final String EXTRA_PROGRESS_DATA = "PROGRESS_DATA";
+ public static final String EXTRA_PROGRESS_ERROR = "PROGRESS_ERROR";
+ public static final String EXTRA_COMPLETE = "COMPLETE";
+ public static final String EXTRA_COMPLETE_UPTODATE = "COMPLETE_UPTODATE";
+
+ private NotificationManager mNotificationManager;
+ private int notificationId;
+
+ private File channelDirectory = null;
+ private ChannelProcessor mChannelProcessor;
+
+ public ChannelDownloadService() {
+ super( "ChannelDownloadService" );
+ }
+
+ /* (non-Javadoc)
+ * @see android.app.IntentService#onHandleIntent(android.content.Intent)
+ */
+ @Override
+ protected void onHandleIntent( Intent intent ) {
+ Log.d( TAG, "onHandleIntent : enter" );
+ super.onHandleIntent( intent );
+
+ mChannelProcessor = new ChannelProcessor( this );
+
+ channelDirectory = mFileHelper.getChannelDataDirectory();
+ if( null == channelDirectory || !channelDirectory.exists() ) {
+ Intent completeIntent = new Intent( ACTION_COMPLETE );
+ completeIntent.putExtra( EXTRA_COMPLETE, "Channel location can not be found" );
+ sendBroadcast( completeIntent );
+
+ Log.d( TAG, "onHandleIntent : exit, channelDirectory does not exist" );
+ return;
+ }
+
+ if( !isBackendConnected() ) {
+ Intent completeIntent = new Intent( ACTION_COMPLETE );
+ completeIntent.putExtra( EXTRA_COMPLETE, "Master Backend unreachable" );
+ sendBroadcast( completeIntent );
+
+ Log.d( TAG, "onHandleIntent : exit, Master Backend unreachable" );
+ return;
+ }
+
+// Cursor channelCursor = getContentResolver().query( ChannelConstants.CONTENT_URI, null, null, null, null );
+// if( channelCursor.getCount() > 0 ) {
+// Intent completeIntent = new Intent( ACTION_COMPLETE );
+// completeIntent.putExtra( EXTRA_COMPLETE, "channels already loaded" );
+// sendBroadcast( completeIntent );
+//
+// Log.d( TAG, "onHandleIntent : exit, Master Backend unreachable" );
+// return;
+// }
+// channelCursor.close();
+
+ mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE );
+
+ if ( intent.getAction().equals( ACTION_DOWNLOAD ) ) {
+ Log.i( TAG, "onHandleIntent : DOWNLOAD action selected" );
+
+ ChannelInfos channelInfos = null;
+ try {
+ sendNotification();
+
+ Long id = null;
+ ETagInfo etag = ETagInfo.createEmptyETag();
+ Cursor cursor = getContentResolver().query( Uri.withAppendedPath( EtagConstants.CONTENT_URI, "endpoint" ), null, EtagConstants.FIELD_ENDPOINT + " = ?" ,new String[] { Endpoint.GET_VIDEO_SOURCE_LIST.name() }, null );
+ if( cursor.moveToFirst() ) {
+ id = cursor.getLong( cursor.getColumnIndexOrThrow( EtagConstants._ID ) );
+ String value = cursor.getString( cursor.getColumnIndexOrThrow( EtagConstants.FIELD_VALUE ) );
+
+ etag.setETag( value );
+ Log.v( TAG, "download : etag=" + etag.getETag() );
+ }
+ cursor.close();
+ ResponseEntity responseEntity = mMainApplication.getMythServicesApi().channelOperations().getVideoSourceList( etag );
+ if( responseEntity.getStatusCode().equals( HttpStatus.OK ) ) {
+
+ if( null != etag.getETag() ) {
+ ContentValues values = new ContentValues();
+ values.put( EtagConstants.FIELD_ENDPOINT, Endpoint.GET_VIDEO_SOURCE_LIST.name() );
+ values.put( EtagConstants.FIELD_VALUE, etag.getETag() );
+ values.put( EtagConstants.FIELD_DATE, ( new DateTime() ).getMillis() );
+
+ if( null == id ) {
+ Log.v( TAG, "download : adding new etag" );
+
+ getContentResolver().insert( EtagConstants.CONTENT_URI, values );
+ } else {
+ Log.v( TAG, "download : updating existing etag" );
+
+ getContentResolver().update( ContentUris.withAppendedId( EtagConstants.CONTENT_URI, id ), values, null, null );
+ }
+ }
+
+ VideoSourceList videoSourceList = responseEntity.getBody();
+
+ if( null != videoSourceList ) {
+ cleanup();
+
+ for( VideoSource videoSource : videoSourceList.getVideoSources().getVideoSources() ) {
+
+ channelInfos = download( videoSource.getId() );
+ if( null != channelInfos ) {
+
+ process( channelInfos );
+
+ }
+ }
+
+ }
+
+ downloadChannelIcons();
+ }
+ } catch( JsonGenerationException e ) {
+ Log.e( TAG, "onHandleIntent : error generating json", e );
+ } catch( JsonMappingException e ) {
+ Log.e( TAG, "onHandleIntent : error mapping json", e );
+ } catch( IOException e ) {
+ Log.e( TAG, "onHandleIntent : error handling files", e );
+ } finally {
+ completed();
+
+ Intent completeIntent = new Intent( ACTION_COMPLETE );
+ completeIntent.putExtra( EXTRA_COMPLETE, "Channels Download Service Finished" );
+ if( null == channelInfos ) {
+ completeIntent.putExtra( EXTRA_COMPLETE_UPTODATE, Boolean.TRUE );
+ }
+
+ sendBroadcast( completeIntent );
+ }
+
+ }
+
+ Log.d( TAG, "onHandleIntent : exit" );
+ }
+
+ // internal helpers
+
+ private ChannelInfos download( int sourceId ) {
+ Log.v( TAG, "download : enter" );
+
+// Cursor etags = getContentResolver().query( EtagConstants.CONTENT_URI, null, null, null, null );
+// while( etags.moveToNext() ) {
+// Long id = etags.getLong( etags.getColumnIndexOrThrow( EtagConstants._ID ) );
+// String endpoint = etags.getString( etags.getColumnIndexOrThrow( EtagConstants.FIELD_ENDPOINT ) );
+// String value = etags.getString( etags.getColumnIndexOrThrow( EtagConstants.FIELD_VALUE ) );
+//
+// Log.v( TAG, "download : etag=" + id + ", endpoint=" + endpoint + ", value=" + value );
+// }
+// etags.close();
+
+ Long id = null;
+ ETagInfo etag = ETagInfo.createEmptyETag();
+ Cursor cursor = getContentResolver().query( Uri.withAppendedPath( EtagConstants.CONTENT_URI, "endpoint" ), null, EtagConstants.FIELD_ENDPOINT + " = ? and " + EtagConstants.FIELD_DATA_ID + " = ?" ,new String[] { Endpoint.GET_CHANNEL_INFO_LIST.name(), String.valueOf( sourceId ) }, null );
+ if( cursor.moveToFirst() ) {
+ id = cursor.getLong( cursor.getColumnIndexOrThrow( EtagConstants._ID ) );
+ String value = cursor.getString( cursor.getColumnIndexOrThrow( EtagConstants.FIELD_VALUE ) );
+
+ etag.setETag( value );
+ Log.v( TAG, "download : etag=" + etag.getETag() );
+ }
+ cursor.close();
+
+ ResponseEntity responseEntity = mMainApplication.getMythServicesApi().channelOperations().getChannelInfoList( sourceId, 1, -1, etag );
+
+ try {
+
+ if( responseEntity.getStatusCode().equals( HttpStatus.OK ) ) {
+ ChannelInfoList channelInfoList = responseEntity.getBody();
+
+ if( null != etag.getETag() ) {
+ ContentValues values = new ContentValues();
+ values.put( EtagConstants.FIELD_ENDPOINT, Endpoint.GET_CHANNEL_INFO_LIST.name() );
+ values.put( EtagConstants.FIELD_VALUE, etag.getETag() );
+ values.put( EtagConstants.FIELD_DATA_ID, sourceId );
+ values.put( EtagConstants.FIELD_DATE, ( new DateTime() ).getMillis() );
+
+ if( null == id ) {
+ Log.v( TAG, "download : adding new etag" );
+
+ getContentResolver().insert( EtagConstants.CONTENT_URI, values );
+ } else {
+ Log.v( TAG, "download : updating existing etag" );
+
+ getContentResolver().update( ContentUris.withAppendedId( EtagConstants.CONTENT_URI, id ), values, null, null );
+ }
+ }
+
+ Log.v( TAG, "download : exit" );
+ return channelInfoList.getChannelInfos();
+ }
+
+ if( responseEntity.getStatusCode().equals( HttpStatus.NOT_MODIFIED ) ) {
+ Log.i( TAG, "download : " + Endpoint.GET_CHANNEL_INFO_LIST.getEndpoint() + " returned 304 Not Modified" );
+
+ if( null != etag.getETag() ) {
+ ContentValues values = new ContentValues();
+ values.put( EtagConstants.FIELD_ENDPOINT, Endpoint.GET_CHANNEL_INFO_LIST.name() );
+ values.put( EtagConstants.FIELD_VALUE, etag.getETag() );
+ values.put( EtagConstants.FIELD_DATA_ID, sourceId );
+ values.put( EtagConstants.FIELD_DATE, ( new DateTime() ).getMillis() );
+ getContentResolver().update( ContentUris.withAppendedId( EtagConstants.CONTENT_URI, id ), values, null, null );
+ }
+
+ }
+
+ } catch( Exception e ) {
+ Log.e( TAG, "download : error downloading upcoming program list" );
+ }
+
+ Log.v( TAG, "download : exit" );
+ return null;
+ }
+
+ private void cleanup() throws IOException {
+ Log.v( TAG, "cleanup : enter" );
+
+ FileUtils.cleanDirectory( channelDirectory );
+
+ Log.v( TAG, "cleanup : exit" );
+ }
+
+ private void process( ChannelInfos channelInfos ) throws JsonGenerationException, JsonMappingException, IOException {
+ Log.v( TAG, "process : enter" );
+
+ mMainApplication.getObjectMapper().writeValue( new File( channelDirectory, CHANNELS_FILE ), channelInfos );
+
+ int channelsAdded = mChannelProcessor.processChannels( channelInfos );
+ Log.v( TAG, "process : channelsAdded=" + channelsAdded );
+
+ Log.v( TAG, "process : exit" );
+ }
+
+ // internal helpers
+
+ private void downloadChannelIcons() {
+ Log.v( TAG, "downloadChannelIcons : enter" );
+
+ Cursor cursor = getContentResolver().query( ChannelConstants.CONTENT_URI, new String[] { ChannelConstants._ID, ChannelConstants.FIELD_CHAN_ID, ChannelConstants.FIELD_CALLSIGN }, null, null, null );
+ while( cursor.moveToNext() ) {
+ Long id = cursor.getLong( cursor.getColumnIndexOrThrow( ChannelConstants._ID ) );
+ String chanId = cursor.getString( cursor.getColumnIndexOrThrow( ChannelConstants.FIELD_CHAN_ID ) );
+ String callsign = cursor.getString( cursor.getColumnIndexOrThrow( ChannelConstants.FIELD_CALLSIGN ) );
+
+ File icon = new File( channelDirectory, callsign + CALLSIGN_EXT );
+ if( !icon.exists() ) {
+ //Intent downloadBannerIntent = new Intent( BannerDownloadService.ACTION_DOWNLOAD );
+ //downloadBannerIntent.putExtra( BannerDownloadService.BANNER_RECORDED_ID, id );
+ //startService( downloadBannerIntent );
+ }
+
+ }
+ cursor.close();
+
+ Log.v( TAG, "downloadChannelIcons : exit" );
+ }
+
+ @SuppressWarnings( "deprecation" )
+ private void sendNotification() {
+
+ long when = System.currentTimeMillis();
+ notificationId = (int) when;
+
+ Notification mNotification = new Notification( android.R.drawable.stat_notify_sync, getResources().getString( R.string.notification_sync_channels ), when );
+
+ Intent notificationIntent = new Intent();
+ PendingIntent mContentIntent = PendingIntent.getActivity( this, 0, notificationIntent, 0 );
+
+ mNotification.setLatestEventInfo( this, getResources().getString( R.string.app_name ), getResources().getString( R.string.notification_sync_channels ), mContentIntent );
+
+ mNotification.flags = Notification.FLAG_ONGOING_EVENT;
+
+ mNotificationManager.notify( notificationId, mNotification );
+
+ }
+
+ public void completed() {
+
+ if( null != mNotificationManager ) {
+ mNotificationManager.cancel( notificationId );
+ }
+
+ }
+
+}
diff --git a/src/org/mythtv/service/channel/ChannelProcessor.java b/src/org/mythtv/service/channel/ChannelProcessor.java
index 550ed41b..6ae8733f 100644
--- a/src/org/mythtv/service/channel/ChannelProcessor.java
+++ b/src/org/mythtv/service/channel/ChannelProcessor.java
@@ -18,18 +18,13 @@
*/
package org.mythtv.service.channel;
-import java.util.ArrayList;
-import java.util.List;
-
import org.mythtv.db.channel.ChannelConstants;
import org.mythtv.service.AbstractMythtvProcessor;
import org.mythtv.services.api.channel.ChannelInfo;
+import org.mythtv.services.api.channel.ChannelInfos;
-import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
-import android.database.Cursor;
-import android.net.Uri;
import android.util.Log;
/**
@@ -47,123 +42,80 @@ public ChannelProcessor( Context context ) {
Log.v( TAG, "initialize : exit" );
}
- public Long updateChannelContentProvider( ChannelInfo channel ) {
-// Log.v( TAG, "updateChannelContentProvider : enter" );
+ public int processChannels( ChannelInfos channelInfos ) {
+ Log.v( TAG, "processChannels : enter" );
+
+ int result = 0;
- if( null != channel ) {
+ if( null != channelInfos ) {
- if( Log.isLoggable( TAG, Log.VERBOSE ) ) {
- Log.v( TAG, "updateChannelContentProvider : channelInfo=" + channel.toString() );
- }
+ // add delete here
+ int deleted = mContext.getContentResolver().delete( ChannelConstants.CONTENT_URI, null, null );
+ Log.v( TAG, "processChannels : channels deleted=" + deleted );
- ContentValues values = new ContentValues();
- values.put( ChannelConstants.FIELD_CHAN_ID, channel.getChannelId() );
- values.put( ChannelConstants.FIELD_CHAN_NUM, channel.getChannelNumber() );
- values.put( ChannelConstants.FIELD_CALLSIGN, channel.getCallSign() );
- values.put( ChannelConstants.FIELD_ICON_URL, channel.getIconUrl() );
- values.put( ChannelConstants.FIELD_CHANNEL_NAME, channel.getChannelName() );
- values.put( ChannelConstants.FIELD_MPLEX_ID, channel.getMultiplexId() );
- values.put( ChannelConstants.FIELD_TRANSPORT_ID, channel.getTransportId() );
- values.put( ChannelConstants.FIELD_SERVICE_ID, channel.getServiceId() );
- values.put( ChannelConstants.FIELD_NETWORK_ID, channel.getNetworkId() );
- values.put( ChannelConstants.FIELD_ATSC_MAJOR_CHAN, channel.getAtscMajorChannel() );
- values.put( ChannelConstants.FIELD_ATSC_MINOR_CHAN, channel.getAtscMinorChannel() );
- values.put( ChannelConstants.FIELD_FORMAT, channel.getFormat() );
- values.put( ChannelConstants.FIELD_MODULATION, channel.getModulation() );
- values.put( ChannelConstants.FIELD_FREQUENCY, channel.getFrequency() );
- values.put( ChannelConstants.FIELD_FREQUENCY_ID, channel.getFrequencyId() );
- values.put( ChannelConstants.FIELD_FREQUENCY_TABLE, channel.getFrequenceTable() );
- values.put( ChannelConstants.FIELD_FINE_TUNE, channel.getFineTune() );
- values.put( ChannelConstants.FIELD_SIS_STANDARD, channel.getSiStandard() );
- values.put( ChannelConstants.FIELD_CHAN_FILTERS, channel.getChannelFilters() );
- values.put( ChannelConstants.FIELD_SOURCE_ID, channel.getSourceId() );
- values.put( ChannelConstants.FIELD_INPUT_ID, channel.getInputId() );
- values.put( ChannelConstants.FIELD_COMM_FREE, channel.getCommercialFree() );
- values.put( ChannelConstants.FIELD_USE_EIT, channel.isUseEit() );
- values.put( ChannelConstants.FIELD_VISIBLE, channel.isVisable() );
- values.put( ChannelConstants.FIELD_XMLTV_ID, channel.getXmltvId() );
- values.put( ChannelConstants.FIELD_DEFAULT_AUTH, channel.getDefaultAuth() );
+ ContentValues[] contentValuesArray = convertChannelsToContentValuesArray( channelInfos );
+ result = mContext.getContentResolver().bulkInsert( ChannelConstants.CONTENT_URI, contentValuesArray );
+ Log.v( TAG, "processChannels : channels added=" + result );
+ }
+
+ Log.v( TAG, "processChannels : exit" );
+ return result;
+ }
- long id = 0;
- Cursor cursor = mContext.getContentResolver().query( ChannelConstants.CONTENT_URI, null, ChannelConstants.FIELD_CHAN_ID + " = ? and " + ChannelConstants.FIELD_SOURCE_ID + " = ?", new String[] { "" + channel.getChannelId(), "" + channel.getSourceId() }, null );
- if( cursor.moveToFirst() ) {
- id = cursor.getInt( cursor.getColumnIndexOrThrow( ChannelConstants._ID ) );
- } else {
- Uri contentUri = mContext.getContentResolver().insert( ChannelConstants.CONTENT_URI, values );
- id = ContentUris.parseId( contentUri );
+ // internal helpers
+
+ private ContentValues[] convertChannelsToContentValuesArray( final ChannelInfos channelInfos ) {
+
+ if( null != channelInfos ) {
+
+ int i = 0;
+ ContentValues contentValues;
+ ContentValues[] contentValuesArray = new ContentValues[ channelInfos.getChannelInfos().size() ];
+ for( ChannelInfo channelInfo : channelInfos.getChannelInfos() ) {
+
+ contentValues = convertChannelToContentValues( channelInfo );
+ contentValuesArray[ i ] = contentValues;
+
+ i++;
}
- cursor.close();
- return id;
+ return contentValuesArray;
}
- Log.v( TAG, "updateChannelContentProvider : exit, channel info is empty" );
return null;
}
- public Long batchUpdateChannelContentProvider( List channels ) {
-
- long numberInserted = 0;
+ private ContentValues convertChannelToContentValues( ChannelInfo channelInfo ) {
- if( null != channels && !channels.isEmpty() ) {
-
- List lChannels = new ArrayList();
-
- Cursor cursor = mContext.getContentResolver().query( ChannelConstants.CONTENT_URI, new String[] { ChannelConstants._ID }, null, null, null );
- if( cursor.getCount() == 0 ) {
- List filtered = new ArrayList();
- for( ChannelInfo channel : channels ) {
- if( !lChannels.contains( channel.getChannelNumber() ) ) {
- if( channel.isVisable() ) {
- filtered.add( channel );
-
- lChannels.add( channel.getChannelNumber() );
- }
- }
- }
-
- int count = 0;
- ContentValues values;
- ContentValues[] valuesArray = new ContentValues[ filtered.size() ];
- for( ChannelInfo channel : filtered ) {
- values = new ContentValues();
- values.put( ChannelConstants.FIELD_CHAN_ID, null != channel.getChannelId() ? channel.getChannelId() : "" );
- values.put( ChannelConstants.FIELD_CHAN_NUM, channel.getChannelNumber() );
- values.put( ChannelConstants.FIELD_CALLSIGN, channel.getCallSign() );
- values.put( ChannelConstants.FIELD_ICON_URL, channel.getIconUrl() );
- values.put( ChannelConstants.FIELD_CHANNEL_NAME, channel.getChannelName() );
- values.put( ChannelConstants.FIELD_MPLEX_ID, channel.getMultiplexId() );
- values.put( ChannelConstants.FIELD_TRANSPORT_ID, channel.getTransportId() );
- values.put( ChannelConstants.FIELD_SERVICE_ID, channel.getServiceId() );
- values.put( ChannelConstants.FIELD_NETWORK_ID, channel.getNetworkId() );
- values.put( ChannelConstants.FIELD_ATSC_MAJOR_CHAN, channel.getAtscMajorChannel() );
- values.put( ChannelConstants.FIELD_ATSC_MINOR_CHAN, channel.getAtscMinorChannel() );
- values.put( ChannelConstants.FIELD_FORMAT, channel.getFormat() );
- values.put( ChannelConstants.FIELD_MODULATION, channel.getModulation() );
- values.put( ChannelConstants.FIELD_FREQUENCY, channel.getFrequency() );
- values.put( ChannelConstants.FIELD_FREQUENCY_ID, channel.getFrequencyId() );
- values.put( ChannelConstants.FIELD_FREQUENCY_TABLE, channel.getFrequenceTable() );
- values.put( ChannelConstants.FIELD_FINE_TUNE, channel.getFineTune() );
- values.put( ChannelConstants.FIELD_SIS_STANDARD, channel.getSiStandard() );
- values.put( ChannelConstants.FIELD_CHAN_FILTERS, channel.getChannelFilters() );
- values.put( ChannelConstants.FIELD_SOURCE_ID, channel.getSourceId() );
- values.put( ChannelConstants.FIELD_INPUT_ID, channel.getInputId() );
- values.put( ChannelConstants.FIELD_COMM_FREE, channel.getCommercialFree() );
- values.put( ChannelConstants.FIELD_USE_EIT, channel.isUseEit() ? 1 : 0 );
- values.put( ChannelConstants.FIELD_VISIBLE, channel.isVisable() ? 1 : 0 );
- values.put( ChannelConstants.FIELD_XMLTV_ID, channel.getXmltvId() );
- values.put( ChannelConstants.FIELD_DEFAULT_AUTH, channel.getDefaultAuth() );
- valuesArray[ count ] = values;
-
- count++;
-
- }
- numberInserted = mContext.getContentResolver().bulkInsert( ChannelConstants.CONTENT_URI, valuesArray );
- }
- cursor.close();
- }
+ ContentValues values = new ContentValues();
+ values.put( ChannelConstants.FIELD_CHAN_ID, channelInfo.getChannelId() );
+ values.put( ChannelConstants.FIELD_CHAN_NUM, channelInfo.getChannelNumber() );
+ values.put( ChannelConstants.FIELD_CALLSIGN, channelInfo.getCallSign() );
+ values.put( ChannelConstants.FIELD_ICON_URL, channelInfo.getIconUrl() );
+ values.put( ChannelConstants.FIELD_CHANNEL_NAME, channelInfo.getChannelName() );
+ values.put( ChannelConstants.FIELD_MPLEX_ID, channelInfo.getMultiplexId() );
+ values.put( ChannelConstants.FIELD_TRANSPORT_ID, channelInfo.getTransportId() );
+ values.put( ChannelConstants.FIELD_SERVICE_ID, channelInfo.getServiceId() );
+ values.put( ChannelConstants.FIELD_NETWORK_ID, channelInfo.getNetworkId() );
+ values.put( ChannelConstants.FIELD_ATSC_MAJOR_CHAN, channelInfo.getAtscMajorChannel() );
+ values.put( ChannelConstants.FIELD_ATSC_MINOR_CHAN, channelInfo.getAtscMinorChannel() );
+ values.put( ChannelConstants.FIELD_FORMAT, channelInfo.getFormat() );
+ values.put( ChannelConstants.FIELD_MODULATION, channelInfo.getModulation() );
+ values.put( ChannelConstants.FIELD_FREQUENCY, channelInfo.getFrequency() );
+ values.put( ChannelConstants.FIELD_FREQUENCY_ID, channelInfo.getFrequencyId() );
+ values.put( ChannelConstants.FIELD_FREQUENCY_TABLE, channelInfo.getFrequenceTable() );
+ values.put( ChannelConstants.FIELD_FINE_TUNE, channelInfo.getFineTune() );
+ values.put( ChannelConstants.FIELD_SIS_STANDARD, channelInfo.getSiStandard() );
+ values.put( ChannelConstants.FIELD_CHAN_FILTERS, channelInfo.getChannelFilters() );
+ values.put( ChannelConstants.FIELD_SOURCE_ID, channelInfo.getSourceId() );
+ values.put( ChannelConstants.FIELD_INPUT_ID, channelInfo.getInputId() );
+ values.put( ChannelConstants.FIELD_COMM_FREE, channelInfo.getCommercialFree() );
+ values.put( ChannelConstants.FIELD_USE_EIT, ( channelInfo.isUseEit() ? 1 : 0 ) );
+ values.put( ChannelConstants.FIELD_VISIBLE, ( channelInfo.isVisable() ? 1 : 0 ) );
+ values.put( ChannelConstants.FIELD_XMLTV_ID, channelInfo.getXmltvId() );
+ values.put( ChannelConstants.FIELD_DEFAULT_AUTH, channelInfo.getDefaultAuth() );
- return numberInserted;
+ return values;
}
}
diff --git a/src/org/mythtv/service/util/FileHelper.java b/src/org/mythtv/service/util/FileHelper.java
index 86c9ed4e..99287d6c 100644
--- a/src/org/mythtv/service/util/FileHelper.java
+++ b/src/org/mythtv/service/util/FileHelper.java
@@ -32,6 +32,7 @@ public class FileHelper {
// private static final String TAG = FileHelper.class.getSimpleName();
+ private static final String CHANNEL_DATA = "chanel";
private static final String PROGRAM_GUIDE_DATA = "programGuide";
private static final String PROGRAM_DATA = "program";
private static final String PROGRAM_RECORDED_DATA = "recorded";
@@ -45,6 +46,27 @@ public FileHelper( Context context ) {
mContext = context;
}
+ public File getChannelDataDirectory() {
+// Log.v( TAG, "getChannelDataDirectory : enter" );
+
+ File cacheDir = getRootCacheDirectory();
+ if( null != cacheDir && cacheDir.exists() ) {
+
+ File channelDataDirectory = new File( cacheDir, CHANNEL_DATA );
+ channelDataDirectory.mkdir();
+
+ if( channelDataDirectory.exists() ) {
+// Log.v( TAG, "getChannelDataDirectory : exit" );
+
+ return channelDataDirectory;
+ }
+
+ }
+
+// Log.v( TAG, "getChannelDataDirectory : exit, channel data directory doesn't exit" );
+ return null;
+ }
+
public File getProgramGuideDataDirectory() {
// Log.v( TAG, "getProgramGuideDataDirectory : enter" );