package de.danoeh.antennapod.core;

import android.content.Context;
import android.util.Log;

import de.danoeh.antennapod.core.cast.CastManager;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import de.danoeh.antennapod.core.preferences.SleepTimerPreferences;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
import de.danoeh.antennapod.core.util.NetworkUtils;
import de.danoeh.antennapod.core.util.exception.RxJavaErrorHandlerSetup;
import de.danoeh.antennapod.core.util.gui.NotificationUtils;

/**
 * Stores callbacks for core classes like Services, DB classes etc. and other configuration variables.
 * Apps using the core module of AntennaPod should register implementations of all interfaces here.
 */
public class ClientConfig {
    private static final String TAG = "ClientConfig";

    private ClientConfig(){}

    /**
     * Should be used when setting User-Agent header for HTTP-requests.
     */
    public static String USER_AGENT;

    public static ApplicationCallbacks applicationCallbacks;

    public static DownloadServiceCallbacks downloadServiceCallbacks;

    public static PlaybackServiceCallbacks playbackServiceCallbacks;

    public static GpodnetCallbacks gpodnetCallbacks;

    public static DBTasksCallbacks dbTasksCallbacks;

    public static CastCallbacks castCallbacks;

    private static boolean initialized = false;

    public static synchronized void initialize(Context context) {
        if (initialized) {
            return;
        }
        PodDBAdapter.init(context);
        UserPreferences.init(context);
        PlaybackPreferences.init(context);
        NetworkUtils.init(context);
        // Don't initialize Cast-related logic unless it is enabled, to avoid the unnecessary
        // Google Play Service usage.
        // Down side: when the user decides to enable casting, AntennaPod needs to be restarted
        // for it to take effect.
        if (UserPreferences.isCastEnabled()) {
            CastManager.init(context);
        } else {
            Log.v(TAG, "Cast is disabled. All Cast-related initialization will be skipped.");
        }
        SleepTimerPreferences.init(context);
        RxJavaErrorHandlerSetup.setupRxJavaErrorHandler();
        NotificationUtils.createChannels(context);
        initialized = true;
    }

}

@@ -87,16 +87,288 @@
 l.Log;%0A%0A
+import com.google.android.gms.common.GoogleApiAvailability;%0Aimport com.google.android.gms.common.GooglePlayServicesNotAvailableException;%0Aimport com.google.android.gms.common.GooglePlayServicesRepairableException;%0Aimport com.google.android.gms.security.ProviderInstaller;%0A
 import d
@@ -2443,32 +2443,69 @@
 d.%22);%0A        %7D%0A
+        installSslProvider(context);%0A
         SleepTim
@@ -2678,10 +2678,455 @@
 %0A    %7D%0A%0A
+    private static void installSslProvider(Context context) %7B%0A        try %7B%0A            ProviderInstaller.installIfNeeded(context);%0A        %7D catch (GooglePlayServicesRepairableException e) %7B%0A            e.printStackTrace();%0A            GoogleApiAvailability.getInstance().showErrorNotification(context, e.getConnectionStatusCode());%0A        %7D catch (GooglePlayServicesNotAvailableException e) %7B%0A            e.printStackTrace();%0A        %7D%0A    %7D%0A
 %7D%0A

Use Google Trust provider