From 4dc40d3ee4f3f01230819d95389d95d6a4300d0e Mon Sep 17 00:00:00 2001 From: stom79 Date: Wed, 29 Nov 2017 18:26:32 +0100 Subject: [PATCH] Fixes an issue with services --- app/src/main/AndroidManifest.xml | 2 +- .../etalab/mastodon/services/LiveNotificationService.java | 6 +++--- .../services/StreamingFederatedTimelineService.java | 3 ++- .../mastodon/services/StreamingLocalTimelineService.java | 3 ++- .../fr/gouv/etalab/mastodon/services/StreamingService.java | 3 ++- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 55b27fbb0..75213d38a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -50,7 +50,7 @@ - + diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java b/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java index 351b5bc47..07d4cf1d5 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/services/LiveNotificationService.java @@ -208,7 +208,7 @@ public class LiveNotificationService extends Service { if( !restartCalled ) { restartCalled = true; SystemClock.sleep(60000); - sendBroadcast(new Intent("RestartStreamingService")); + sendBroadcast(new Intent("RestartLiveNotificationService")); stopSelf(); } } @@ -230,8 +230,8 @@ public class LiveNotificationService extends Service { httpsURLConnection.disconnect(); if( !restartCalled ) { restartCalled = true; - SystemClock.sleep(10000); - sendBroadcast(new Intent("RestartStreamingService")); + SystemClock.sleep(5000); + sendBroadcast(new Intent("RestartLiveNotificationService")); stopSelf(); } } diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingFederatedTimelineService.java b/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingFederatedTimelineService.java index 210bc2807..cb52c085d 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingFederatedTimelineService.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingFederatedTimelineService.java @@ -109,7 +109,8 @@ public class StreamingFederatedTimelineService extends IntentService { httpsURLConnection.setRequestProperty("Connection", "Keep-Alive"); httpsURLConnection.setRequestProperty("Keep-Alive", "header"); httpsURLConnection.setRequestProperty("Connection", "close"); - httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); + if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) + httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); httpsURLConnection.setRequestMethod("GET"); httpsURLConnection.setConnectTimeout(70000); httpsURLConnection.setReadTimeout(70000); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingLocalTimelineService.java b/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingLocalTimelineService.java index e850661e5..83fcbf053 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingLocalTimelineService.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingLocalTimelineService.java @@ -108,7 +108,8 @@ public class StreamingLocalTimelineService extends IntentService { httpsURLConnection.setRequestProperty("Connection", "Keep-Alive"); httpsURLConnection.setRequestProperty("Keep-Alive", "header"); httpsURLConnection.setRequestProperty("Connection", "close"); - httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); + if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) + httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); httpsURLConnection.setRequestMethod("GET"); httpsURLConnection.setConnectTimeout(70000); httpsURLConnection.setReadTimeout(70000); diff --git a/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingService.java b/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingService.java index dd1e64f31..ab5521a2d 100644 --- a/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingService.java +++ b/app/src/main/java/fr/gouv/etalab/mastodon/services/StreamingService.java @@ -106,7 +106,8 @@ public class StreamingService extends IntentService { httpsURLConnection.setRequestProperty("Connection", "Keep-Alive"); httpsURLConnection.setRequestProperty("Keep-Alive", "header"); httpsURLConnection.setRequestProperty("Connection", "close"); - httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); + if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) + httpsURLConnection.setSSLSocketFactory(new TLSSocketFactory()); httpsURLConnection.setRequestMethod("GET"); httpsURLConnection.setConnectTimeout(70000); httpsURLConnection.setReadTimeout(70000);