diff --git a/app/src/androidTest/java/de/test/antennapod/storage/DBReaderTest.java b/app/src/androidTest/java/de/test/antennapod/storage/DBReaderTest.java index 1b77baea0..11a34813a 100644 --- a/app/src/androidTest/java/de/test/antennapod/storage/DBReaderTest.java +++ b/app/src/androidTest/java/de/test/antennapod/storage/DBReaderTest.java @@ -42,38 +42,6 @@ public class DBReaderTest extends InstrumentationTestCase { adapter.close(); } - private void expiredFeedListTestHelper(long lastUpdate, long expirationTime, boolean shouldReturn) { - final Context context = getInstrumentation().getTargetContext(); - Feed feed = new Feed(0, new Date(lastUpdate), "feed", "link", "descr", null, - null, null, null, "feed", null, null, "url", false, new FlattrStatus(), false, null, null, false); - feed.setItems(new ArrayList()); - PodDBAdapter adapter = new PodDBAdapter(context); - adapter.open(); - adapter.setCompleteFeed(feed); - adapter.close(); - - assertTrue(feed.getId() != 0); - List expiredFeeds = DBReader.getExpiredFeedsList(context, expirationTime); - assertNotNull(expiredFeeds); - if (shouldReturn) { - assertTrue(expiredFeeds.size() == 1); - assertTrue(expiredFeeds.get(0).getId() == feed.getId()); - } else { - assertTrue(expiredFeeds.isEmpty()); - } - } - - public void testGetExpiredFeedsListShouldReturnFeed() { - final long expirationTime = 1000 * 60 * 60; // 1 hour - expiredFeedListTestHelper(System.currentTimeMillis() - expirationTime - 1, expirationTime, true); - } - - public void testGetExpiredFeedsListShouldNotReturnFeed() { - final long expirationTime = 1000 * 60 * 60; // 1 hour - expiredFeedListTestHelper(System.currentTimeMillis() - expirationTime / 2, expirationTime, false); - } - - public void testGetFeedList() { final Context context = getInstrumentation().getTargetContext(); List feeds = saveFeedlist(context, 10, 0, false); diff --git a/app/src/androidTest/java/de/test/antennapod/storage/DBTasksTest.java b/app/src/androidTest/java/de/test/antennapod/storage/DBTasksTest.java index ac4a709d7..944fc7792 100644 --- a/app/src/androidTest/java/de/test/antennapod/storage/DBTasksTest.java +++ b/app/src/androidTest/java/de/test/antennapod/storage/DBTasksTest.java @@ -299,37 +299,4 @@ public class DBTasksTest extends InstrumentationTestCase { lastDate = item.getPubDate(); } } - - private void expiredFeedListTestHelper(long lastUpdate, long expirationTime, boolean shouldReturn) { - UserPreferences.setUpdateInterval(TimeUnit.MILLISECONDS.toHours(expirationTime)); - Feed feed = new Feed(0, new Date(lastUpdate), "feed", "link", "descr", null, - null, null, null, "feed", null, null, "url", false, new FlattrStatus(), false, null, null, false); - feed.setItems(new ArrayList()); - PodDBAdapter adapter = new PodDBAdapter(context); - adapter.open(); - adapter.setCompleteFeed(feed); - adapter.close(); - - assertTrue(feed.getId() != 0); - List expiredFeeds = DBTasks.getExpiredFeeds(context); - assertNotNull(expiredFeeds); - if (shouldReturn) { - assertTrue(expiredFeeds.size() == 1); - assertTrue(expiredFeeds.get(0).getId() == feed.getId()); - } else { - assertTrue(expiredFeeds.isEmpty()); - } - } - - @FlakyTest(tolerance = 3) - public void testGetExpiredFeedsTestShouldReturn() { - final long expirationTime = 1000 * 60 * 60; - expiredFeedListTestHelper(System.currentTimeMillis() - expirationTime - 1, expirationTime, true); - } - - @FlakyTest(tolerance = 3) - public void testGetExpiredFeedsTestShouldNotReturn() { - final long expirationTime = 1000 * 60 * 60; - expiredFeedListTestHelper(System.currentTimeMillis() - expirationTime / 2, expirationTime, false); - } } diff --git a/app/src/main/java/de/danoeh/antennapod/receiver/ConnectivityActionReceiver.java b/app/src/main/java/de/danoeh/antennapod/receiver/ConnectivityActionReceiver.java index f55a7603f..a3a200058 100644 --- a/app/src/main/java/de/danoeh/antennapod/receiver/ConnectivityActionReceiver.java +++ b/app/src/main/java/de/danoeh/antennapod/receiver/ConnectivityActionReceiver.java @@ -15,7 +15,7 @@ import de.danoeh.antennapod.core.storage.DownloadRequester; import de.danoeh.antennapod.core.util.NetworkUtils; public class ConnectivityActionReceiver extends BroadcastReceiver { - private static final String TAG = "ConnectivityActionReceiver"; + private static final String TAG = "ConnectivityActionRecvr"; @Override public void onReceive(final Context context, Intent intent) { diff --git a/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java b/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java index d98086003..0045f1eb0 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java +++ b/core/src/main/java/de/danoeh/antennapod/core/receiver/FeedUpdateReceiver.java @@ -20,7 +20,7 @@ public class FeedUpdateReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { Log.d(TAG, "Received intent"); if (NetworkUtils.isDownloadAllowed(context)) { - DBTasks.refreshExpiredFeeds(context); + DBTasks.refreshAllFeeds(context, null); } else { Log.d(TAG, "Blocking automatic update: no wifi available / no mobile updates allowed"); } diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java index 578bce854..3df305027 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java +++ b/core/src/main/java/de/danoeh/antennapod/core/service/download/DownloadService.java @@ -326,6 +326,7 @@ public class DownloadService extends Service { unregisterReceiver(cancelDownloadReceiver); if (!newMediaFiles.isEmpty()) { + Log.d(TAG, "newMediaFiles exist, autodownload them"); DBTasks.autodownloadUndownloadedItems(getApplicationContext(), ArrayUtils.toPrimitive(newMediaFiles.toArray(new Long[newMediaFiles.size()]))); } diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java index 53fd8c24b..cfbfd152b 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java @@ -114,35 +114,6 @@ public final class DBReader { return result; } - /** - * Returns a list of 'expired Feeds', i.e. Feeds that have not been updated for a certain amount of time. - * - * @param context A context that is used for opening a database connection. - * @param expirationTime Time that is used for determining whether a feed is outdated or not. - * A Feed is considered expired if 'lastUpdate < (currentTime - expirationTime)' evaluates to true. - * @return A list of Feeds, sorted alphabetically by their title. A Feed-object - * of the returned list does NOT have its list of FeedItems yet. The FeedItem-list - * can be loaded separately with {@link #getFeedItemList(android.content.Context, de.danoeh.antennapod.core.feed.Feed)}. - */ - public static List getExpiredFeedsList(final Context context, final long expirationTime) { - Log.d(TAG, String.format("getExpiredFeedsList(%d)", expirationTime)); - - PodDBAdapter adapter = new PodDBAdapter(context); - adapter.open(); - - Cursor feedlistCursor = adapter.getExpiredFeedsCursor(expirationTime); - List feeds = new ArrayList(feedlistCursor.getCount()); - - if (feedlistCursor.moveToFirst()) { - do { - Feed feed = extractFeedFromCursorRow(adapter, feedlistCursor); - feeds.add(feed); - } while (feedlistCursor.moveToNext()); - } - feedlistCursor.close(); - return feeds; - } - /** * Takes a list of FeedItems and loads their corresponding Feed-objects from the database. * The feedID-attribute of a FeedItem must be set to the ID of its feed or the method will diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java index a90df433e..b08013c65 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBTasks.java @@ -184,6 +184,7 @@ public final class DBTasks { if (ClientConfig.gpodnetCallbacks.gpodnetEnabled()) { GpodnetSyncService.sendSyncIntent(context); } + Log.d(TAG, "refreshAllFeeds autodownload"); autodownloadUndownloadedItems(context); } }.start(); @@ -192,44 +193,6 @@ public final class DBTasks { } } - /** - * Used by refreshExpiredFeeds to determine which feeds should be refreshed. - * This method will use the value specified in the UserPreferences as the - * expiration time. - * - * @param context Used for DB access. - * @return A list of expired feeds. An empty list will be returned if there - * are no expired feeds. - */ - public static List getExpiredFeeds(final Context context) { - long millis = UserPreferences.getUpdateInterval(); - if (millis > 0) { - List feedList = DBReader.getExpiredFeedsList(context, millis); - if (feedList.size() > 0) { - refreshFeeds(context, feedList); - } - return feedList; - } else { - return new ArrayList(); - } - } - - /** - * Refreshes expired Feeds in the list returned by the getExpiredFeedsList(Context, long) method in DBReader. - * The expiration date parameter is determined by the update interval specified in {@link UserPreferences}. - * - * @param context Used for DB access. - */ - public static void refreshExpiredFeeds(final Context context) { - Log.d(TAG, "Refreshing expired feeds"); - - new Thread() { - public void run() { - refreshFeeds(context, getExpiredFeeds(context)); - } - }.start(); - } - private static void refreshFeeds(final Context context, final List feedList) { @@ -440,6 +403,7 @@ public final class DBTasks { * @return A Future that can be used for waiting for the methods completion. */ public static Future autodownloadUndownloadedItems(final Context context, final long... mediaIds) { + Log.d(TAG, "autodownloadUndownloadedItems"); return autodownloadExec.submit(ClientConfig.dbTasksCallbacks.getAutomaticDownloadAlgorithm() .autoDownloadUndownloadedItems(context, mediaIds)); diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java index 0153cbc8c..d0402710c 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/PodDBAdapter.java @@ -981,13 +981,6 @@ public class PodDBAdapter { return db.query(TABLE_NAME_FEEDS, new String[]{KEY_ID, KEY_DOWNLOAD_URL}, null, null, null, null, null); } - public final Cursor getExpiredFeedsCursor(long expirationTime) { - Cursor c = db.query(TABLE_NAME_FEEDS, FEED_SEL_STD, KEY_LASTUPDATE + " < " + String.valueOf(System.currentTimeMillis() - expirationTime), - null, null, null, - null); - return c; - } - /** * Returns a cursor with all FeedItems of a Feed. Uses FEEDITEM_SEL_FI_SMALL *