Merge pull request #78 from simao/bugfix/71

Use settings from preferences for readTimeout
This commit is contained in:
Andrew Rabert 2020-04-30 12:54:53 -04:00 committed by GitHub
commit f6d308c37c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -592,7 +592,7 @@ public class RESTMusicService implements MusicService {
public Response getDownloadInputStream(Context context, MusicDirectory.Entry song, long offset, int maxBitrate, SilentBackgroundTask task) throws Exception { public Response getDownloadInputStream(Context context, MusicDirectory.Entry song, long offset, int maxBitrate, SilentBackgroundTask task) throws Exception {
OkHttpClient eagerClient = client.newBuilder() OkHttpClient eagerClient = client.newBuilder()
.readTimeout(30, TimeUnit.SECONDS) .readTimeout(Util.getNetworkTimeoutMs(context), TimeUnit.MILLISECONDS)
.build(); .build();
Map<String, String> parameters = new HashMap<>(); Map<String, String> parameters = new HashMap<>();

View File

@ -72,6 +72,9 @@ import java.nio.charset.StandardCharsets;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalUnit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -122,6 +125,11 @@ public final class Util {
editor.apply(); editor.apply();
} }
public static int getNetworkTimeoutMs(Context context) {
SharedPreferences prefs = getPreferences(context);
return prefs.getInt(Constants.PREFERENCES_KEY_NETWORK_TIMEOUT, 30000);
}
public static boolean isScreenLitOnDownload(Context context) { public static boolean isScreenLitOnDownload(Context context) {
SharedPreferences prefs = getPreferences(context); SharedPreferences prefs = getPreferences(context);
return prefs.getBoolean(Constants.PREFERENCES_KEY_SCREEN_LIT_ON_DOWNLOAD, false); return prefs.getBoolean(Constants.PREFERENCES_KEY_SCREEN_LIT_ON_DOWNLOAD, false);