翰林优商.apk(点击下载) / c.java


package com.bytedance.sdk.openadsdk.api.plugin;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import com.bytedance.sdk.openadsdk.AdConfig;
import com.bytedance.sdk.openadsdk.TTAdManager;
import com.bytedance.sdk.openadsdk.TTAdSdk;
import com.bytedance.sdk.openadsdk.TTCustomController;
import com.bytedance.sdk.openadsdk.api.plugin.b.b;
import com.bytedance.sdk.openadsdk.api.plugin.e;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* access modifiers changed from: package-private */
/* compiled from: PluginReporter */
public final class c {
    static final Map<String, String> a = new HashMap();
    private static ScheduledExecutorService b = Executors.newSingleThreadScheduledExecutor(new e.a("tt_pangle_thread_pl_report"));
    private static SharedPreferences c;
    private static final List<JSONObject> d = new ArrayList();
    private static volatile boolean e = false;

    public static void a(Context context) {
        c = context.getSharedPreferences("tt_sdk_settings", 0);
    }

    public static final void a(int i, String str, long j) {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.putOpt("duration", Long.valueOf(j));
            jSONObject.putOpt(PluginConstants.KEY_ERROR_CODE, Integer.valueOf(i));
            jSONObject.putOpt("message", str);
        } catch (JSONException e2) {
            e2.printStackTrace();
        }
        c("plugin_load_failed", jSONObject);
    }

    public static void a(String str, JSONObject jSONObject) {
        c("zeus_" + str, jSONObject);
    }

    public static void a() {
        if (!e) {
            try {
                e = true;
                b.shutdown();
            } catch (Throwable unused) {
            }
        }
    }

    private static void c(String str, JSONObject jSONObject) {
        if (jSONObject != null) {
            TTAdManager adManager = TTAdSdk.getAdManager();
            if (adManager != null) {
                Bundle bundle = new Bundle();
                bundle.putInt("action", 1);
                bundle.putString("event_name", str);
                bundle.putString("event_extra", jSONObject.toString());
                adManager.getExtra(Bundle.class, bundle);
                return;
            }
            a(d(str, jSONObject));
        }
    }

    public static void a(final List<JSONObject> list) {
        if (e) {
            return;
        }
        if (list == null || !list.isEmpty() || !d.isEmpty()) {
            b.execute(new Runnable() {
                /* class com.bytedance.sdk.openadsdk.api.plugin.c.AnonymousClass1 */

                public void run() {
                    c.c(list);
                }
            });
        }
    }

    private static List<JSONObject> d(String str, JSONObject jSONObject) {
        ArrayList arrayList = new ArrayList();
        arrayList.add(e(str, jSONObject));
        return arrayList;
    }

    private static JSONObject e(String str, JSONObject jSONObject) {
        JSONObject jSONObject2 = new JSONObject();
        try {
            jSONObject.put("os_api", Build.VERSION.SDK_INT);
            jSONObject.put("support_abi", Arrays.toString(Build.VERSION.SDK_INT >= 21 ? Build.SUPPORTED_ABIS : new String[]{Build.CPU_ABI, Build.CPU_ABI2}));
            jSONObject2.put("ad_sdk_version", "4.4.0.2");
            jSONObject2.put("plugin_version", "4.4.0.2");
            jSONObject2.put("timestamp", System.currentTimeMillis() / 1000);
            jSONObject2.put("is_plugin", true);
            jSONObject2.put("event_extra", jSONObject.toString());
            jSONObject2.put("type", str);
            JSONObject jSONObject3 = new JSONObject();
            jSONObject3.put("model", Build.MODEL);
            jSONObject3.put("vendor", Build.MANUFACTURER);
            Map<String, String> map = a;
            jSONObject3.put("imei", map.get("imei"));
            jSONObject3.put("oaid", map.get("oaid"));
            jSONObject2.put("device_info", jSONObject3);
        } catch (JSONException unused) {
        }
        return jSONObject2;
    }

    public static void b(String str, JSONObject jSONObject) {
        d.add(e(str, jSONObject));
    }

    /* access modifiers changed from: private */
    public static void c(List<JSONObject> list) {
        if (list != null) {
            String str = "pangolin.snssdk.com";
            SharedPreferences sharedPreferences = c;
            if (sharedPreferences != null) {
                str = sharedPreferences.getString("url_alog", str);
            }
            String format = String.format("https://%s%s", str, "/api/ad/union/sdk/stats/batch/");
            JSONObject jSONObject = new JSONObject();
            try {
                List<JSONObject> list2 = d;
                if (list2.size() > 0) {
                    list.addAll(list2);
                }
                jSONObject.put("stats_list", new JSONArray((Collection) list));
            } catch (JSONException unused) {
            }
            com.bytedance.sdk.openadsdk.api.plugin.a.c.a().a(true, format, b.a(jSONObject).toString().getBytes());
            d.clear();
        }
    }

    public static void a(final Bundle bundle) {
        if (!e) {
            b.execute(new Runnable() {
                /* class com.bytedance.sdk.openadsdk.api.plugin.c.AnonymousClass2 */

                public void run() {
                    c.b(bundle);
                }
            });
        }
    }

    public static void b(Bundle bundle) {
        if (bundle != null) {
            try {
                String string = bundle.getString("event_name");
                String string2 = bundle.getString("event_extra");
                c(d(string, TextUtils.isEmpty(string2) ? new JSONObject() : new JSONObject(string2)));
            } catch (Exception unused) {
            }
        }
    }

    public static void a(AdConfig adConfig) {
        if (adConfig != null) {
            Map<String, String> map = a;
            map.put("appid", adConfig.getAppId());
            Object extra = adConfig.getExtra("plugin_update_conf");
            if (extra instanceof Integer) {
                String num = ((Integer) extra).toString();
                if (num == null) {
                    num = "2";
                }
                map.put("plugin_update_conf", num);
            }
            TTCustomController customController = adConfig.getCustomController();
            if (customController != null) {
                try {
                    map.put("oaid", customController.getDevOaid());
                    map.put("imei", customController.getDevImei());
                } catch (Exception unused) {
                }
            }
        }
    }
}