Browse Source

Add a random string to the update download intents to circumvent Android's aggressive caching of urls.

pull/11/head
Eric Kok 12 years ago
parent
commit
aa9565eb7a
  1. 3
      android/src/org/transdroid/gui/TorrentsFragment.java
  2. 7
      android/src/org/transdroid/service/UpdateService.java
  3. 1
      lib/src/org/transdroid/daemon/util/HttpHelper.java

3
android/src/org/transdroid/gui/TorrentsFragment.java

@ -368,7 +368,8 @@ public class TorrentsFragment extends Fragment implements IDaemonCallback, OnTou @@ -368,7 +368,8 @@ public class TorrentsFragment extends Fragment implements IDaemonCallback, OnTou
// Intent should have some Uri data pointing to a single torrent
String data = startIntent.getDataString();
if (data != null && startIntent.getData() != null && startIntent.getData().getScheme() != null) {
if (startIntent.getData().getScheme().equals(HttpHelper.SCHEME_HTTP)) {
if (startIntent.getData().getScheme().equals(HttpHelper.SCHEME_HTTP)
|| startIntent.getData().getScheme().equals(HttpHelper.SCHEME_HTTPS)) {
// From a global intent to add a .torrent file via URL (maybe form the browser)
String title = data.substring(data.lastIndexOf("/"));
if (startIntent.hasExtra(Transdroid.INTENT_TORRENT_TITLE)) {

7
android/src/org/transdroid/service/UpdateService.java

@ -19,6 +19,7 @@ package org.transdroid.service; @@ -19,6 +19,7 @@ package org.transdroid.service;
import java.io.IOException;
import java.io.InputStream;
import java.util.Random;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
@ -58,6 +59,8 @@ public class UpdateService extends IntentService { @@ -58,6 +59,8 @@ public class UpdateService extends IntentService {
private static final String DOWNLOAD_URL_SEARCH = "http://www.transdroid.org/latest-search";
private static final String LOG_NAME = "Update service";
private static NotificationManager notificationManager;
private Random random = new Random();
public UpdateService() {
super(LOG_NAME);
@ -91,7 +94,7 @@ public class UpdateService extends IntentService { @@ -91,7 +94,7 @@ public class UpdateService extends IntentService {
// New version available! Notify the user.
newNotification(getString(R.string.update_app_newversion),
getString(R.string.update_app_newversion), getString(R.string.update_updateto,
app[1].trim()), DOWNLOAD_URL_APP, 0);
app[1].trim()), DOWNLOAD_URL_APP + "?" + Integer.toString(random.nextInt()), 0);
}
} catch (NameNotFoundException e) {
// Not installed... this can never happen since this Service is part of the app itself.
@ -104,7 +107,7 @@ public class UpdateService extends IntentService { @@ -104,7 +107,7 @@ public class UpdateService extends IntentService {
// New version available! Notify the user.
newNotification(getString(R.string.update_search_newversion),
getString(R.string.update_search_newversion), getString(R.string.update_updateto,
search[1].trim()), DOWNLOAD_URL_SEARCH, 0);
search[1].trim()), DOWNLOAD_URL_SEARCH + "?" + Integer.toString(random.nextInt()), 0);
}
} catch (NameNotFoundException e) {
// The search module isn't installed yet at all; ignore and wait for the user to manually

1
lib/src/org/transdroid/daemon/util/HttpHelper.java

@ -61,6 +61,7 @@ public class HttpHelper { @@ -61,6 +61,7 @@ public class HttpHelper {
public static final int DEFAULT_CONNECTION_TIMEOUT = 8000;
public static final String SCHEME_HTTP = "http";
public static final String SCHEME_HTTPS = "https";
public static final String SCHEME_MAGNET = "magnet";
public static final String SCHEME_FILE = "file";

Loading…
Cancel
Save