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

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


package com.appsflyer.internal;

import android.app.Application;
import android.content.Context;
import android.net.Uri;
import android.os.Build;
import com.appsflyer.AFLogger;
import com.appsflyer.AppsFlyerLib;
import com.appsflyer.deeplink.DeepLink;
import com.appsflyer.deeplink.DeepLinkResult;
import com.appsflyer.internal.AFc1oSDK;
import com.appsflyer.internal.AFf1oSDK;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import com.newrelic.agent.android.instrumentation.Instrumented;
import com.newrelic.agent.android.instrumentation.JSONObjectInstrumentation;
import in.swiggy.android.tejas.feature.listing.analytics.helpers.AnalyticsUtils;
import j$.util.DesugarTimeZone;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.net.HttpURLConnection;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Observable;
import java.util.Observer;
import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.json.JSONException;
import org.json.JSONObject;
@Instrumented
public final class AFb1qSDK extends AFe1iSDK {
    public static long AFLogger$LogLevel = 0;
    private static String AFVersionDeclaration = "https://%sdlsdk.%s/v1.0/android/";
    private final AFe1sSDK AppsFlyer2dXConversionCallback;
    private final CountDownLatch afErrorLogForExcManagerOnly;
    private final List<AFf1oSDK> getLevel;
    private final AFf1lSDK init;
    private final ExecutorService onAppOpenAttributionNative;
    private int onAttributionFailureNative;
    private boolean onConversionDataSuccess;
    private final AFb1rSDK onDeepLinkingNative;
    private final AFb1bSDK onInstallConversionDataLoadedNative;
    private final AFe1jSDK onInstallConversionFailureNative;
    private int onResponseErrorNative;
    private int onResponseNative;

    public static class AnonymousClass1 {
        static final int[] values;

        static {
            int[] iArr = new int[AFf1oSDK.AFa1zSDK.values().length];
            values = iArr;
            try {
                iArr[AFf1oSDK.AFa1zSDK.FINISHED.ordinal()] = 1;
            } catch (NoSuchFieldError unused) {
            }
            try {
                values[AFf1oSDK.AFa1zSDK.STARTED.ordinal()] = 2;
            } catch (NoSuchFieldError unused2) {
            }
        }
    }

    public AFb1qSDK(Context context, AFc1zSDK aFc1zSDK) {
        super(null, AFVersionDeclaration, Boolean.FALSE, Boolean.TRUE, null, context);
        this.getLevel = new ArrayList();
        this.afErrorLogForExcManagerOnly = new CountDownLatch(1);
        this.onInstallConversionFailureNative = aFc1zSDK.afRDLog();
        this.onInstallConversionDataLoadedNative = aFc1zSDK.valueOf();
        this.AppsFlyer2dXConversionCallback = aFc1zSDK.afWarnLog();
        this.init = aFc1zSDK.AFLogger$LogLevel();
        this.onAppOpenAttributionNative = aFc1zSDK.AFInAppEventParameterName();
        this.onDeepLinkingNative = aFc1zSDK.getLevel();
    }

    private static boolean AFInAppEventParameterName(AFf1oSDK aFf1oSDK) {
        Long l = (Long) aFf1oSDK.valueOf.get("click_ts");
        return l != null && System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(l.longValue()) < TimeUnit.DAYS.toMillis(1L);
    }

    static void AFInAppEventType(AFb1qSDK aFb1qSDK) {
        AFf1oSDK[] AFInAppEventParameterName;
        ArrayList<AFf1oSDK> arrayList = new ArrayList();
        for (AFf1oSDK aFf1oSDK : aFb1qSDK.init.AFInAppEventParameterName()) {
            if (aFf1oSDK != null && aFf1oSDK.afRDLog != AFf1oSDK.AFa1zSDK.NOT_STARTED) {
                arrayList.add(aFf1oSDK);
            }
        }
        aFb1qSDK.onResponseErrorNative = arrayList.size();
        for (final AFf1oSDK aFf1oSDK2 : arrayList) {
            int i = AnonymousClass1.values[aFf1oSDK2.afRDLog.ordinal()];
            if (i != 1) {
                if (i == 2) {
                    aFf1oSDK2.addObserver(new Observer() {
                        @Override
                        public final void update(Observable observable, Object obj) {
                            StringBuilder sb = new StringBuilder("[DDL] ");
                            sb.append(aFf1oSDK2.valueOf.get("source"));
                            sb.append(" referrer collected via observer");
                            AFLogger.afDebugLog(sb.toString());
                            AFb1qSDK.this.AFKeystoreWrapper((AFf1oSDK) observable);
                        }
                    });
                }
            } else {
                StringBuilder sb = new StringBuilder("[DDL] ");
                sb.append(aFf1oSDK2.valueOf.get("source"));
                sb.append(" referrer collected earlier");
                AFLogger.afDebugLog(sb.toString());
                aFb1qSDK.AFKeystoreWrapper(aFf1oSDK2);
            }
        }
    }

    public void AFKeystoreWrapper(AFf1oSDK aFf1oSDK) {
        if (AFInAppEventParameterName(aFf1oSDK)) {
            this.getLevel.add(aFf1oSDK);
            this.afErrorLogForExcManagerOnly.countDown();
            StringBuilder sb = new StringBuilder("[DDL] Added non-organic ");
            sb.append(aFf1oSDK.getClass().getSimpleName());
            AFLogger.afDebugLog(sb.toString());
            return;
        }
        int i = this.onAttributionFailureNative + 1;
        this.onAttributionFailureNative = i;
        if (i == this.onResponseErrorNative) {
            this.afErrorLogForExcManagerOnly.countDown();
        }
    }

    private boolean AFLogger$LogLevel() {
        int i;
        List list = (List) this.AFInAppEventParameterName.get("referrers");
        if (list != null) {
            i = list.size();
        } else {
            i = 0;
        }
        if (i >= this.onResponseErrorNative || this.AFInAppEventParameterName.containsKey("referrers")) {
            return false;
        }
        return true;
    }

    public void getLevel() {
        String[] strArr;
        boolean z = true;
        this.onResponseNative++;
        StringBuilder sb = new StringBuilder("[DDL] Preparing request ");
        sb.append(this.onResponseNative);
        AFLogger.afDebugLog(sb.toString());
        if (this.onResponseNative == 1) {
            AFb1wSDK AFKeystoreWrapper = AFb1wSDK.AFKeystoreWrapper();
            Map<String, Object> map = this.AFInAppEventParameterName;
            if (this.onInstallConversionDataLoadedNative.AFInAppEventType.AFKeystoreWrapper("appsFlyerCount", 0) != 0) {
                z = false;
            }
            map.put("is_first", Boolean.valueOf(z));
            Map<String, Object> map2 = this.AFInAppEventParameterName;
            StringBuilder sb2 = new StringBuilder();
            sb2.append(Locale.getDefault().getLanguage());
            sb2.append("-");
            sb2.append(Locale.getDefault().getCountry());
            map2.put("lang", sb2.toString());
            this.AFInAppEventParameterName.put("os", Build.VERSION.RELEASE);
            this.AFInAppEventParameterName.put("type", Build.MODEL);
            this.AFInAppEventParameterName.put(AnalyticsUtils.REQUEST_ID, AFb1zSDK.AFInAppEventParameterName(new WeakReference(this.onInstallConversionDataLoadedNative.values.AFKeystoreWrapper)));
            AFa1fSDK aFa1fSDK = AFKeystoreWrapper.afInfoLog;
            if (aFa1fSDK != null && (strArr = aFa1fSDK.values) != null) {
                this.AFInAppEventParameterName.put("sharing_filter", strArr);
            }
            Map<String, Object> valueOf = valueOf(AFa1eSDK.AFKeystoreWrapper(this.onInstallConversionDataLoadedNative.values.AFKeystoreWrapper, new HashMap()));
            Map<String, Object> valueOf2 = valueOf(AFa1eSDK.AFInAppEventParameterName(this.onInstallConversionDataLoadedNative.values.AFKeystoreWrapper));
            if (valueOf != null) {
                this.AFInAppEventParameterName.put("gaid", valueOf);
            }
            if (valueOf2 != null) {
                this.AFInAppEventParameterName.put("oaid", valueOf2);
            }
        }
        Map<String, Object> map3 = this.AFInAppEventParameterName;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US);
        long currentTimeMillis = System.currentTimeMillis();
        simpleDateFormat.setTimeZone(DesugarTimeZone.getTimeZone("UTC"));
        map3.put("timestamp", simpleDateFormat.format(new Date(currentTimeMillis)));
        this.AFInAppEventParameterName.put("request_count", Integer.valueOf(this.onResponseNative));
        ArrayList arrayList = new ArrayList();
        for (AFf1oSDK aFf1oSDK : this.getLevel) {
            Map<String, String> values = values(aFf1oSDK);
            if (values != null) {
                arrayList.add(values);
            }
        }
        if (!arrayList.isEmpty()) {
            this.AFInAppEventParameterName.put("referrers", arrayList);
        }
        AFInAppEventParameterName(init());
    }

    private String init() {
        String str;
        String str2 = this.AppsFlyer2dXConversionCallback.AFInAppEventParameterName;
        String packageName = this.onInstallConversionDataLoadedNative.values.AFKeystoreWrapper.getPackageName();
        String values = this.onInstallConversionDataLoadedNative.values();
        if (values != null && !values.trim().isEmpty()) {
            str = "-".concat(values);
        } else {
            str = "";
        }
        Uri.Builder buildUpon = Uri.parse(String.format(AFVersionDeclaration, AppsFlyerLib.getInstance().getHostPrefix(), AFb1wSDK.AFKeystoreWrapper().getHostName())).buildUpon();
        StringBuilder sb = new StringBuilder();
        sb.append(packageName);
        sb.append(str);
        Uri.Builder appendPath = buildUpon.appendPath(sb.toString());
        StringBuilder sb2 = new StringBuilder();
        sb2.append(this.AFInAppEventParameterName.get("timestamp"));
        sb2.append(str2);
        return appendPath.appendQueryParameter("af_sig", AFb1ySDK.AFInAppEventType(sb2.toString(), str2)).appendQueryParameter("sdk_version", AFb1wSDK.AFInAppEventParameterName).build().toString();
    }

    private static Map<String, String> values(AFf1oSDK aFf1oSDK) {
        if (aFf1oSDK.afRDLog == AFf1oSDK.AFa1zSDK.FINISHED) {
            HashMap hashMap = new HashMap();
            String str = (String) aFf1oSDK.valueOf.get("referrer");
            if (str != null) {
                hashMap.put("source", (String) aFf1oSDK.valueOf.get("source"));
                hashMap.put(AppMeasurementSdk.ConditionalUserProperty.VALUE, str);
                return hashMap;
            }
            return null;
        }
        return null;
    }

    public final DeepLinkResult afErrorLog() {
        DeepLinkResult.Error error;
        AFLogger.afDebugLog("[DDL] start");
        FutureTask futureTask = new FutureTask(new Callable<DeepLinkResult>() {
            @Override
            public final DeepLinkResult call() throws Exception {
                Application application = AFb1qSDK.this.AFKeystoreWrapper;
                AFb1qSDK.AFInAppEventType(AFb1qSDK.this);
                AFb1qSDK.this.getLevel();
                return AFb1qSDK.AFInAppEventParameterName(AFb1qSDK.this, application);
            }
        });
        this.onAppOpenAttributionNative.execute(futureTask);
        try {
            DeepLinkResult deepLinkResult = (DeepLinkResult) futureTask.get(AFLogger$LogLevel, TimeUnit.MILLISECONDS);
            this.onInstallConversionFailureNative.values(deepLinkResult, AFLogger$LogLevel);
            AFb1pSDK.AFKeystoreWrapper(deepLinkResult);
            return deepLinkResult;
        } catch (InterruptedException e) {
            e = e;
            AFLogger.afErrorLog("[DDL] Error occurred", e, true);
            if (!(e.getCause() instanceof IOException)) {
                error = DeepLinkResult.Error.NETWORK;
            } else {
                error = DeepLinkResult.Error.UNEXPECTED;
            }
            DeepLinkResult deepLinkResult2 = new DeepLinkResult(null, error);
            this.onInstallConversionFailureNative.values(deepLinkResult2, AFLogger$LogLevel);
            AFb1pSDK.AFKeystoreWrapper(deepLinkResult2);
            return deepLinkResult2;
        } catch (ExecutionException e2) {
            e = e2;
            AFLogger.afErrorLog("[DDL] Error occurred", e, true);
            if (!(e.getCause() instanceof IOException)) {
            }
            DeepLinkResult deepLinkResult22 = new DeepLinkResult(null, error);
            this.onInstallConversionFailureNative.values(deepLinkResult22, AFLogger$LogLevel);
            AFb1pSDK.AFKeystoreWrapper(deepLinkResult22);
            return deepLinkResult22;
        } catch (TimeoutException e3) {
            AFLogger.afErrorLogForExcManagerOnly("[DDL] Timeout", e3);
            StringBuilder sb = new StringBuilder("[DDL] Timeout, didn't manage to find deferred deep link after ");
            sb.append(this.onResponseNative);
            sb.append(" attempt(s) within ");
            sb.append(AFLogger$LogLevel);
            sb.append(" milliseconds");
            AFLogger.afDebugLog(sb.toString());
            DeepLinkResult deepLinkResult3 = new DeepLinkResult(null, DeepLinkResult.Error.TIMEOUT);
            this.onInstallConversionFailureNative.values(deepLinkResult3, AFLogger$LogLevel);
            AFb1pSDK.AFKeystoreWrapper(deepLinkResult3);
            return deepLinkResult3;
        }
    }

    static DeepLinkResult AFInAppEventParameterName(AFb1qSDK aFb1qSDK, Context context) throws IOException, JSONException, InterruptedException {
        DeepLink AFKeystoreWrapper;
        while (true) {
            AFe1jSDK aFe1jSDK = aFb1qSDK.onInstallConversionFailureNative;
            int i = aFb1qSDK.onResponseNative;
            if (i > 0 && i <= 2) {
                int i2 = i - 1;
                aFe1jSDK.afErrorLog[i2] = System.currentTimeMillis();
                if (i2 == 0) {
                    long j = aFe1jSDK.afInfoLog;
                    if (j != 0) {
                        aFe1jSDK.valueOf.put("from_fg", Long.valueOf(aFe1jSDK.afErrorLog[i2] - j));
                        aFe1jSDK.AFInAppEventParameterName.AFInAppEventType("ddl", JSONObjectInstrumentation.toString(new JSONObject(aFe1jSDK.valueOf)));
                    } else {
                        AFLogger.afInfoLog("Metrics: fg ts is missing");
                    }
                }
            } else {
                AFLogger.afErrorLogForExcManagerOnly("Unexpected ddl requestCount - start", new IllegalStateException("Metrics: Unexpected ddl requestCount = ".concat(String.valueOf(i))));
            }
            HttpURLConnection AFInAppEventType = new AFa1uSDK(aFb1qSDK, aFb1qSDK.onDeepLinkingNative).AFInAppEventType(aFb1qSDK.AppsFlyer2dXConversionCallback.AFInAppEventParameterName);
            AFe1jSDK aFe1jSDK2 = aFb1qSDK.onInstallConversionFailureNative;
            int i3 = aFb1qSDK.onResponseNative;
            if (i3 > 0 && i3 <= 2) {
                int i4 = i3 - 1;
                aFe1jSDK2.AFLogger[i4] = System.currentTimeMillis();
                long j2 = aFe1jSDK2.afErrorLog[i4];
                if (j2 != 0) {
                    long[] jArr = aFe1jSDK2.afDebugLog;
                    jArr[i4] = aFe1jSDK2.AFLogger[i4] - j2;
                    aFe1jSDK2.valueOf.put("net", jArr);
                    aFe1jSDK2.AFInAppEventParameterName.AFInAppEventType("ddl", JSONObjectInstrumentation.toString(new JSONObject(aFe1jSDK2.valueOf)));
                } else {
                    StringBuilder sb = new StringBuilder("Metrics: ddlStart[");
                    sb.append(i4);
                    sb.append("] ts is missing");
                    AFLogger.afInfoLog(sb.toString());
                }
            } else {
                AFLogger.afErrorLogForExcManagerOnly("Unexpected ddl requestCount - end", new IllegalStateException("Metrics: Unexpected ddl requestCount = ".concat(String.valueOf(i3))));
            }
            if (AFInAppEventType.getResponseCode() == 200) {
                JSONObject jSONObject = new JSONObject(AFb1wSDK.AFInAppEventParameterName(AFInAppEventType));
                aFb1qSDK.onConversionDataSuccess = jSONObject.optBoolean("is_second_ping", true);
                if (jSONObject.optBoolean("found")) {
                    AFKeystoreWrapper = DeepLink.AFKeystoreWrapper(jSONObject.optJSONObject("click_event"));
                    AFKeystoreWrapper.valueOf.put("is_deferred", true);
                } else {
                    AFKeystoreWrapper = null;
                }
                if (AFKeystoreWrapper != null) {
                    return new DeepLinkResult(AFKeystoreWrapper, null);
                }
                if (aFb1qSDK.onResponseNative > 1 || !aFb1qSDK.AFLogger$LogLevel() || !aFb1qSDK.onConversionDataSuccess) {
                    break;
                }
                AFLogger.afDebugLog("[DDL] Waiting for referrers...");
                aFb1qSDK.afErrorLogForExcManagerOnly.await();
                AFe1jSDK aFe1jSDK3 = aFb1qSDK.onInstallConversionFailureNative;
                long currentTimeMillis = System.currentTimeMillis();
                long j3 = aFe1jSDK3.AFLogger[0];
                if (j3 != 0) {
                    aFe1jSDK3.valueOf.put("rfr_wait", Long.valueOf(currentTimeMillis - j3));
                    aFe1jSDK3.AFInAppEventParameterName.AFInAppEventType("ddl", JSONObjectInstrumentation.toString(new JSONObject(aFe1jSDK3.valueOf)));
                } else {
                    AFLogger.afInfoLog("Metrics: ddlEnd[0] ts is missing");
                }
                if (aFb1qSDK.onAttributionFailureNative == aFb1qSDK.onResponseErrorNative) {
                    return new DeepLinkResult(null, null);
                }
                aFb1qSDK.getLevel();
            } else {
                StringBuilder sb2 = new StringBuilder("[DDL] Error occurred. Server response code = ");
                sb2.append(AFInAppEventType.getResponseCode());
                AFLogger.afDebugLog(sb2.toString());
                return new DeepLinkResult(null, DeepLinkResult.Error.HTTP_STATUS_CODE);
            }
        }
    }

    private Map<String, Object> valueOf(final AFc1oSDK.AFa1vSDK aFa1vSDK) {
        if (aFa1vSDK == null || aFa1vSDK.AFInAppEventParameterName == null) {
            return null;
        }
        Boolean bool = aFa1vSDK.AFInAppEventType;
        if (bool == null || !bool.booleanValue()) {
            return new HashMap<String, Object>() {
                {
                    put("type", "unhashed");
                    put(AppMeasurementSdk.ConditionalUserProperty.VALUE, aFa1vSDK.AFInAppEventParameterName);
                }
            };
        }
        return null;
    }

    @Override
    public final AFd1uSDK AFKeystoreWrapper() {
        return AFd1uSDK.DLSDK;
    }
}