Merge pull request #4285 from ByteHamster/install-provider
Install provider in any case
This commit is contained in:
commit
a3a5a58ae6
|
@ -266,16 +266,15 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
true, null, true);
|
||||
|
||||
download = Observable.fromCallable(() -> {
|
||||
feeds = DBReader.getFeedList();
|
||||
ClientConfig.installSslProvider(this);
|
||||
downloader = new HttpDownloader(request);
|
||||
downloader.call();
|
||||
return downloader.getResult();
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::checkDownloadResult,
|
||||
error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
feeds = DBReader.getFeedList();
|
||||
downloader = new HttpDownloader(request);
|
||||
downloader.call();
|
||||
return downloader.getResult();
|
||||
})
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(this::checkDownloadResult,
|
||||
error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
}
|
||||
|
||||
private void checkDownloadResult(@NonNull DownloadStatus status) {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package de.danoeh.antennapod.core.service;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.Response;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ProviderInstallerInterceptor implements Interceptor {
|
||||
public static Runnable installer = () -> { };
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
installer.run();
|
||||
return chain.proceed(chain.request());
|
||||
}
|
||||
}
|
|
@ -7,10 +7,6 @@ import okhttp3.Response;
|
|||
import java.io.IOException;
|
||||
|
||||
public class UserAgentInterceptor implements Interceptor {
|
||||
|
||||
public UserAgentInterceptor() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
return chain.proceed(chain.request().newBuilder()
|
||||
|
|
|
@ -32,6 +32,7 @@ import javax.net.ssl.TrustManagerFactory;
|
|||
import javax.net.ssl.X509TrustManager;
|
||||
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.ProviderInstallerInterceptor;
|
||||
import de.danoeh.antennapod.core.service.UserAgentInterceptor;
|
||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||
import okhttp3.Cache;
|
||||
|
@ -116,6 +117,7 @@ public class AntennapodHttpClient {
|
|||
}
|
||||
return response;
|
||||
});
|
||||
builder.interceptors().add(new ProviderInstallerInterceptor());
|
||||
builder.interceptors().add(new BasicAuthorizationInterceptor());
|
||||
builder.networkInterceptors().add(new UserAgentInterceptor());
|
||||
|
||||
|
|
|
@ -479,12 +479,9 @@ public class DownloadService extends Service {
|
|||
}
|
||||
handler.post(() -> {
|
||||
downloads.add(downloader);
|
||||
downloadExecutor.submit(downloader);
|
||||
postDownloaders();
|
||||
});
|
||||
// Needs to be done after postDownloaders() because otherwise,
|
||||
// it might take long before the progress bar circle starts spinning
|
||||
ClientConfig.installSslProvider(this);
|
||||
handler.post(() -> downloadExecutor.submit(downloader));
|
||||
}
|
||||
handler.post(this::queryDownloads);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package de.danoeh.antennapod.core;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
|
||||
import com.google.android.gms.common.GooglePlayServicesRepairableException;
|
||||
|
@ -12,6 +12,7 @@ import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
|||
import de.danoeh.antennapod.core.preferences.SleepTimerPreferences;
|
||||
import de.danoeh.antennapod.core.preferences.UsageStatistics;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.ProviderInstallerInterceptor;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||
|
@ -64,6 +65,18 @@ public class ClientConfig {
|
|||
} else {
|
||||
Log.v(TAG, "Cast is disabled. All Cast-related initialization will be skipped.");
|
||||
}
|
||||
ProviderInstaller.installIfNeededAsync(context, new ProviderInstaller.ProviderInstallListener() {
|
||||
@Override
|
||||
public void onProviderInstalled() {
|
||||
Log.e(TAG, "onProviderInstalled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProviderInstallFailed(int i, Intent intent) {
|
||||
Log.e(TAG, "onProviderInstallFailed");
|
||||
}
|
||||
});
|
||||
ProviderInstallerInterceptor.installer = () -> installSslProvider(context);
|
||||
AntennapodHttpClient.setCacheDirectory(new File(context.getCacheDir(), "okhttp"));
|
||||
SleepTimerPreferences.init(context);
|
||||
RxJavaErrorHandlerSetup.setupRxJavaErrorHandler();
|
||||
|
|
Loading…
Reference in New Issue