Kufar v3.2.0版本的 MD5 值为:6a4d203db1c561c7e3bcd50d23fed59f

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


package com.appsflyer.internal;

import android.net.Uri;
import android.os.Build;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.appsflyer.AFLogger;
import com.appsflyer.AppsFlyerLib;
import com.appsflyer.deeplink.DeepLink;
import com.appsflyer.deeplink.DeepLinkResult;
import com.appsflyer.internal.AFc1wSDK;
import com.appsflyer.internal.AFf1pSDK;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import com.tapjoy.TapjoyAuctionFlags;
import com.tapjoy.TapjoyConstants;
import com.vungle.warren.VungleApiClient;
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.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Observable;
import java.util.Observer;
import java.util.TimeZone;
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;

public final class AFb1pSDK extends AFe1jSDK {
    public static long afErrorLog = 0;

    @VisibleForTesting
    private static String afErrorLogForExcManagerOnly = "https://%sdlsdk.%s/v1.0/android/";
    private final AFe1gSDK AFLogger$LogLevel;
    private final List<AFf1pSDK> AFVersionDeclaration;
    private final AFf1iSDK AppsFlyer2dXConversionCallback;
    private final CountDownLatch getLevel;
    private final AFb1uSDK init;
    private final AFe1tSDK onAppOpenAttributionNative;
    private int onAttributionFailureNative;
    private boolean onConversionDataSuccess;
    private int onDeepLinkingNative;
    private final ExecutorService onInstallConversionDataLoadedNative;
    private final AFc1ySDK onInstallConversionFailureNative;
    private final AFb1tSDK onResponseErrorNative;
    private int onResponseNative;

    public static class AnonymousClass3 {
        static final int[] AFInAppEventParameterName;

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

    public AFb1pSDK(AFb1bSDK aFb1bSDK) {
        super(null, afErrorLogForExcManagerOnly, Boolean.FALSE, Boolean.TRUE, null);
        this.AFVersionDeclaration = new ArrayList();
        this.getLevel = new CountDownLatch(1);
        this.AFLogger$LogLevel = aFb1bSDK.afDebugLog();
        this.onInstallConversionFailureNative = aFb1bSDK.values();
        this.onAppOpenAttributionNative = aFb1bSDK.AppsFlyer2dXConversionCallback();
        this.AppsFlyer2dXConversionCallback = aFb1bSDK.AFVersionDeclaration();
        this.onInstallConversionDataLoadedNative = aFb1bSDK.AFInAppEventType();
        this.init = aFb1bSDK.AFLogger$LogLevel();
        this.onResponseErrorNative = aFb1bSDK.onResponseErrorNative();
    }

    public void AFInAppEventType(AFf1pSDK aFf1pSDK) {
        if (AFInAppEventParameterName(aFf1pSDK)) {
            this.AFVersionDeclaration.add(aFf1pSDK);
            this.getLevel.countDown();
            StringBuilder sb2 = new StringBuilder("[DDL] Added non-organic ");
            sb2.append(aFf1pSDK.getClass().getSimpleName());
            AFLogger.afDebugLog(sb2.toString());
            return;
        }
        int i11 = this.onAttributionFailureNative + 1;
        this.onAttributionFailureNative = i11;
        if (i11 == this.onDeepLinkingNative) {
            this.getLevel.countDown();
        }
    }

    @Nullable
    private Map<String, Object> AFKeystoreWrapper(final AFc1wSDK.AFa1ySDK aFa1ySDK) {
        Boolean bool;
        boolean z11 = false;
        if (aFa1ySDK != null && aFa1ySDK.AFInAppEventType != null && ((bool = aFa1ySDK.AFKeystoreWrapper) == null || !bool.booleanValue())) {
            z11 = true;
        }
        if (z11) {
            return new HashMap<String, Object>() {
                {
                    put(TapjoyAuctionFlags.AUCTION_TYPE, "unhashed");
                    put(AppMeasurementSdk.ConditionalUserProperty.VALUE, aFa1ySDK.AFInAppEventType);
                }
            };
        }
        return null;
    }

    private boolean afErrorLogForExcManagerOnly() {
        int i11;
        List list = (List) this.valueOf.get("referrers");
        if (list != null) {
            i11 = list.size();
        } else {
            i11 = 0;
        }
        if (i11 >= this.onDeepLinkingNative || this.valueOf.containsKey("referrers")) {
            return false;
        }
        return true;
    }

    public void getLevel() {
        String[] strArr;
        boolean z11 = true;
        this.onResponseNative++;
        StringBuilder sb2 = new StringBuilder("[DDL] Preparing request ");
        sb2.append(this.onResponseNative);
        AFLogger.afDebugLog(sb2.toString());
        if (this.onResponseNative == 1) {
            AFa1dSDK valueOf = AFa1dSDK.valueOf();
            Map<String, Object> map = this.valueOf;
            if (this.onInstallConversionFailureNative.values.AFInAppEventType("appsFlyerCount", 0) != 0) {
                z11 = false;
            }
            map.put("is_first", Boolean.valueOf(z11));
            Map<String, Object> map2 = this.valueOf;
            StringBuilder sb3 = new StringBuilder();
            sb3.append(Locale.getDefault().getLanguage());
            sb3.append("-");
            sb3.append(Locale.getDefault().getCountry());
            map2.put("lang", sb3.toString());
            this.valueOf.put("os", Build.VERSION.RELEASE);
            this.valueOf.put(TapjoyAuctionFlags.AUCTION_TYPE, Build.MODEL);
            this.valueOf.put("request_id", AFb1xSDK.values(new WeakReference(this.onInstallConversionFailureNative.AFInAppEventType.AFKeystoreWrapper)));
            AFa1eSDK aFa1eSDK = valueOf.afRDLog;
            if (aFa1eSDK != null && (strArr = aFa1eSDK.AFInAppEventParameterName) != null) {
                this.valueOf.put("sharing_filter", strArr);
            }
            Map<String, Object> AFKeystoreWrapper = AFKeystoreWrapper(AFa1eSDK.AFKeystoreWrapper(this.onInstallConversionFailureNative.AFInAppEventType.AFKeystoreWrapper, new HashMap()));
            Map<String, Object> AFKeystoreWrapper2 = AFKeystoreWrapper(AFa1eSDK.values(this.onInstallConversionFailureNative.AFInAppEventType.AFKeystoreWrapper));
            if (AFKeystoreWrapper != null) {
                this.valueOf.put(VungleApiClient.GAID, AFKeystoreWrapper);
            }
            if (AFKeystoreWrapper2 != null) {
                this.valueOf.put("oaid", AFKeystoreWrapper2);
            }
        }
        Map<String, Object> map3 = this.valueOf;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US);
        long currentTimeMillis = System.currentTimeMillis();
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
        map3.put("timestamp", simpleDateFormat.format(new Date(currentTimeMillis)));
        this.valueOf.put("request_count", Integer.valueOf(this.onResponseNative));
        ArrayList arrayList = new ArrayList();
        Iterator<AFf1pSDK> it = this.AFVersionDeclaration.iterator();
        while (it.hasNext()) {
            Map<String, String> AFKeystoreWrapper3 = AFKeystoreWrapper(it.next());
            if (AFKeystoreWrapper3 != null) {
                arrayList.add(AFKeystoreWrapper3);
            }
        }
        if (!arrayList.isEmpty()) {
            this.valueOf.put("referrers", arrayList);
        }
        AFKeystoreWrapper(init());
    }

    @VisibleForTesting
    private String init() {
        String str;
        String str2 = this.onAppOpenAttributionNative.AFKeystoreWrapper;
        String packageName = this.onInstallConversionFailureNative.AFInAppEventType.AFKeystoreWrapper.getPackageName();
        String AFKeystoreWrapper = this.onInstallConversionFailureNative.AFKeystoreWrapper();
        if (AFKeystoreWrapper != null && !AFKeystoreWrapper.trim().isEmpty()) {
            str = "-".concat(AFKeystoreWrapper);
        } else {
            str = "";
        }
        Uri.Builder buildUpon = Uri.parse(String.format(afErrorLogForExcManagerOnly, AppsFlyerLib.getInstance().getHostPrefix(), AFa1dSDK.valueOf().getHostName())).buildUpon();
        StringBuilder sb2 = new StringBuilder();
        sb2.append(packageName);
        sb2.append(str);
        Uri.Builder appendPath = buildUpon.appendPath(sb2.toString());
        StringBuilder sb3 = new StringBuilder();
        sb3.append(this.valueOf.get("timestamp"));
        sb3.append(str2);
        return appendPath.appendQueryParameter("af_sig", AFa1aSDK.AFInAppEventType(sb3.toString(), str2)).appendQueryParameter("sdk_version", AFa1dSDK.AFKeystoreWrapper).build().toString();
    }

    public static DeepLinkResult values(AFb1pSDK aFb1pSDK) throws IOException, JSONException, InterruptedException {
        DeepLink valueOf;
        while (true) {
            AFe1gSDK aFe1gSDK = aFb1pSDK.AFLogger$LogLevel;
            int i11 = aFb1pSDK.onResponseNative;
            if (i11 > 0 && i11 <= 2) {
                int i12 = i11 - 1;
                aFe1gSDK.afInfoLog[i12] = System.currentTimeMillis();
                if (i12 == 0) {
                    long j11 = aFe1gSDK.afRDLog;
                    if (j11 != 0) {
                        aFe1gSDK.values.put("from_fg", Long.valueOf(aFe1gSDK.afInfoLog[i12] - j11));
                        aFe1gSDK.AFInAppEventParameterName.valueOf("ddl", new JSONObject(aFe1gSDK.values).toString());
                    } else {
                        AFLogger.afInfoLog("Metrics: fg ts is missing");
                    }
                }
            } else {
                AFLogger.afErrorLogForExcManagerOnly("Unexpected ddl requestCount - start", new IllegalStateException("Metrics: Unexpected ddl requestCount = ".concat(String.valueOf(i11))));
            }
            HttpURLConnection AFInAppEventParameterName = new AFa1uSDK(aFb1pSDK, aFb1pSDK.init).AFInAppEventParameterName(aFb1pSDK.onAppOpenAttributionNative.AFKeystoreWrapper);
            AFe1gSDK aFe1gSDK2 = aFb1pSDK.AFLogger$LogLevel;
            int i13 = aFb1pSDK.onResponseNative;
            if (i13 > 0 && i13 <= 2) {
                int i14 = i13 - 1;
                aFe1gSDK2.AFLogger[i14] = System.currentTimeMillis();
                long j12 = aFe1gSDK2.afInfoLog[i14];
                if (j12 != 0) {
                    long[] jArr = aFe1gSDK2.afErrorLog;
                    jArr[i14] = aFe1gSDK2.AFLogger[i14] - j12;
                    aFe1gSDK2.values.put("net", jArr);
                    aFe1gSDK2.AFInAppEventParameterName.valueOf("ddl", new JSONObject(aFe1gSDK2.values).toString());
                } else {
                    StringBuilder sb2 = new StringBuilder("Metrics: ddlStart[");
                    sb2.append(i14);
                    sb2.append("] ts is missing");
                    AFLogger.afInfoLog(sb2.toString());
                }
            } else {
                AFLogger.afErrorLogForExcManagerOnly("Unexpected ddl requestCount - end", new IllegalStateException("Metrics: Unexpected ddl requestCount = ".concat(String.valueOf(i13))));
            }
            if (AFInAppEventParameterName.getResponseCode() == 200) {
                JSONObject jSONObject = new JSONObject(AFa1dSDK.AFKeystoreWrapper(AFInAppEventParameterName));
                aFb1pSDK.onConversionDataSuccess = jSONObject.optBoolean("is_second_ping", true);
                if (!jSONObject.optBoolean("found")) {
                    valueOf = null;
                } else {
                    valueOf = DeepLink.valueOf(jSONObject.optJSONObject("click_event"));
                    valueOf.AFInAppEventParameterName.put("is_deferred", true);
                }
                if (valueOf != null) {
                    return new DeepLinkResult(valueOf, null);
                }
                if (aFb1pSDK.onResponseNative > 1 || !aFb1pSDK.afErrorLogForExcManagerOnly() || !aFb1pSDK.onConversionDataSuccess) {
                    break;
                }
                AFLogger.afDebugLog("[DDL] Waiting for referrers...");
                aFb1pSDK.getLevel.await();
                AFe1gSDK aFe1gSDK3 = aFb1pSDK.AFLogger$LogLevel;
                long currentTimeMillis = System.currentTimeMillis();
                long j13 = aFe1gSDK3.AFLogger[0];
                if (j13 != 0) {
                    aFe1gSDK3.values.put("rfr_wait", Long.valueOf(currentTimeMillis - j13));
                    aFe1gSDK3.AFInAppEventParameterName.valueOf("ddl", new JSONObject(aFe1gSDK3.values).toString());
                } else {
                    AFLogger.afInfoLog("Metrics: ddlEnd[0] ts is missing");
                }
                if (aFb1pSDK.onAttributionFailureNative == aFb1pSDK.onDeepLinkingNative) {
                    return new DeepLinkResult(null, null);
                }
                aFb1pSDK.getLevel();
            } else {
                StringBuilder sb3 = new StringBuilder("[DDL] Error occurred. Server response code = ");
                sb3.append(AFInAppEventParameterName.getResponseCode());
                AFLogger.afDebugLog(sb3.toString());
                return new DeepLinkResult(null, DeepLinkResult.Error.HTTP_STATUS_CODE);
            }
        }
    }

    public final DeepLinkResult afRDLog() {
        DeepLinkResult.Error error;
        AFLogger.afDebugLog("[DDL] start");
        FutureTask futureTask = new FutureTask(new Callable<DeepLinkResult>() {
            @Override
            public final DeepLinkResult call() throws Exception {
                AFb1pSDK.AFInAppEventType(AFb1pSDK.this);
                AFb1pSDK.this.getLevel();
                return AFb1pSDK.values(AFb1pSDK.this);
            }
        });
        this.onInstallConversionDataLoadedNative.execute(futureTask);
        try {
            DeepLinkResult deepLinkResult = (DeepLinkResult) futureTask.get(afErrorLog, TimeUnit.MILLISECONDS);
            this.AFLogger$LogLevel.AFInAppEventType(deepLinkResult, afErrorLog);
            this.onResponseErrorNative.AFKeystoreWrapper(deepLinkResult);
            return deepLinkResult;
        } catch (InterruptedException e11) {
            e = e11;
            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.AFLogger$LogLevel.AFInAppEventType(deepLinkResult2, afErrorLog);
            this.onResponseErrorNative.AFKeystoreWrapper(deepLinkResult2);
            return deepLinkResult2;
        } catch (ExecutionException e12) {
            e = e12;
            AFLogger.afErrorLog("[DDL] Error occurred", e, true);
            if (!(e.getCause() instanceof IOException)) {
            }
            DeepLinkResult deepLinkResult22 = new DeepLinkResult(null, error);
            this.AFLogger$LogLevel.AFInAppEventType(deepLinkResult22, afErrorLog);
            this.onResponseErrorNative.AFKeystoreWrapper(deepLinkResult22);
            return deepLinkResult22;
        } catch (TimeoutException e13) {
            AFLogger.afErrorLogForExcManagerOnly("[DDL] Timeout", e13);
            StringBuilder sb2 = new StringBuilder("[DDL] Timeout, didn't manage to find deferred deep link after ");
            sb2.append(this.onResponseNative);
            sb2.append(" attempt(s) within ");
            sb2.append(afErrorLog);
            sb2.append(" milliseconds");
            AFLogger.afDebugLog(sb2.toString());
            DeepLinkResult deepLinkResult3 = new DeepLinkResult(null, DeepLinkResult.Error.TIMEOUT);
            this.AFLogger$LogLevel.AFInAppEventType(deepLinkResult3, afErrorLog);
            this.onResponseErrorNative.AFKeystoreWrapper(deepLinkResult3);
            return deepLinkResult3;
        }
    }

    private static boolean AFInAppEventParameterName(AFf1pSDK aFf1pSDK) {
        Long l11 = (Long) aFf1pSDK.values.get("click_ts");
        return l11 != null && System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(l11.longValue()) < TimeUnit.DAYS.toMillis(1L);
    }

    @Override
    public final AFd1tSDK AFInAppEventParameterName() {
        return AFd1tSDK.DLSDK;
    }

    private static Map<String, String> AFKeystoreWrapper(AFf1pSDK aFf1pSDK) {
        if (aFf1pSDK.AFInAppEventType != AFf1pSDK.AFa1wSDK.FINISHED) {
            return null;
        }
        HashMap hashMap = new HashMap();
        String str = (String) aFf1pSDK.values.get(TapjoyConstants.TJC_REFERRER);
        if (str == null) {
            return null;
        }
        hashMap.put("source", (String) aFf1pSDK.values.get("source"));
        hashMap.put(AppMeasurementSdk.ConditionalUserProperty.VALUE, str);
        return hashMap;
    }

    public static void AFInAppEventType(AFb1pSDK aFb1pSDK) {
        ArrayList<AFf1pSDK> arrayList = new ArrayList();
        for (AFf1pSDK aFf1pSDK : aFb1pSDK.AppsFlyer2dXConversionCallback.AFKeystoreWrapper()) {
            if (aFf1pSDK != null && aFf1pSDK.AFInAppEventType != AFf1pSDK.AFa1wSDK.NOT_STARTED) {
                arrayList.add(aFf1pSDK);
            }
        }
        aFb1pSDK.onDeepLinkingNative = arrayList.size();
        for (final AFf1pSDK aFf1pSDK2 : arrayList) {
            int i11 = AnonymousClass3.AFInAppEventParameterName[aFf1pSDK2.AFInAppEventType.ordinal()];
            if (i11 == 1) {
                StringBuilder sb2 = new StringBuilder("[DDL] ");
                sb2.append(aFf1pSDK2.values.get("source"));
                sb2.append(" referrer collected earlier");
                AFLogger.afDebugLog(sb2.toString());
                aFb1pSDK.AFInAppEventType(aFf1pSDK2);
            } else if (i11 == 2) {
                aFf1pSDK2.addObserver(new Observer() {
                    @Override
                    public final void update(Observable observable, Object obj) {
                        StringBuilder sb3 = new StringBuilder("[DDL] ");
                        sb3.append(aFf1pSDK2.values.get("source"));
                        sb3.append(" referrer collected via observer");
                        AFLogger.afDebugLog(sb3.toString());
                        AFb1pSDK.this.AFInAppEventType((AFf1pSDK) observable);
                    }
                });
            }
        }
    }
}