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


package X;

import android.content.Context;
import android.text.TextUtils;
import com.bytedance.covode.number.Covode;
import com.bytedance.framwork.core.sdkmonitor.SDKMonitorUtils;
import com.ss.android.ttve.monitor.IMonitor;
import com.ss.android.ttve.monitor.TEMonitorInvoker;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;

/* renamed from: X.2Yo  reason: invalid class name and case insensitive filesystem */
public final class C60132Yo {
    public static int LIZ;
    public static int LIZIZ = 1;
    public static WeakReference<IMonitor> LIZJ;
    public static boolean LIZLLL = true;
    public static String LJ = "";

    static {
        Covode.recordClassIndex(42964);
    }

    public static int LIZ(JSONObject jSONObject) {
        try {
            if (jSONObject.has("completed")) {
                return jSONObject.getInt("completed");
            }
            return 0;
        } catch (JSONException e) {
            EVH.LIZLLL("TEMonitor", "get complete filed error!");
            e.printStackTrace();
            return 0;
        }
    }

    public static void LIZ(int i2) {
        if (i2 == 0) {
            LIZ(0, "te_record_err_code", 0L);
        } else if (i2 == 1) {
            LIZ(1, "te_edit_err_code", 0L);
            LIZ(1, "te_composition_err_code", 0L);
        }
    }

    public static void LIZ(int i2, String str, double d) {
        if (TextUtils.isEmpty(str)) {
            EVH.LIZJ("TEMonitor", "perfDouble: key is null");
        } else {
            TEMonitorInvoker.nativePerfDouble(i2, str, d);
        }
    }

    public static void LIZ(int i2, String str, long j) {
        if (!TextUtils.isEmpty(str)) {
            TEMonitorInvoker.nativePerfLong(i2, str, j);
        }
    }

    public static void LIZ(int i2, String str, String str2) {
        if (TextUtils.isEmpty(str)) {
            EVH.LIZJ("TEMonitor", "perfString: key is null");
            return;
        }
        if (str2 == null) {
            str2 = "";
        }
        TEMonitorInvoker.nativePerfString(i2, str, str2);
    }

    public static void LIZ(Context context, String str) {
        TEMonitorInvoker.nativeInit();
        Context applicationContext = context.getApplicationContext();
        if (C16360kz.LIZJ && applicationContext == null) {
            applicationContext = C16360kz.LIZ;
        }
        if (C527526e.LIZ) {
            SDKMonitorUtils.LIZ("1357", new ArrayList(Arrays.asList("https://mon-sg.tiktokv.com/monitor/appmonitor/v2/settings", "https://mon.tiktokv.com/monitor/appmonitor/v2/settings", "https://mon.tiktokv.com/monitor/appmonitor/v2/settings")));
            SDKMonitorUtils.LIZIZ("1357", new ArrayList(Arrays.asList("https://mon-sg.tiktokv.com/monitor/collect/", "https://mon-sg.tiktokv.com/monitor/collect/", "https://mon-sg.tiktokv.com/monitor/collect/", "https://mon-sg.tiktokv.com/monitor/collect/")));
            if (!C527526e.LJ) {
                C527826h.LIZ(applicationContext, str, null, null);
                C527526e.LIZJ = true;
            } else if (!C527526e.LIZJ && C527526e.LIZIZ == null) {
                Thread thread = new Thread(new RunnableC528026j(applicationContext, str));
                C527526e.LIZIZ = thread;
                thread.start();
            }
        }
    }

    public static void LIZ(String str, double d) {
        if (TextUtils.isEmpty(str)) {
            EVH.LIZJ("TEMonitor", "perfDouble: key is null");
        } else {
            TEMonitorInvoker.nativePerfDouble(str, d);
        }
    }

    public static void LIZ(String str, long j) {
        if (TextUtils.isEmpty(str)) {
            EVH.LIZJ("TEMonitor", "perfLong: key is null");
        } else {
            TEMonitorInvoker.nativePerfLong(str, j);
        }
    }

    public static void LIZ(String str, Map map, JSONObject jSONObject) {
        for (String str2 : map.keySet()) {
            int LIZ2 = (str.equals("iesve_veeditor_record_finish") || str.equals("iesve_veeditor_composition_finish") || str.equals("iesve_veeditor_edit") || str.equals("iesve_veeditor_cut")) ? EJS.LIZ(str2) : EJS.LIZ(str2);
            if (LIZ2 == 1) {
                try {
                    jSONObject.put(str2, Integer.parseInt(String.valueOf(map.get(str2))));
                } catch (Exception unused) {
                    EVH.LIZLLL("TEMonitor", "Parse int error:" + map.get(str2));
                }
            } else if (LIZ2 == 2) {
                try {
                    jSONObject.put(str2, (double) Float.parseFloat(String.valueOf(map.get(str2))));
                } catch (Exception unused2) {
                    EVH.LIZLLL("TEMonitor", "Parse float error");
                }
            } else {
                jSONObject.put(str2, map.get(str2));
            }
        }
    }

    public static void LIZ(Map map, JSONObject jSONObject) {
        for (String str : map.keySet()) {
            str.startsWith("iesve_");
            int LIZ2 = EJS.LIZ(str);
            if (LIZ2 == 1) {
                try {
                    jSONObject.put(str, Integer.parseInt(String.valueOf(map.get(str))));
                } catch (Exception unused) {
                    EVH.LIZLLL("TEMonitor", "Parse int error:" + map.get(str));
                }
            } else if (LIZ2 == 2) {
                try {
                    jSONObject.put(str, (double) Float.parseFloat(String.valueOf(map.get(str))));
                } catch (Exception unused2) {
                    EVH.LIZLLL("TEMonitor", "Parse float error");
                }
            } else {
                jSONObject.put(str, map.get(str));
            }
        }
    }

    public static boolean LIZ(String str, String str2, float f) {
        HashMap hashMap = new HashMap();
        hashMap.put(str2, Float.valueOf(f));
        return LIZ(str, str2, hashMap);
    }

    public static boolean LIZ(String str, String str2, long j) {
        HashMap hashMap = new HashMap();
        hashMap.put(str2, Long.valueOf(j));
        return LIZ(str, str2, hashMap);
    }

    public static boolean LIZ(String str, String str2, Map map) {
        return LIZ(LIZJ, str, str2, map);
    }

    public static boolean LIZ(WeakReference<IMonitor> weakReference, String str, String str2, Map map) {
        if (!LIZLLL) {
            return LIZ(weakReference, str2, map);
        }
        JSONObject jSONObject = new JSONObject();
        try {
            if (!TextUtils.isEmpty(str2)) {
                jSONObject.put("service", str2);
            }
            if (str2.equals("iesve_veeditor_record_finish") || str2.equals("iesve_veeditor_composition_finish") || str2.equals("iesve_veeditor_edit") || str2.equals("iesve_veeditor_cut") || str2.equals("iesve_veeditor_frame_report")) {
                LIZ(str2, map, jSONObject);
            } else {
                LIZ(map, jSONObject);
            }
            LIZIZ(weakReference, str, jSONObject);
            return true;
        } catch (JSONException unused) {
            EVH.LIZIZ("TEMonitor", "No monitor callback, skip");
            return false;
        }
    }

    public static boolean LIZ(WeakReference<IMonitor> weakReference, String str, Map map) {
        if (weakReference == null || weakReference.get() == null) {
            EVH.LIZLLL("TEMonitor", "monitorEventToBusiness business monitor invalid");
            return false;
        } else if (TextUtils.isEmpty(str) || map == null) {
            EVH.LIZLLL("TEMonitor", "monitorEventToBusiness param invalid");
            return false;
        } else {
            JSONObject jSONObject = new JSONObject();
            try {
                LIZ(map, jSONObject);
                return LIZ(weakReference, str, jSONObject);
            } catch (JSONException e) {
                EVH.LIZLLL("TEMonitor", "monitorEventToBusiness json err: ".concat(String.valueOf(e)));
                return false;
            }
        }
    }

    public static boolean LIZ(WeakReference<IMonitor> weakReference, String str, JSONObject jSONObject) {
        if (weakReference == null || weakReference.get() == null) {
            EVH.LIZLLL("TEMonitor", "monitorEventJsonToBusiness business monitor invalid");
            return false;
        } else if (TextUtils.isEmpty(str) || jSONObject == null) {
            EVH.LIZLLL("TEMonitor", "monitorEventJsonToBusiness param invalid");
            return false;
        } else {
            try {
                weakReference.get().monitorLog(str, jSONObject);
                return true;
            } catch (Exception e) {
                EVH.LIZLLL("TEMonitor", "Something happened when monitor log: ".concat(String.valueOf(e)));
                return true;
            }
        }
    }

    public static void LIZIZ(WeakReference<IMonitor> weakReference, String str, JSONObject jSONObject) {
        int i2;
        String str2 = "sdk_video_edit_compose";
        if (jSONObject != null) {
            i2 = LIZ(jSONObject);
            try {
                if (jSONObject.has("service")) {
                    str2 = jSONObject.getString("service");
                }
                if (str2.equals("iesve_veeditor_record_finish") || str2.equals("iesve_veeditor_composition_finish")) {
                    if ("".equals(LJ)) {
                        LJ = C527526e.LIZ("device_id") + "_" + System.currentTimeMillis();
                    }
                    jSONObject.put("te_record_compose_vid", LJ);
                }
                if (str2.equals("iesve_veeditor_composition_finish")) {
                    LJ = "";
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        } else {
            i2 = 0;
        }
        C527526e.LIZ(str2, i2, jSONObject);
        if (weakReference != null && weakReference.get() != null) {
            try {
                weakReference.get().monitorLog(str, jSONObject);
            } catch (Exception unused) {
            }
        }
    }
}