Make ProviderInstaller synchronous again
See #4077 for details: It is fast and the old method sometimes does not install the provider early enough Reverts #3946 and #4285
This commit is contained in:
parent
689bdb69db
commit
806b1f48ec
|
@ -45,6 +45,7 @@ public class ClientConfig {
|
||||||
UserPreferences.init(context);
|
UserPreferences.init(context);
|
||||||
UsageStatistics.init(context);
|
UsageStatistics.init(context);
|
||||||
PlaybackPreferences.init(context);
|
PlaybackPreferences.init(context);
|
||||||
|
installSslProvider(context);
|
||||||
NetworkUtils.init(context);
|
NetworkUtils.init(context);
|
||||||
AntennapodHttpClient.setCacheDirectory(new File(context.getCacheDir(), "okhttp"));
|
AntennapodHttpClient.setCacheDirectory(new File(context.getCacheDir(), "okhttp"));
|
||||||
SleepTimerPreferences.init(context);
|
SleepTimerPreferences.init(context);
|
||||||
|
@ -53,7 +54,7 @@ public class ClientConfig {
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void installSslProvider(Context context) {
|
private static void installSslProvider(Context context) {
|
||||||
// ProviderInstaller is a closed-source Google library
|
// ProviderInstaller is a closed-source Google library
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -32,7 +32,6 @@ import javax.net.ssl.TrustManagerFactory;
|
||||||
import javax.net.ssl.X509TrustManager;
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
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.service.UserAgentInterceptor;
|
||||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||||
import okhttp3.Cache;
|
import okhttp3.Cache;
|
||||||
|
@ -117,7 +116,6 @@ public class AntennapodHttpClient {
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
builder.interceptors().add(new ProviderInstallerInterceptor());
|
|
||||||
builder.interceptors().add(new BasicAuthorizationInterceptor());
|
builder.interceptors().add(new BasicAuthorizationInterceptor());
|
||||||
builder.networkInterceptors().add(new UserAgentInterceptor());
|
builder.networkInterceptors().add(new UserAgentInterceptor());
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||||
import de.danoeh.antennapod.core.preferences.SleepTimerPreferences;
|
import de.danoeh.antennapod.core.preferences.SleepTimerPreferences;
|
||||||
import de.danoeh.antennapod.core.preferences.UsageStatistics;
|
import de.danoeh.antennapod.core.preferences.UsageStatistics;
|
||||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
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.service.download.AntennapodHttpClient;
|
||||||
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
import de.danoeh.antennapod.core.storage.PodDBAdapter;
|
||||||
import de.danoeh.antennapod.core.util.NetworkUtils;
|
import de.danoeh.antennapod.core.util.NetworkUtils;
|
||||||
|
@ -55,6 +54,7 @@ public class ClientConfig {
|
||||||
UserPreferences.init(context);
|
UserPreferences.init(context);
|
||||||
UsageStatistics.init(context);
|
UsageStatistics.init(context);
|
||||||
PlaybackPreferences.init(context);
|
PlaybackPreferences.init(context);
|
||||||
|
installSslProvider(context);
|
||||||
NetworkUtils.init(context);
|
NetworkUtils.init(context);
|
||||||
// Don't initialize Cast-related logic unless it is enabled, to avoid the unnecessary
|
// Don't initialize Cast-related logic unless it is enabled, to avoid the unnecessary
|
||||||
// Google Play Service usage.
|
// Google Play Service usage.
|
||||||
|
@ -65,18 +65,6 @@ public class ClientConfig {
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG, "Cast is disabled. All Cast-related initialization will be skipped.");
|
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"));
|
AntennapodHttpClient.setCacheDirectory(new File(context.getCacheDir(), "okhttp"));
|
||||||
SleepTimerPreferences.init(context);
|
SleepTimerPreferences.init(context);
|
||||||
RxJavaErrorHandlerSetup.setupRxJavaErrorHandler();
|
RxJavaErrorHandlerSetup.setupRxJavaErrorHandler();
|
||||||
|
@ -84,7 +72,7 @@ public class ClientConfig {
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void installSslProvider(Context context) {
|
private static void installSslProvider(Context context) {
|
||||||
try {
|
try {
|
||||||
ProviderInstaller.installIfNeeded(context);
|
ProviderInstaller.installIfNeeded(context);
|
||||||
} catch (GooglePlayServicesRepairableException e) {
|
} catch (GooglePlayServicesRepairableException e) {
|
||||||
|
|
Loading…
Reference in New Issue