Swiggy v4.51.1版本的 MD5 值为:5af7ec91512a0a8c1510e3f8bac20b8b

以下内容为反编译后的 NetworkConfigUtils.java 源代码,内容仅作参考


package in.swiggy.android.tejas.network.retrofit.utils;

import android.content.SharedPreferences;
import in.swiggy.android.commons.extension.KotlinExtensionsKt;
import in.swiggy.android.commons.utils.b;
import in.swiggy.android.commons.utils.c;
import in.swiggy.android.commons.utils.u;
import in.swiggy.android.tejas.TejasConstants;
import java.util.Map;
import kotlin.collections.j0;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.o;
import org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf.PDLayoutAttributeObject;
public final class NetworkConfigUtils implements u {
    private static final String CONNECT_PRIORITY_ENABLED = "connect_priority_enabled";
    private static final boolean CONNECT_PRIORITY_ENABLED_DEFAULT = false;
    public static final String DISC_PREHEAT_URL = "https://disc.swiggy.com/connect";
    private static final String DNS_RESOLVER_PRIORITY_ENABLED = "dns_resolver_priority_enabled";
    private static final boolean DNS_RESOLVER_PRIORITY_ENABLED_DEFAULT = false;
    private static final String LAUNCH_PREHEAT_ENABLED = "launch_preheat_enabled";
    private static final boolean LAUNCH_PREHEAT_ENABLED_DEFAULT = false;
    public static final String MAPS_PREHEAT_URL = "https://maps.swiggy.com/connect";
    private static final String PARALLEL_DNS_ENABLED = "parallel_dns_enabled";
    private static final boolean PARALLEL_DNS_ENABLED_DEFAULT = true;
    private static final String PARALLEL_DNS_SYSTEM_TIMEOUT = "parallel_dns_system_timeout";
    private static final long PARALLEL_DNS_SYSTEM_TIMEOUT_DEFAULT = 2000;
    public static final String PREHEAT_WORKER_URL_LIST_JSON = "[\"https://disc.swiggy.com/connect\"]";
    private static final String WP_GLOBAL_DNS = "global_dns_enabled";
    private static final boolean WP_GLOBAL_DNS_DEFAULT = false;
    private static final String WP_LOG_LOTTIE_LOAD_SUCCESS = "should_log_lottie_load_success";
    private static final boolean WP_LOG_LOTTIE_LOAD_SUCCESS_DEFAULT = false;
    private static final String WP_OKHTTP_LOTTIE_DNS = "okhttp_lottie_dns_enabled";
    private static final boolean WP_OKHTTP_LOTTIE_DNS_DEFAULT = false;
    private static final String WP_PING_INTERVAL = "network_ping_interval_in_seconds";
    private static final long WP_PING_INTERVAL_DEFAULT = 0;
    private static final String XP_DNS_FLAGS = "consumer_android_dns_optimisation_flags";
    private static final String XP_PREHEAT_FLAGS = "consumer_android_preheat_optimisation_flags";
    private c cachedDNSXPFlags;
    private c cachedPreheatXPFlags;
    private final Function2<String, String, String> getXPValue;
    private final SharedPreferences sharedPreferences;
    public static final Companion Companion = new Companion(null);
    private static final c XP_PREHEAT_FLAGS_DEFAULT = new c(30, 0, 2, null);
    private static final c XP_PREHEAT_FLAGS_DISC = new c(1, 0, 2, null);
    private static final c XP_PREHEAT_FLAGS_MAPS = new c(2, 0, 2, null);
    private static final c XP_DNS_FLAGS_DEFAULT = new c(30, 0, 2, null);
    private static final c XP_DNS_FLAGS_BACKGROUND_WORKER = new c(1, 0, 2, null);
    private static final c XP_DNS_FLAGS_PING_INTERVAL = new c(2, 0, 2, null);
    private static final c XP_DNS_FLAGS_RESOLVER_PRIORITY = new c(3, 0, 2, null);
    private static final c XP_DNS_FLAGS_CONNECT_PRIORITY = new c(4, 0, 2, null);
    private static final c XP_DNS_FLAGS_PARALLEL_DNS = new c(5, 0, 2, null);
    private static final c XP_DNS_FLAGS_OKHTTP_LOTTIE_DNS = new c(6, 0, 2, null);
    private static final c XP_DNS_FLAGS_GLOBAL_OKHTTP_DNS = new c(7, 0, 2, null);

    public static final class Companion {
        public Companion(DefaultConstructorMarker defaultConstructorMarker) {
            this();
        }

        public final Map<String, String> getWPConfigMap() {
            Map<String, String> l;
            l = j0.l(o.a(NetworkConfigUtils.WP_PING_INTERVAL, PDLayoutAttributeObject.GLYPH_ORIENTATION_VERTICAL_ZERO_DEGREES), o.a(NetworkConfigUtils.DNS_RESOLVER_PRIORITY_ENABLED, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT), o.a(NetworkConfigUtils.CONNECT_PRIORITY_ENABLED, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT), o.a(NetworkConfigUtils.PARALLEL_DNS_ENABLED, "true"), o.a(NetworkConfigUtils.PARALLEL_DNS_SYSTEM_TIMEOUT, "2000"), o.a(NetworkConfigUtils.LAUNCH_PREHEAT_ENABLED, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT), o.a(NetworkConfigUtils.WP_OKHTTP_LOTTIE_DNS, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT), o.a(NetworkConfigUtils.WP_LOG_LOTTIE_LOAD_SUCCESS, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT), o.a(NetworkConfigUtils.WP_GLOBAL_DNS, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT));
            return l;
        }

        public final Map<String, String> getXPConfigMap() {
            Map<String, String> l;
            l = j0.l(o.a(NetworkConfigUtils.XP_PREHEAT_FLAGS, String.valueOf(NetworkConfigUtils.XP_PREHEAT_FLAGS_DEFAULT.a())), o.a(NetworkConfigUtils.XP_DNS_FLAGS, String.valueOf(NetworkConfigUtils.XP_DNS_FLAGS_DEFAULT.a())));
            return l;
        }

        private Companion() {
        }
    }

    public NetworkConfigUtils(SharedPreferences sharedPreferences, Function2<? super String, ? super String, String> function2) {
        this.sharedPreferences = sharedPreferences;
        this.getXPValue = function2;
    }

    private final c getDNSXPFlags() {
        String str;
        c cVar = this.cachedDNSXPFlags;
        if (cVar == null) {
            Function2<String, String, String> function2 = this.getXPValue;
            if (function2 != null) {
                str = function2.invoke(XP_DNS_FLAGS, String.valueOf(XP_DNS_FLAGS_DEFAULT.a()));
            } else {
                str = null;
            }
            c cVar2 = new c(0, KotlinExtensionsKt.w(str, XP_DNS_FLAGS_DEFAULT.a()), 1, null);
            this.cachedDNSXPFlags = cVar2;
            return cVar2;
        }
        return cVar;
    }

    private final long getPingIntervalFromWP() {
        String str;
        SharedPreferences sharedPreferences = this.sharedPreferences;
        if (sharedPreferences != null) {
            str = sharedPreferences.getString(WP_PING_INTERVAL, PDLayoutAttributeObject.GLYPH_ORIENTATION_VERTICAL_ZERO_DEGREES);
            if (str == null) {
                str = "";
            }
        } else {
            str = null;
        }
        return KotlinExtensionsKt.y(str, WP_PING_INTERVAL_DEFAULT);
    }

    private final c getPreheatXPFlags() {
        String str;
        c cVar = this.cachedPreheatXPFlags;
        if (cVar == null) {
            Function2<String, String, String> function2 = this.getXPValue;
            if (function2 != null) {
                str = function2.invoke(XP_PREHEAT_FLAGS, String.valueOf(XP_PREHEAT_FLAGS_DEFAULT.a()));
            } else {
                str = null;
            }
            c cVar2 = new c(0, KotlinExtensionsKt.w(str, XP_PREHEAT_FLAGS_DEFAULT.a()), 1, null);
            this.cachedPreheatXPFlags = cVar2;
            return cVar2;
        }
        return cVar;
    }

    private final boolean isConnectPriorityEnabledWP() {
        String str;
        SharedPreferences sharedPreferences = this.sharedPreferences;
        if (sharedPreferences != null) {
            str = sharedPreferences.getString(CONNECT_PRIORITY_ENABLED, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT);
            if (str == null) {
                str = "";
            }
        } else {
            str = null;
        }
        return KotlinExtensionsKt.q(str, false);
    }

    private final boolean isConnectPriorityEnabledXP() {
        return b.a(getDNSXPFlags(), XP_DNS_FLAGS_CONNECT_PRIORITY);
    }

    private final boolean isGlobalDnsEnabledWP() {
        String str;
        SharedPreferences sharedPreferences = this.sharedPreferences;
        if (sharedPreferences != null) {
            str = sharedPreferences.getString(WP_GLOBAL_DNS, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT);
            if (str == null) {
                str = "";
            }
        } else {
            str = null;
        }
        return KotlinExtensionsKt.q(str, false);
    }

    private final boolean isGlobalDnsEnabledXP() {
        return b.a(getDNSXPFlags(), XP_DNS_FLAGS_GLOBAL_OKHTTP_DNS);
    }

    private final boolean isOkHttpLottieDnsEnabledWP() {
        String str;
        SharedPreferences sharedPreferences = this.sharedPreferences;
        if (sharedPreferences != null) {
            str = sharedPreferences.getString(WP_OKHTTP_LOTTIE_DNS, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT);
            if (str == null) {
                str = "";
            }
        } else {
            str = null;
        }
        return KotlinExtensionsKt.q(str, false);
    }

    private final boolean isOkHttpLottieDnsEnabledXP() {
        return b.a(getDNSXPFlags(), XP_DNS_FLAGS_OKHTTP_LOTTIE_DNS);
    }

    private final boolean isParallelDNSEnabledWP() {
        String str;
        SharedPreferences sharedPreferences = this.sharedPreferences;
        if (sharedPreferences != null) {
            str = sharedPreferences.getString(PARALLEL_DNS_ENABLED, "true");
            if (str == null) {
                str = "";
            }
        } else {
            str = null;
        }
        return KotlinExtensionsKt.q(str, true);
    }

    private final boolean isParallelDNSEnabledXP() {
        return b.a(getDNSXPFlags(), XP_DNS_FLAGS_PARALLEL_DNS);
    }

    private final boolean isPingIntervalEnabledXP() {
        return b.a(getDNSXPFlags(), XP_DNS_FLAGS_PING_INTERVAL);
    }

    private final boolean isResolverPriorityEnabledWP() {
        String str;
        SharedPreferences sharedPreferences = this.sharedPreferences;
        if (sharedPreferences != null) {
            str = sharedPreferences.getString(DNS_RESOLVER_PRIORITY_ENABLED, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT);
            if (str == null) {
                str = "";
            }
        } else {
            str = null;
        }
        return KotlinExtensionsKt.q(str, false);
    }

    private final boolean isResolverPriorityEnabledXP() {
        return b.a(getDNSXPFlags(), XP_DNS_FLAGS_RESOLVER_PRIORITY);
    }

    @Override
    public long getPingIntervalInSeconds() {
        long pingIntervalFromWP = getPingIntervalFromWP();
        if (!isPingIntervalEnabledXP()) {
            return WP_PING_INTERVAL_DEFAULT;
        }
        return pingIntervalFromWP;
    }

    public final long getSystemDefaultTimeout() {
        String str;
        SharedPreferences sharedPreferences = this.sharedPreferences;
        if (sharedPreferences != null) {
            str = sharedPreferences.getString(PARALLEL_DNS_SYSTEM_TIMEOUT, "2000");
            if (str == null) {
                str = "";
            }
        } else {
            str = null;
        }
        return KotlinExtensionsKt.y(str, 2000L);
    }

    public final boolean isBackgroundWorkerEnabledXP() {
        return b.a(getDNSXPFlags(), XP_DNS_FLAGS_BACKGROUND_WORKER);
    }

    public final boolean isConnectPriorityEnabled() {
        boolean isConnectPriorityEnabledWP = isConnectPriorityEnabledWP();
        boolean isConnectPriorityEnabledXP = isConnectPriorityEnabledXP();
        if (isConnectPriorityEnabledWP && isConnectPriorityEnabledXP) {
            return true;
        }
        return false;
    }

    public final boolean isDiscPreheatEnabledXP() {
        return b.a(getPreheatXPFlags(), XP_PREHEAT_FLAGS_DISC);
    }

    public final boolean isGlobalDnsEnabled() {
        boolean isGlobalDnsEnabledWP = isGlobalDnsEnabledWP();
        boolean isGlobalDnsEnabledXP = isGlobalDnsEnabledXP();
        if (isGlobalDnsEnabledWP && isGlobalDnsEnabledXP) {
            return true;
        }
        return false;
    }

    public final boolean isLaunchPreheatEnabled() {
        String str;
        SharedPreferences sharedPreferences = this.sharedPreferences;
        if (sharedPreferences != null) {
            str = sharedPreferences.getString(LAUNCH_PREHEAT_ENABLED, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT);
            if (str == null) {
                str = "";
            }
        } else {
            str = null;
        }
        return KotlinExtensionsKt.q(str, false);
    }

    public final boolean isMapsPreheatEnabledXP() {
        return b.a(getPreheatXPFlags(), XP_PREHEAT_FLAGS_MAPS);
    }

    public final boolean isOkHttpLottieDnsEnabled() {
        boolean isOkHttpLottieDnsEnabledWP = isOkHttpLottieDnsEnabledWP();
        boolean isOkHttpLottieDnsEnabledXP = isOkHttpLottieDnsEnabledXP();
        if (isOkHttpLottieDnsEnabledWP && isOkHttpLottieDnsEnabledXP) {
            return true;
        }
        return false;
    }

    public final boolean isParallelDNSEnabled() {
        boolean isParallelDNSEnabledWP = isParallelDNSEnabledWP();
        boolean isParallelDNSEnabledXP = isParallelDNSEnabledXP();
        if (isParallelDNSEnabledWP && isParallelDNSEnabledXP) {
            return true;
        }
        return false;
    }

    public final boolean isResolverPriorityEnabled() {
        boolean isResolverPriorityEnabledWP = isResolverPriorityEnabledWP();
        boolean isResolverPriorityEnabledXP = isResolverPriorityEnabledXP();
        if (isResolverPriorityEnabledWP && isResolverPriorityEnabledXP) {
            return true;
        }
        return false;
    }

    public final boolean shouldLogLottieSuccess() {
        String str;
        SharedPreferences sharedPreferences = this.sharedPreferences;
        String str2 = null;
        if (sharedPreferences != null) {
            str = sharedPreferences.getString(WP_LOG_LOTTIE_LOAD_SUCCESS, TejasConstants.ENABLE_V4_PROFILE_API_DEFAULT);
            if (str == null) {
                str = "";
            }
        } else {
            str = null;
        }
        boolean q = KotlinExtensionsKt.q(str, false);
        String valueOf = String.valueOf(XP_DNS_FLAGS_DEFAULT.a());
        Function2<String, String, String> function2 = this.getXPValue;
        if (function2 != null) {
            str2 = function2.invoke(XP_DNS_FLAGS, valueOf);
        }
        if (!(!kotlin.jvm.internal.o.f(str2, valueOf)) || !q) {
            return false;
        }
        return true;
    }
}