diff --git a/.idea/misc.xml b/.idea/misc.xml index 1c9e3220..6832b13e 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,7 @@ - + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index d5d07cad..126ee7de 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -23,7 +23,17 @@ - + + + + + + + + + + + - - + + - + - - + + - - - - - - - - - - - - + - - + + - + @@ -127,61 +126,64 @@ - + - - + + - + - - + + - + - - + + - + + + + + + + + + + - - + - - + + - + - - + + - - - - - - - + + @@ -194,14 +196,22 @@ - + + @@ -209,30 +219,30 @@ @@ -260,6 +270,8 @@ + + @@ -318,38 +330,52 @@ - - - + + - - - - - + + + + - - - - + + + + + + + - - + + + + + + + + + + + + + + + @@ -506,38 +532,43 @@ 1370584979416 1370584979416 + + 1370596209522 + 1370596209522 + + - - + + - - - - - - + + + + - - - - - - + + + + + + - - - - - - - - + + + + + + + + + + @@ -582,7 +613,7 @@ - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - diff --git a/AndroidManifest.xml b/AndroidManifest.xml index e4c45f96..2d0152c4 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -2,8 +2,8 @@ + a:versionCode="31" + a:versionName="1.2.0.4" > diff --git a/src/com/thejoshwa/ultrasonic/androidapp/service/RESTMusicService.java b/src/com/thejoshwa/ultrasonic/androidapp/service/RESTMusicService.java index 36dcfa13..0e3f4a22 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/service/RESTMusicService.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/service/RESTMusicService.java @@ -968,16 +968,23 @@ public class RESTMusicService implements MusicService { // received intact. Remember, HTTP POST requests are converted to GET // requests during HTTP redirects, thus // loosing its entity. - if (parameterNames != null && parameterNames.size() < 10) { - StringBuilder builder = new StringBuilder(url); - for (int i = 0; i < parameterNames.size(); i++) { - builder.append("&").append(parameterNames.get(i)).append("="); - builder.append(URLEncoder.encode(String.valueOf(parameterValues.get(i)), "UTF-8")); - } - url = builder.toString(); - parameterNames = null; - parameterValues = null; - } + + if (parameterNames != null) { + int parameters = parameterNames.size(); + + if (parameters < 10) { + StringBuilder builder = new StringBuilder(url); + + for (int i = 0; i < parameters; i++) { + builder.append("&").append(parameterNames.get(i)).append("="); + builder.append(URLEncoder.encode(String.valueOf(parameterValues.get(i)), "UTF-8")); + } + + url = builder.toString(); + parameterNames = null; + parameterValues = null; + } + } String rewrittenUrl = rewriteUrlWithRedirect(context, url); return executeWithRetry(context, rewrittenUrl, url, requestParams, parameterNames, parameterValues, headers, progressListener, task); @@ -986,15 +993,14 @@ public class RESTMusicService implements MusicService { private HttpResponse executeWithRetry(Context context, String url, String originalUrl, HttpParams requestParams, List parameterNames, List parameterValues, List
headers, ProgressListener progressListener, CancellableTask task) throws IOException { Log.i(TAG, "Using URL " + url); - SharedPreferences prefs = Util.getPreferences(context); int networkTimeout = Util.getNetworkTimeout(context); HttpParams newParams = httpClient.getParams(); HttpConnectionParams.setSoTimeout(newParams, networkTimeout); httpClient.setParams(newParams); - final AtomicReference cancelled = new AtomicReference(false); int attempts = 0; - while (true) { + + while (true) { attempts++; HttpContext httpContext = new BasicHttpContext(); final HttpPost request = new HttpPost(url); @@ -1020,9 +1026,11 @@ public class RESTMusicService implements MusicService { if (parameterNames != null) { List params = new ArrayList(); - for (int i = 0; i < parameterNames.size(); i++) { + + for (int i = 0; i < parameterNames.size(); i++) { params.add(new BasicNameValuePair(parameterNames.get(i), String.valueOf(parameterValues.get(i)))); } + request.setEntity(new UrlEncodedFormEntity(params, Constants.UTF_8)); } @@ -1038,11 +1046,11 @@ public class RESTMusicService implements MusicService { } // Set credentials to get through apache proxies that require authentication. - int instance = prefs.getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1); - String username = prefs.getString(Constants.PREFERENCES_KEY_USERNAME + instance, null); - String password = prefs.getString(Constants.PREFERENCES_KEY_PASSWORD + instance, null); - httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), - new UsernamePasswordCredentials(username, password)); + SharedPreferences preferences = Util.getPreferences(context); + int instance = preferences.getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1); + String username = preferences.getString(Constants.PREFERENCES_KEY_USERNAME + instance, null); + String password = preferences.getString(Constants.PREFERENCES_KEY_PASSWORD + instance, null); + httpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), new UsernamePasswordCredentials(username, password)); try { HttpResponse response = httpClient.execute(request, httpContext); @@ -1050,13 +1058,16 @@ public class RESTMusicService implements MusicService { return response; } catch (IOException x) { request.abort(); + if (attempts >= HTTP_REQUEST_MAX_ATTEMPTS || cancelled.get()) { throw x; } + if (progressListener != null) { String msg = context.getResources().getString(R.string.music_service_retry, attempts, HTTP_REQUEST_MAX_ATTEMPTS - 1); progressListener.updateProgress(msg); } + Log.w(TAG, "Got IOException (" + attempts + "), will retry", x); increaseTimeouts(requestParams); Util.sleepQuietly(2000L); diff --git a/src/com/thejoshwa/ultrasonic/androidapp/util/Constants.java b/src/com/thejoshwa/ultrasonic/androidapp/util/Constants.java index 4c80f6e8..323a4af2 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/util/Constants.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/util/Constants.java @@ -79,8 +79,6 @@ public final class Constants { public static final String PREFERENCES_KEY_SHOW_TRACK_NUMBER = "showTrackNumber"; public static final String PREFERENCES_KEY_MAX_BITRATE_WIFI = "maxBitrateWifi"; public static final String PREFERENCES_KEY_MAX_BITRATE_MOBILE = "maxBitrateMobile"; - public static final String PREFERENCES_KEY_MAX_VIDEO_BITRATE_WIFI = "maxVideoBitrateWifi"; - public static final String PREFERENCES_KEY_MAX_VIDEO_BITRATE_MOBILE = "maxVideoBitrateMobile"; public static final String PREFERENCES_KEY_CACHE_SIZE = "cacheSize"; public static final String PREFERENCES_KEY_CACHE_LOCATION = "cacheLocation"; public static final String PREFERENCES_KEY_PRELOAD_COUNT = "preloadCount"; diff --git a/src/com/thejoshwa/ultrasonic/androidapp/util/Util.java b/src/com/thejoshwa/ultrasonic/androidapp/util/Util.java index f6cd4b85..45c7d7d8 100644 --- a/src/com/thejoshwa/ultrasonic/androidapp/util/Util.java +++ b/src/com/thejoshwa/ultrasonic/androidapp/util/Util.java @@ -105,8 +105,6 @@ public class Util extends DownloadActivity { public static final String CM_AVRCP_PLAYSTATE_CHANGED = "com.android.music.playstatechanged"; public static final String CM_AVRCP_METADATA_CHANGED = "com.android.music.metachanged"; - //public final static int albumArtImageSize = 300; - private static boolean hasFocus = false; private static boolean pauseFocus = false; private static boolean lowerFocus = false; @@ -117,7 +115,6 @@ public class Util extends DownloadActivity { private static final char[] HEX_DIGITS = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; private static Toast toast; - //public static Bitmap albumArtBitmap; private static Entry currentSong; private Util() {