Craftsman 4 v1.20.43版本的 MD5 值为:44824ed1b4bf939cc4a771f5f317f768

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


package com.appsflyer.share;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import com.appsflyer.AFLogger;
import com.appsflyer.AppsFlyerLib;
import com.appsflyer.AppsFlyerProperties;
import com.appsflyer.internal.ah;
import com.appsflyer.internal.cr;
import com.appsflyer.internal.cu;
import com.google.common.net.HttpHeaders;
import com.safedk.android.analytics.events.BrandSafetyEvent;
import java.lang.ref.WeakReference;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
public class CrossPromotionHelper {
    private static String AFInAppEventParameterName = "https://%simpression.%s";

    public static void logAndOpenStore(Context context, String str, String str2) {
        logAndOpenStore(context, str, str2, null);
    }

    public static void logAndOpenStore(Context context, String str, String str2, Map<String, String> map) {
        LinkGenerator AFInAppEventParameterName2 = AFInAppEventParameterName(context, str, str2, map, String.format(cr.valueOf, AppsFlyerLib.getInstance().getHostPrefix(), ah.AFKeystoreWrapper().getHostName()));
        if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.AF_WAITFOR_CUSTOMERID, false)) {
            AFLogger.valueOf("CustomerUserId not set, track And Open Store is disabled", true);
            return;
        }
        if (map == null) {
            map = new HashMap<>();
        }
        map.put("af_campaign", str2);
        AppsFlyerLib.getInstance().logEvent(context, "af_cross_promotion", map);
        new Thread(new d(AFInAppEventParameterName2.generateLink(), new cu(), context, AppsFlyerLib.getInstance().isStopped())).start();
    }

    public static void logCrossPromoteImpression(Context context, String str, String str2) {
        logCrossPromoteImpression(context, str, str2, null);
    }

    public static void logCrossPromoteImpression(Context context, String str, String str2, Map<String, String> map) {
        if (AppsFlyerProperties.getInstance().getBoolean(AppsFlyerProperties.AF_WAITFOR_CUSTOMERID, false)) {
            AFLogger.valueOf("CustomerUserId not set, Promote Impression is disabled", true);
        } else {
            new Thread(new d(AFInAppEventParameterName(context, str, str2, map, String.format(AFInAppEventParameterName, AppsFlyerLib.getInstance().getHostPrefix(), ah.AFKeystoreWrapper().getHostName())).generateLink(), null, null, AppsFlyerLib.getInstance().isStopped())).start();
        }
    }

    private static LinkGenerator AFInAppEventParameterName(Context context, String str, String str2, Map<String, String> map, String str3) {
        LinkGenerator linkGenerator = new LinkGenerator("af_cross_promotion");
        linkGenerator.valueOf = str3;
        linkGenerator.AFInAppEventType = str;
        linkGenerator.addParameter("af_siteid", context.getPackageName());
        if (str2 != null) {
            linkGenerator.setCampaign(str2);
        }
        if (map != null) {
            linkGenerator.addParameters(map);
        }
        String string = AppsFlyerProperties.getInstance().getString("advertiserId");
        if (string != null) {
            linkGenerator.addParameter("advertising_id", string);
        }
        return linkGenerator;
    }

    public static void setUrl(Map<String, String> map) {
        for (Map.Entry<String, String> entry : map.entrySet()) {
            String value = entry.getValue();
            String key = entry.getKey();
            char c2 = 65535;
            int hashCode = key.hashCode();
            if (hashCode != 96801) {
                if (hashCode == 120623625 && key.equals(BrandSafetyEvent.f6290n)) {
                    c2 = 1;
                }
            } else if (key.equals("app")) {
                c2 = 0;
            }
            if (c2 == 0) {
                cr.valueOf = value;
            } else if (c2 == 1) {
                AFInAppEventParameterName = value;
            }
        }
    }

    public static class d implements Runnable {
        private final boolean AFInAppEventParameterName;
        private final WeakReference<Context> AFInAppEventType;
        private final cu AFKeystoreWrapper;
        private final String values;

        d(String str, cu cuVar, Context context, boolean z) {
            this.values = str;
            this.AFKeystoreWrapper = cuVar;
            this.AFInAppEventType = new WeakReference<>(context);
            this.AFInAppEventParameterName = z;
        }

        @Override
        public final void run() {
            HttpURLConnection httpURLConnection;
            Throwable th;
            if (this.AFInAppEventParameterName) {
                return;
            }
            try {
                httpURLConnection = (HttpURLConnection) new URL(this.values).openConnection();
            } catch (Throwable th2) {
                httpURLConnection = null;
                th = th2;
            }
            try {
                httpURLConnection.setConnectTimeout(10000);
                httpURLConnection.setInstanceFollowRedirects(false);
                int responseCode = httpURLConnection.getResponseCode();
                if (responseCode == 200) {
                    StringBuilder sb = new StringBuilder("Cross promotion impressions success: ");
                    sb.append(this.values);
                    AFLogger.valueOf(sb.toString(), false);
                } else if (responseCode == 301 || responseCode == 302) {
                    StringBuilder sb2 = new StringBuilder("Cross promotion redirection success: ");
                    sb2.append(this.values);
                    AFLogger.valueOf(sb2.toString(), false);
                    if (this.AFKeystoreWrapper != null && this.AFInAppEventType.get() != null) {
                        this.AFKeystoreWrapper.AFInAppEventType = httpURLConnection.getHeaderField(HttpHeaders.LOCATION);
                        cu cuVar = this.AFKeystoreWrapper;
                        Context context = this.AFInAppEventType.get();
                        if (cuVar.AFInAppEventType != null) {
                            context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(cuVar.AFInAppEventType)).setFlags(268435456));
                        }
                    }
                } else {
                    StringBuilder sb3 = new StringBuilder("call to ");
                    sb3.append(this.values);
                    sb3.append(" failed: ");
                    sb3.append(responseCode);
                    AFLogger.AFInAppEventType(sb3.toString());
                }
            } catch (Throwable th3) {
                th = th3;
                try {
                    AFLogger.AFInAppEventType(th.getMessage(), th);
                    if (httpURLConnection != null) {
                        httpURLConnection.disconnect();
                    }
                } finally {
                    if (httpURLConnection != null) {
                        httpURLConnection.disconnect();
                    }
                }
            }
        }
    }
}