Maxcredito v1.2.1版本的 MD5 值为:2605738f37f8ddb81288799ddcbfcbe8

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


package com.appsflyer.internal;

import android.content.Context;
import android.net.Uri;
import android.os.Build;
import com.appsflyer.AFLogger;
import com.appsflyer.AppsFlyerLib;
import com.appsflyer.AppsFlyerProperties;
import com.appsflyer.deeplink.DeepLink;
import com.appsflyer.deeplink.DeepLinkResult;
import com.appsflyer.internal.b;
import com.appsflyer.internal.bs;
import com.facebook.internal.AnalyticsEvents;
import com.google.android.material.datepicker.UtcDates;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
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.TimeZone;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public final class ar extends bd {
    private static String onAppOpenAttribution = "https://%sdlsdk.%s/v1.0/android/";
    public static long onAppOpenAttributionNative = TimeUnit.SECONDS.toMillis(3);
    private int AppsFlyerConversionListener;
    private boolean AppsFlyerLib;
    private final CountDownLatch onAttributionFailure;
    private final List<bs> onConversionDataFail;
    private final ax onConversionDataSuccess;
    public int onDeepLinkingNative;
    private final JSONObject onValidateInApp;
    private int onValidateInAppFailure;

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

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

    public ar(Context context, ax axVar) {
        super(null, onAppOpenAttribution, Boolean.FALSE, Boolean.TRUE, null, context);
        this.onConversionDataFail = new ArrayList();
        this.onAttributionFailure = new CountDownLatch(1);
        this.onValidateInApp = new JSONObject();
        this.onConversionDataSuccess = axVar;
    }

    public void AFInAppEventType(bs bsVar) {
        if (AFKeystoreWrapper(bsVar)) {
            this.onConversionDataFail.add(bsVar);
            this.onAttributionFailure.countDown();
            StringBuilder sb = new StringBuilder("[DDL] Added non-organic ");
            sb.append(bsVar.getClass().getSimpleName());
            AFLogger.AFKeystoreWrapper(sb.toString());
            return;
        }
        int i2 = this.AppsFlyerConversionListener + 1;
        this.AppsFlyerConversionListener = i2;
        if (i2 == this.onValidateInAppFailure) {
            this.onAttributionFailure.countDown();
        }
    }

    private static boolean AFKeystoreWrapper(bs bsVar) {
        Long l2 = (Long) bsVar.values.get("click_ts");
        return l2 != null && System.currentTimeMillis() - TimeUnit.SECONDS.toMillis(l2.longValue()) < TimeUnit.DAYS.toMillis(1L);
    }

    private boolean values() {
        List list = (List) this.values.get("referrers");
        return (list != null ? list.size() : 0) < this.onValidateInAppFailure && !this.values.containsKey("referrers");
    }

    public final void valueOf(DeepLinkResult deepLinkResult) {
        try {
            this.onValidateInApp.put(AnalyticsEvents.PARAMETER_SHARE_DIALOG_CONTENT_STATUS, deepLinkResult.getStatus().toString());
            this.onValidateInApp.put("timeout_value", onAppOpenAttributionNative);
        } catch (JSONException unused) {
        }
        ax axVar = this.onConversionDataSuccess;
        axVar.AFInAppEventType.edit().putString("ddl", this.onValidateInApp.toString()).apply();
        ah.values(this.valueOf).edit().putBoolean("ddl_sent", true).apply();
        aq.AFInAppEventParameterName(deepLinkResult);
    }

    private Map<String, Object> AFKeystoreWrapper(final b.e.a aVar) {
        Boolean bool;
        boolean z = false;
        if (aVar != null && aVar.AFKeystoreWrapper != null && ((bool = aVar.values) == null || !bool.booleanValue())) {
            z = true;
        }
        if (z) {
            return new HashMap<String, Object>() {
                {
                    put("type", "unhashed");
                    put("value", b.e.a.this.AFKeystoreWrapper);
                }
            };
        }
        return null;
    }

    public static void values(ar arVar) {
        ArrayList<bs> arrayList = new ArrayList();
        for (bs bsVar : ah.AFInAppEventParameterName().onDeepLinkingNative) {
            if (bsVar != null && bsVar.AFKeystoreWrapper != bs.e.NOT_STARTED) {
                arrayList.add(bsVar);
            }
        }
        arVar.onValidateInAppFailure = arrayList.size();
        for (final bs bsVar2 : arrayList) {
            int i2 = AnonymousClass3.values[bsVar2.AFKeystoreWrapper.ordinal()];
            if (i2 == 1) {
                StringBuilder sb = new StringBuilder("[DDL] ");
                sb.append(bsVar2.values.get("source"));
                sb.append(" referrer collected earlier");
                AFLogger.AFKeystoreWrapper(sb.toString());
                arVar.AFInAppEventType(bsVar2);
            } else if (i2 == 2) {
                bsVar2.addObserver(new Observer() {
                    @Override
                    public final void update(Observable observable, Object obj) {
                        StringBuilder sb2 = new StringBuilder("[DDL] ");
                        sb2.append(bsVar2.values.get("source"));
                        sb2.append(" referrer collected via observer");
                        AFLogger.AFKeystoreWrapper(sb2.toString());
                        ar.this.AFInAppEventType((bs) observable);
                    }
                });
            }
        }
    }

    public static DeepLinkResult AFKeystoreWrapper(ar arVar, Context context) throws IOException, JSONException, InterruptedException, NoSuchAlgorithmException, InvalidKeyException {
        DeepLink valueOf;
        while (true) {
            long currentTimeMillis = System.currentTimeMillis();
            if (arVar.onDeepLinkingNative == 1) {
                arVar.onValidateInApp.put("from_fg", currentTimeMillis - arVar.onConversionDataSuccess.AFInAppEventType.getLong("fg_ts", 0L));
            }
            HttpURLConnection AFKeystoreWrapper = new m(arVar).AFKeystoreWrapper();
            JSONArray optJSONArray = arVar.onValidateInApp.optJSONArray("net");
            if (optJSONArray == null) {
                optJSONArray = new JSONArray();
            }
            long currentTimeMillis2 = System.currentTimeMillis();
            optJSONArray.put(arVar.onDeepLinkingNative - 1, currentTimeMillis2 - currentTimeMillis);
            arVar.onValidateInApp.put("net", optJSONArray);
            if (AFKeystoreWrapper.getResponseCode() == 200) {
                JSONObject jSONObject = new JSONObject(ah.AFInAppEventParameterName().AFInAppEventType(AFKeystoreWrapper));
                arVar.AppsFlyerLib = jSONObject.optBoolean("is_second_ping", true);
                if (jSONObject.optBoolean("found")) {
                    valueOf = DeepLink.valueOf(jSONObject.optJSONObject("click_event"));
                    valueOf.valueOf.put("is_deferred", true);
                } else {
                    valueOf = null;
                }
                if (valueOf != null) {
                    return new DeepLinkResult(valueOf, null);
                }
                if (arVar.onDeepLinkingNative > 1 || !arVar.values() || !arVar.AppsFlyerLib) {
                    break;
                }
                AFLogger.AFKeystoreWrapper("[DDL] Waiting for referrers...");
                arVar.onAttributionFailure.await();
                arVar.onValidateInApp.put("rfr_wait", System.currentTimeMillis() - currentTimeMillis2);
                if (arVar.AppsFlyerConversionListener == arVar.onValidateInAppFailure) {
                    return new DeepLinkResult(null, null);
                }
                arVar.valueOf(context);
            } else {
                StringBuilder sb = new StringBuilder("[DDL] Error occurred. Server response code = ");
                sb.append(AFKeystoreWrapper.getResponseCode());
                AFLogger.AFKeystoreWrapper(sb.toString());
                return new DeepLinkResult(null, DeepLinkResult.c.HTTP_STATUS_CODE);
            }
        }
        return new DeepLinkResult(null, null);
    }

    public void valueOf(Context context) throws NoSuchAlgorithmException, InvalidKeyException {
        HashMap hashMap;
        this.onDeepLinkingNative++;
        StringBuilder sb = new StringBuilder("[DDL] Preparing request ");
        sb.append(this.onDeepLinkingNative);
        AFLogger.AFKeystoreWrapper(sb.toString());
        if (this.onDeepLinkingNative == 1) {
            ah AFInAppEventParameterName = ah.AFInAppEventParameterName();
            this.values.put("is_first", Boolean.valueOf(ah.AFKeystoreWrapper(context)));
            Map<String, Object> map = this.values;
            StringBuilder sb2 = new StringBuilder();
            sb2.append(Locale.getDefault().getLanguage());
            sb2.append("-");
            sb2.append(Locale.getDefault().getCountry());
            map.put("lang", sb2.toString());
            this.values.put("os", Build.VERSION.RELEASE);
            this.values.put("type", Build.MODEL);
            this.values.put("request_id", AFInAppEventParameterName.getAppsFlyerUID(context));
            String[] strArr = AFInAppEventParameterName.getLevel;
            if (strArr != null) {
                this.values.put("sharing_filter", strArr);
            }
            Map<String, Object> AFKeystoreWrapper = AFKeystoreWrapper(ac.values(context, new HashMap()));
            Map<String, Object> AFKeystoreWrapper2 = AFKeystoreWrapper(ac.AFKeystoreWrapper(context));
            if (AFKeystoreWrapper != null) {
                this.values.put("gaid", AFKeystoreWrapper);
            }
            if (AFKeystoreWrapper2 != null) {
                this.values.put("oaid", AFKeystoreWrapper2);
            }
        }
        Map<String, Object> map2 = this.values;
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS", Locale.US);
        long currentTimeMillis = System.currentTimeMillis();
        simpleDateFormat.setTimeZone(TimeZone.getTimeZone(UtcDates.UTC));
        map2.put("timestamp", simpleDateFormat.format(new Date(currentTimeMillis)));
        this.values.put("request_count", Integer.valueOf(this.onDeepLinkingNative));
        ArrayList arrayList = new ArrayList();
        for (bs bsVar : this.onConversionDataFail) {
            if (bsVar.AFKeystoreWrapper == bs.e.FINISHED) {
                hashMap = new HashMap();
                String str = (String) bsVar.values.get("referrer");
                if (str != null) {
                    hashMap.put("source", (String) bsVar.values.get("source"));
                    hashMap.put("value", str);
                    if (hashMap == null) {
                        arrayList.add(hashMap);
                    }
                }
            }
            hashMap = null;
            if (hashMap == null) {
            }
        }
        if (!arrayList.isEmpty()) {
            this.values.put("referrers", arrayList);
        }
        Uri.Builder appendPath = Uri.parse(String.format(this.onAttributionFailureNative, AppsFlyerLib.getInstance().getHostPrefix(), ah.AFInAppEventParameterName().getHostName())).buildUpon().appendPath(context.getPackageName());
        String str2 = (String) this.values.get("timestamp");
        byte[] bytes = AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.AF_KEY).getBytes();
        Mac mac = Mac.getInstance("HmacSHA256");
        mac.init(new SecretKeySpec(bytes, "HmacSHA256"));
        StringBuilder sb3 = new StringBuilder();
        sb3.append(str2);
        sb3.append(AppsFlyerProperties.getInstance().getString(AppsFlyerProperties.AF_KEY));
        AFInAppEventParameterName(appendPath.appendQueryParameter("af_sig", aj.AFInAppEventParameterName(mac.doFinal(sb3.toString().getBytes())).toLowerCase()).appendQueryParameter("sdk_version", ah.AFInAppEventParameterName).build().toString());
    }
}