TikTok.apk(点击下载) / JYF.java


package X;

import android.text.TextUtils;
import com.bytedance.android.livesdk.livesetting.broadcast.LiveMaxRetainAlogMessageSizeSetting;
import com.bytedance.android.monitorV2.HybridMultiMonitor;
import com.bytedance.covode.number.Covode;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import kotlin.g.b.m;
import org.json.JSONException;
import org.json.JSONObject;

public final class JYF {
    public static final JYF LIZ = new JYF();
    public static JYN LIZIZ = new JYN();
    public static final ExecutorService LIZJ = C14740iN.LIZ(C14780iR.LIZ(EnumC14830iW.FIXED).LIZ(1).LIZ());
    public static final ConcurrentHashMap<String, AtomicLong> LIZLLL = new ConcurrentHashMap<>();

    static {
        Covode.recordClassIndex(17858);
    }

    private final String LIZ(String str, JSONObject jSONObject) {
        String str2;
        if (!m.LIZ((Object) "custom", (Object) str)) {
            try {
                str2 = jSONObject.getJSONObject("nativeBase").getJSONObject("bid_info").getString("setting_bid");
                m.LIZ((Object) str2, "");
            } catch (JSONException e) {
                C63302eV.LIZ(e);
                return "";
            }
        } else {
            try {
                str2 = jSONObject.getJSONObject("bid_info").getString("setting_bid");
                m.LIZ((Object) str2, "");
            } catch (JSONException e2) {
                C63302eV.LIZ(e2);
                return "";
            }
        }
        return str2;
    }

    private final String LIZ(Map<String, ? extends Object> map) {
        if (map == null) {
            return "";
        }
        Iterator it = AnonymousClass1ZP.LIZLLL("jsb_bid", "regex_bid", "config_bid").iterator();
        while (it.hasNext()) {
            String str = (String) it.next();
            Object obj = map.get(str);
            if ((obj instanceof String) && (!AnonymousClass1ZS.LIZ((CharSequence) obj))) {
                AnonymousClass2ZL.LIZIZ("DataReporter", "use " + str + ": " + obj);
                return (String) obj;
            }
        }
        return "";
    }

    public final JYI LIZ(String str) {
        HybridMultiMonitor instance = HybridMultiMonitor.getInstance();
        m.LIZ((Object) instance, "");
        AbstractC63422eh hybridSettingManager = instance.getHybridSettingManager();
        m.LIZ((Object) hybridSettingManager, "");
        JYI LIZ2 = hybridSettingManager.LIZIZ().LIZ(str);
        m.LIZ((Object) LIZ2, "");
        return LIZ2;
    }

    public final String LIZ(Object obj) {
        if (obj instanceof JYQ) {
            return LIZ((Map<String, ? extends Object>) ((JYQ) obj).LIZIZ());
        }
        if (!(obj instanceof C49267JWe)) {
            return "";
        }
        C49267JWe jWe = (C49267JWe) obj;
        if (TextUtils.isEmpty(jWe.LIZIZ)) {
            return LIZ(jWe.LJIIL);
        }
        String str = jWe.LIZIZ;
        m.LIZ((Object) str, "");
        return str;
    }

    public final void LIZ(C49267JWe jWe) {
        LIZJ.submit(new JYE(jWe));
    }

    public final void LIZ(JYQ jyq, AbstractC49317JYc jYc) {
        LIZJ.submit(new JYH(jyq, jYc));
    }

    public final void LIZ(AbstractC49317JYc jYc, JSONObject jSONObject, String str, String str2) {
        if (jSONObject != null && str != null && str2 != null) {
            JSONObject jSONObject2 = new JSONObject();
            C74802x3.LIZ(jSONObject2, "extra", jSONObject);
            String LIZ2 = LIZ(str, jSONObject);
            C74012vm r9 = C74012vm.LIZ;
            C21090sc.LIZ(str, LIZ2);
            AnonymousClass2ZL.LIZIZ("DoubleReportChecker", "reportSampleCaseBeforeSend eventName:" + str + ", bid:" + LIZ2);
            if (!TextUtils.isEmpty(str)) {
                if (!JYG.LIZJ(LIZ2)) {
                    AnonymousClass2ZL.LIZJ("DoubleReportChecker", "reportSampleCaseBeforeSend bid:" + LIZ2 + " not hit");
                } else {
                    JSONObject jSONObject3 = new JSONObject();
                    C74802x3.LIZ(jSONObject3, "event_name", str);
                    C74802x3.LIZ(jSONObject3, "bid", LIZ2);
                    r9.LIZ("hybridmonitor_report_sample_before_send", jSONObject3);
                }
            }
            if (jYc != null) {
                try {
                    AnonymousClass2ZL.LIZIZ("DataReporter", "use another ".concat(String.valueOf(jYc)));
                    jYc.LIZ("bd_hybrid_monitor_service_all_in_one", jSONObject2);
                } catch (Throwable th) {
                    C63302eV.LIZ(th);
                    return;
                }
            } else {
                AnonymousClass0FY.LIZ("bd_hybrid_monitor_service_all_in_one", (JSONObject) null, (JSONObject) null, jSONObject2);
            }
            String LIZ3 = LIZ(str, jSONObject);
            if (JYS.LIZ("monitor_validation_switch")) {
                C96283qb r5 = C96283qb.LIZIZ;
                C21090sc.LIZ(str, LIZ3, str2, jSONObject2);
                JSONObject jSONObject4 = new JSONObject();
                C74802x3.LIZ(jSONObject4, "module", "monitor");
                C74802x3.LIZ(jSONObject4, "body", jSONObject2);
                C74802x3.LIZ(jSONObject4, "ev_type", str);
                C74802x3.LIZ(jSONObject4, "timestamp", System.currentTimeMillis());
                C74802x3.LIZ(jSONObject4, "hit_sample", (Object) true);
                C48786JDr jDr = C96283qb.LIZ;
                C74802x3.LIZ(jSONObject4, "device_id", jDr != null ? jDr.LJFF : null);
                C48786JDr jDr2 = C96283qb.LIZ;
                C74802x3.LIZ(jSONObject4, "os", jDr2 != null ? jDr2.LIZJ : null);
                C74802x3.LIZ(jSONObject4, "container_name", r5.LIZ("container_name", str, jSONObject2));
                C74802x3.LIZ(jSONObject4, "container_type", str2);
                C74802x3.LIZ(jSONObject4, "url", r5.LIZ("url", str, jSONObject2));
                C74802x3.LIZ(jSONObject4, "bid", LIZ3);
                C48786JDr jDr3 = C96283qb.LIZ;
                C74802x3.LIZ(jSONObject4, "aid", jDr3 != null ? jDr3.LIZ : null);
                C74802x3.LIZ(jSONObject4, "sdk_version", "1.5.0-rc.0");
                C74802x3.LIZ(jSONObject4, "sdk_name", "Android Hybrid Monitor");
                String jSONObject5 = jSONObject4.toString();
                m.LIZ((Object) jSONObject5, "");
                r5.LIZ(jSONObject5);
            }
            HybridMultiMonitor.getInstance().notifyReportInterceptor("bd_hybrid_monitor_service_all_in_one", str, str2, jSONObject2);
            if (!m.LIZ((Object) "jsbPerf", (Object) str) && !m.LIZ((Object) "custom", (Object) str)) {
                Object[] objArr = new Object[3];
                objArr[0] = str;
                objArr[1] = str2;
                String jSONObject6 = jSONObject2.toString();
                m.LIZ((Object) jSONObject6, "");
                if (jSONObject6.length() > 500) {
                    if (jSONObject6 != null) {
                        jSONObject6 = jSONObject6.substring(0, LiveMaxRetainAlogMessageSizeSetting.DEFAULT);
                        m.LIZ((Object) jSONObject6, "");
                    } else {
                        throw new C23830x2("null cannot be cast to non-null type java.lang.String");
                    }
                }
                objArr[2] = jSONObject6;
                String LIZ4 = AnonymousClass0EJ.LIZ("report: event:%s container:%s data:%s", Arrays.copyOf(objArr, 3));
                m.LIZ((Object) LIZ4, "");
                AnonymousClass2ZL.LIZIZ("DataReporter", LIZ4);
            }
        }
    }

    public final boolean LIZ(Object obj, JYI jyi) {
        if (obj instanceof JYQ) {
            JYQ jyq = (JYQ) obj;
            String LJIIIZ = jyq.LJIIIZ();
            if (LJIIIZ != null) {
                int hashCode = LJIIIZ.hashCode();
                if (hashCode != 117588) {
                    if (hashCode == 3337239 && LJIIIZ.equals("lynx")) {
                        return JYG.LIZ(jyq.LJIIIIZZ(), jyi);
                    }
                } else if (LJIIIZ.equals("web")) {
                    return JYG.LIZIZ(jyq.LJIIIIZZ(), jyi);
                }
            }
            return JYG.LIZJ(jyq.LJIIIIZZ(), jyi);
        } else if (!(obj instanceof C49267JWe)) {
            return false;
        } else {
            C49267JWe jWe = (C49267JWe) obj;
            String str = jWe.LIZIZ;
            String str2 = jWe.LIZJ;
            if (TextUtils.isEmpty(str2)) {
                return false;
            }
            if (JYG.LIZ(str, str2) == 1) {
                String LIZ2 = AnonymousClass0EJ.LIZ("bid: %s, event: %s, sample hit", Arrays.copyOf(new Object[]{str, str2}, 2));
                m.LIZ((Object) LIZ2, "");
                AnonymousClass2ZL.LIZIZ("DataReporter", LIZ2);
                return true;
            } else if (JYG.LIZ(str, str2) == 0) {
                String LIZ3 = AnonymousClass0EJ.LIZ("bid: %s, event: %s, sample not hit", Arrays.copyOf(new Object[]{str, str2}, 2));
                m.LIZ((Object) LIZ3, "");
                AnonymousClass2ZL.LIZIZ("DataReporter", LIZ3);
                return false;
            } else {
                String LIZ4 = AnonymousClass0EJ.LIZ("bid: %s, event: %s, sample not found, checking all...", Arrays.copyOf(new Object[]{str, str2}, 2));
                m.LIZ((Object) LIZ4, "");
                AnonymousClass2ZL.LIZIZ("DataReporter", LIZ4);
                String str3 = jWe.LIZJ;
                if (JYG.LIZIZ(str3) == 1) {
                    String LIZ5 = AnonymousClass0EJ.LIZ("event: %s, sample hit", Arrays.copyOf(new Object[]{str3}, 1));
                    m.LIZ((Object) LIZ5, "");
                    AnonymousClass2ZL.LIZIZ("DataReporter", LIZ5);
                    return true;
                } else if (JYG.LIZIZ(str3) == 0) {
                    String LIZ6 = AnonymousClass0EJ.LIZ("event: %s, sample not hit", Arrays.copyOf(new Object[]{str3}, 1));
                    m.LIZ((Object) LIZ6, "");
                    AnonymousClass2ZL.LIZIZ("DataReporter", LIZ6);
                    return false;
                } else {
                    String LIZ7 = AnonymousClass0EJ.LIZ("event: %s, sample not found, checking canSample level...", Arrays.copyOf(new Object[]{str3}, 1));
                    m.LIZ((Object) LIZ7, "");
                    AnonymousClass2ZL.LIZIZ("DataReporter", LIZ7);
                    HybridMultiMonitor instance = HybridMultiMonitor.getInstance();
                    m.LIZ((Object) instance, "");
                    AbstractC63422eh hybridSettingManager = instance.getHybridSettingManager();
                    m.LIZ((Object) hybridSettingManager, "");
                    C63412eg LIZIZ2 = hybridSettingManager.LIZIZ();
                    m.LIZ((Object) LIZIZ2, "");
                    JYI LIZ8 = LIZIZ2.LIZ(jWe.LIZIZ);
                    if (LIZ8 == null) {
                        return false;
                    }
                    return JYG.LIZ(LIZ8, jWe.LJIILJJIL);
                }
            }
        }
    }

    public final String LIZIZ(String str) {
        String str2;
        String str3 = "";
        if (str == null || AnonymousClass1ZS.LIZ(str)) {
            return str3;
        }
        Matcher matcher = Pattern.compile("[?&]bd_hybrid_monitor_bid=([^&#]+)").matcher(str);
        if (matcher.find()) {
            String group = matcher.group(1);
            m.LIZ((Object) group, str3);
            int length = group.length() - 1;
            int i2 = 0;
            boolean z = false;
            while (i2 <= length) {
                boolean z2 = group.charAt(!z ? i2 : length) <= ' ';
                if (z) {
                    if (!z2) {
                        break;
                    }
                    length--;
                } else if (!z2) {
                    z = true;
                } else {
                    i2++;
                }
            }
            str2 = group.subSequence(i2, length + 1).toString();
        } else {
            str2 = str3;
        }
        if (TextUtils.isEmpty(str2)) {
            C49356JZp jZp = C49356JZp.LIZIZ;
            HybridMultiMonitor instance = HybridMultiMonitor.getInstance();
            m.LIZ((Object) instance, str3);
            AbstractC63422eh hybridSettingManager = instance.getHybridSettingManager();
            m.LIZ((Object) hybridSettingManager, str3);
            List<C63432ei> LIZLLL2 = hybridSettingManager.LIZLLL();
            C21090sc.LIZ(str);
            if (LIZLLL2 != null && !LIZLLL2.isEmpty()) {
                String str4 = C49356JZp.LIZ.get(str);
                if (str4 == null) {
                    C21090sc.LIZ(str, LIZLLL2);
                    Iterator<T> it = LIZLLL2.iterator();
                    while (true) {
                        if (!it.hasNext()) {
                            break;
                        }
                        T next = it.next();
                        if (next.LIZIZ.containsMatchIn(str)) {
                            System.out.print((Object) (next.LIZIZ + " match " + next.LIZ));
                            if (next != null) {
                                C49356JZp.LIZ.put(str, next.LIZ);
                                str3 = next.LIZ;
                            }
                        }
                    }
                } else {
                    System.out.println((Object) "hit cache: ".concat(String.valueOf(str4)));
                    str3 = str4;
                }
            }
            str2 = str3;
        }
        AnonymousClass2ZL.LIZIZ("DataReporter", "regexMatcher: ".concat(String.valueOf(str2)));
        return str2;
    }

    public final void LIZIZ(AbstractC49317JYc jYc, JSONObject jSONObject, String str, String str2) {
        JYN jyn = LIZIZ;
        C21090sc.LIZ(jSONObject, str, str2);
        String str3 = "custom";
        if (!TextUtils.equals(str3, str)) {
            str3 = str2 + '_' + str + '_' + C74802x3.LIZJ(C74802x3.LIZLLL(jSONObject, "nativeBase"), "navigation_id");
        }
        if (!jyn.LIZ.containsKey(str) || !TextUtils.equals(str3, jyn.LIZIZ)) {
            jyn.LIZ();
            LIZ.LIZ(jYc, jSONObject, str, str2);
        } else {
            AbstractC49316JYb jYb = jyn.LIZ.get(str);
            if (jYb != null) {
                if (jYb.LIZ(jyn.LIZJ, jSONObject)) {
                    jyn.LIZLLL++;
                } else {
                    jyn.LIZ();
                    LIZ.LIZ(jYc, jSONObject, str, str2);
                }
            }
        }
        jyn.LJI = jYc;
        jyn.LIZJ = jSONObject;
        jyn.LJ = str;
        jyn.LJFF = str2;
    }

    public final AtomicLong LIZJ(String str) {
        ConcurrentHashMap<String, AtomicLong> concurrentHashMap = LIZLLL;
        AtomicLong atomicLong = concurrentHashMap.get(str);
        if (atomicLong != null) {
            return atomicLong;
        }
        AtomicLong atomicLong2 = new AtomicLong();
        concurrentHashMap.put(str, atomicLong2);
        return atomicLong2;
    }
}