Sketch SG v3.0版本的 MD5 值为:c9b07a41a370e7ad2443807e6792f6ec

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


package com.appsflyer.internal;

import android.app.Application;
import com.appsflyer.AFInAppEventParameterName;
import com.appsflyer.AFLogger;
import com.appsflyer.AppsFlyerLib;
import com.yandex.metrica.YandexMetricaDefaultValues;
import java.lang.ref.WeakReference;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.json.JSONObject;

public final class ay implements Runnable {
    private static String valueOf = "https://%sgcdsdk.%s/install_data/v4.0/";
    private static final List<String> values = Arrays.asList("googleplay", "playstore", "googleplaystore");
    private final String AFInAppEventParameterName;
    final ScheduledExecutorService AFInAppEventType;
    private final Application AFKeystoreWrapper;
    private final ae AFLogger$LogLevel;
    private final int AFVersionDeclaration;
    private final AtomicInteger getLevel;

    public ay(ae aeVar, Application application, String str) {
        if (k.valueOf == null) {
            k.valueOf = new k();
        }
        this.AFInAppEventType = k.valueOf.AFInAppEventParameterName();
        this.getLevel = new AtomicInteger(0);
        this.AFLogger$LogLevel = aeVar;
        this.AFKeystoreWrapper = application;
        this.AFInAppEventParameterName = str;
        this.AFVersionDeclaration = 0;
    }

    private ay(ay ayVar) {
        if (k.valueOf == null) {
            k.valueOf = new k();
        }
        this.AFInAppEventType = k.valueOf.AFInAppEventParameterName();
        this.getLevel = new AtomicInteger(0);
        this.AFLogger$LogLevel = ayVar.AFLogger$LogLevel;
        this.AFKeystoreWrapper = ayVar.AFKeystoreWrapper;
        this.AFInAppEventParameterName = ayVar.AFInAppEventParameterName;
        this.AFVersionDeclaration = ayVar.AFVersionDeclaration + 1;
    }

    public static void AFInAppEventType(Map<String, Object> map) {
        StringBuilder sb = new StringBuilder("[GCD-A02] Calling onConversionDataSuccess with:\n");
        sb.append(map.toString());
        AFLogger.values(sb.toString());
        ae.valueOf.onConversionDataSuccess(map);
    }

    public static void AFInAppEventParameterName(String str) {
        if (ae.valueOf != null) {
            AFLogger.values("[GCD-A02] Calling onConversionFailure with:\n".concat(String.valueOf(str)));
            ae.valueOf.onConversionDataFail(str);
        }
    }

    @Override
    public final void run() {
        Application application;
        String str;
        HttpURLConnection httpURLConnection;
        int responseCode;
        String AFKeystoreWrapper;
        String str2 = this.AFInAppEventParameterName;
        if (str2 == null || str2.length() == 0) {
            AFLogger.values("[GCD-E05] AppsFlyer dev key is missing");
            AFInAppEventParameterName("AppsFlyer dev key is missing");
            return;
        }
        if (this.AFLogger$LogLevel.isStopped()) {
            AFLogger.values("[GCD-E03] 'isStopTracking' enabled");
            AFInAppEventParameterName("'isStopTracking' enabled");
            return;
        }
        this.getLevel.incrementAndGet();
        HttpURLConnection httpURLConnection2 = null;
        try {
            application = this.AFKeystoreWrapper;
        } catch (Throwable th) {
            th = th;
        }
        if (application == null) {
            AFLogger.values("[GCD-E06] Context null");
            AFInAppEventParameterName("Context null");
            this.getLevel.decrementAndGet();
            return;
        }
        ae aeVar = this.AFLogger$LogLevel;
        String AFKeystoreWrapper2 = aeVar.AFKeystoreWrapper(application, aeVar.valueOf(application));
        if (AFKeystoreWrapper2 != null) {
            if (!values.contains(AFKeystoreWrapper2.toLowerCase())) {
                str = "-".concat(String.valueOf(AFKeystoreWrapper2));
                StringBuilder sb = new StringBuilder();
                sb.append(String.format(valueOf, AppsFlyerLib.getInstance().getHostPrefix(), ae.values().getHostName()));
                sb.append(this.AFKeystoreWrapper.getPackageName());
                sb.append(str);
                sb.append("?devkey=");
                sb.append(this.AFInAppEventParameterName);
                sb.append("&device_id=");
                sb.append(an.AFKeystoreWrapper(new WeakReference(this.AFKeystoreWrapper)));
                String obj = sb.toString();
                aj.valueOf().AFInAppEventType("server_request", obj, "");
                am.AFKeystoreWrapper("[GCD-B01] URL: ".concat(String.valueOf(obj)));
                long currentTimeMillis = System.currentTimeMillis();
                httpURLConnection = (HttpURLConnection) new URL(obj).openConnection();
                httpURLConnection.setRequestMethod("GET");
                httpURLConnection.setConnectTimeout(YandexMetricaDefaultValues.DEFAULT_MAX_REPORTS_COUNT_UPPER_BOUND);
                httpURLConnection.setRequestProperty("Connection", "close");
                httpURLConnection.connect();
                responseCode = httpURLConnection.getResponseCode();
                AFKeystoreWrapper = ae.AFKeystoreWrapper(httpURLConnection);
                aj.valueOf().AFInAppEventType("server_response", obj, String.valueOf(responseCode), AFKeystoreWrapper);
                if (responseCode != 200 && responseCode != 404) {
                    if ((responseCode != 403 || responseCode >= 500) && this.AFVersionDeclaration < 2) {
                        ay ayVar = new ay(this);
                        ae.AFInAppEventType(ayVar.AFInAppEventType, ayVar, 10L, TimeUnit.MILLISECONDS);
                    } else {
                        AFInAppEventParameterName("Error connection to server: ".concat(String.valueOf(responseCode)));
                    }
                    this.getLevel.decrementAndGet();
                    if (httpURLConnection != null) {
                        httpURLConnection.disconnect();
                    }
                    this.AFInAppEventType.shutdown();
                    AFLogger.values("[GCD-A03] Server retrieving attempt finished");
                }
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("net", System.currentTimeMillis() - currentTimeMillis);
                jSONObject.put("retries", this.AFVersionDeclaration);
                this.AFLogger$LogLevel.init.valueOf.edit().putString("gcd", jSONObject.toString()).apply();
                am.AFKeystoreWrapper("Attribution data: ".concat(String.valueOf(AFKeystoreWrapper)));
                if (AFKeystoreWrapper.length() > 0) {
                    Map<String, Object> valueOf2 = ba.valueOf(AFKeystoreWrapper);
                    Boolean bool = (Boolean) valueOf2.get("iscache");
                    if (responseCode == 404) {
                        valueOf2.remove("error_reason");
                        valueOf2.remove("status_code");
                        valueOf2.put("af_status", "Organic");
                        valueOf2.put("af_message", "organic install");
                    }
                    if (bool != null && !bool.booleanValue()) {
                        this.AFLogger$LogLevel.valueOf(this.AFKeystoreWrapper, "appsflyerConversionDataCacheExpiration", System.currentTimeMillis());
                    }
                    if (valueOf2.containsKey("af_siteid")) {
                        if (valueOf2.containsKey(AFInAppEventParameterName.AF_CHANNEL)) {
                            StringBuilder sb2 = new StringBuilder("[Invite] Detected App-Invite via channel: ");
                            sb2.append(valueOf2.get(AFInAppEventParameterName.AF_CHANNEL));
                            AFLogger.values(sb2.toString());
                        } else {
                            AFLogger.values(String.format("[CrossPromotion] App was installed via %s's Cross Promotion", valueOf2.get("af_siteid")));
                        }
                    }
                    if (valueOf2.containsKey("af_siteid")) {
                        StringBuilder sb3 = new StringBuilder("[Invite] Detected App-Invite via channel: ");
                        sb3.append(valueOf2.get(AFInAppEventParameterName.AF_CHANNEL));
                        AFLogger.values(sb3.toString());
                    }
                    valueOf2.put("is_first_launch", Boolean.FALSE);
                    String jSONObject2 = new JSONObject(valueOf2).toString();
                    if (jSONObject2 != null) {
                        ae.AFKeystoreWrapper(this.AFKeystoreWrapper, "attributionId", jSONObject2);
                    } else {
                        ae.AFKeystoreWrapper(this.AFKeystoreWrapper, "attributionId", AFKeystoreWrapper);
                    }
                    if (ae.valueOf != null && this.getLevel.intValue() <= 1) {
                        try {
                            Map<String, Object> values2 = ba.values(this.AFKeystoreWrapper);
                            if (!ae.values(this.AFKeystoreWrapper).getBoolean("sixtyDayConversionData", false)) {
                                values2.put("is_first_launch", Boolean.TRUE);
                            }
                            valueOf2 = values2;
                        } catch (az e) {
                            AFLogger.AFInAppEventType("Exception while trying to fetch attribution data. ", e);
                        }
                        StringBuilder sb4 = new StringBuilder("[GCD-A02] Calling onConversionDataSuccess with:\n");
                        sb4.append(valueOf2.toString());
                        AFLogger.values(sb4.toString());
                        ae.valueOf.onConversionDataSuccess(valueOf2);
                    }
                }
                this.getLevel.decrementAndGet();
                if (httpURLConnection != null) {
                }
                this.AFInAppEventType.shutdown();
                AFLogger.values("[GCD-A03] Server retrieving attempt finished");
            }
            AFLogger.init(String.format("AF detected using redundant Google-Play channel for attribution - %s. Using without channel postfix.", AFKeystoreWrapper2));
        }
        str = "";
        StringBuilder sb5 = new StringBuilder();
        sb5.append(String.format(valueOf, AppsFlyerLib.getInstance().getHostPrefix(), ae.values().getHostName()));
        sb5.append(this.AFKeystoreWrapper.getPackageName());
        sb5.append(str);
        sb5.append("?devkey=");
        sb5.append(this.AFInAppEventParameterName);
        sb5.append("&device_id=");
        sb5.append(an.AFKeystoreWrapper(new WeakReference(this.AFKeystoreWrapper)));
        String obj2 = sb5.toString();
        aj.valueOf().AFInAppEventType("server_request", obj2, "");
        am.AFKeystoreWrapper("[GCD-B01] URL: ".concat(String.valueOf(obj2)));
        long currentTimeMillis2 = System.currentTimeMillis();
        httpURLConnection = (HttpURLConnection) new URL(obj2).openConnection();
        httpURLConnection.setRequestMethod("GET");
        httpURLConnection.setConnectTimeout(YandexMetricaDefaultValues.DEFAULT_MAX_REPORTS_COUNT_UPPER_BOUND);
        httpURLConnection.setRequestProperty("Connection", "close");
        httpURLConnection.connect();
        responseCode = httpURLConnection.getResponseCode();
        AFKeystoreWrapper = ae.AFKeystoreWrapper(httpURLConnection);
        aj.valueOf().AFInAppEventType("server_response", obj2, String.valueOf(responseCode), AFKeystoreWrapper);
        if (responseCode != 200) {
            if (responseCode != 403) {
            }
            ay ayVar2 = new ay(this);
            ae.AFInAppEventType(ayVar2.AFInAppEventType, ayVar2, 10L, TimeUnit.MILLISECONDS);
            this.getLevel.decrementAndGet();
            if (httpURLConnection != null) {
            }
            this.AFInAppEventType.shutdown();
            AFLogger.values("[GCD-A03] Server retrieving attempt finished");
        }
        JSONObject jSONObject3 = new JSONObject();
        jSONObject3.put("net", System.currentTimeMillis() - currentTimeMillis2);
        jSONObject3.put("retries", this.AFVersionDeclaration);
        this.AFLogger$LogLevel.init.valueOf.edit().putString("gcd", jSONObject3.toString()).apply();
        am.AFKeystoreWrapper("Attribution data: ".concat(String.valueOf(AFKeystoreWrapper)));
        if (AFKeystoreWrapper.length() > 0) {
        }
        this.getLevel.decrementAndGet();
        if (httpURLConnection != null) {
        }
        this.AFInAppEventType.shutdown();
        AFLogger.values("[GCD-A03] Server retrieving attempt finished");
    }
}