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


package com.mbridge.msdk.mbjscommon.a;

import android.content.Context;
import android.text.TextUtils;
import android.util.Base64;
import com.bytedance.sdk.openadsdk.api.plugin.PluginConstants;
import com.mbridge.msdk.foundation.db.i;
import com.mbridge.msdk.foundation.db.t;
import com.mbridge.msdk.foundation.entity.DomainCampaignEx;
import com.mbridge.msdk.foundation.entity.p;
import com.mbridge.msdk.foundation.same.net.f.d;
import com.mbridge.msdk.foundation.same.report.d.b;
import com.mbridge.msdk.foundation.same.report.e;
import com.mbridge.msdk.foundation.tools.w;
import com.mbridge.msdk.mbjscommon.windvane.h;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* compiled from: H5ReportManager */
public class a {
    private static final String c = "a";
    int a = 0;
    int b = 1;
    private String d = "handlerNativeResult";

    /* renamed from: com.mbridge.msdk.mbjscommon.a.a$a  reason: collision with other inner class name */
    /* compiled from: H5ReportManager */
    private static final class C0215a {
        private static a a = new a();
    }

    public static a a() {
        return C0215a.a;
    }

    public final void a(Object obj, String str, JSONArray jSONArray, int i) {
        JSONObject optJSONObject;
        JSONObject optJSONObject2;
        JSONObject optJSONObject3;
        JSONObject optJSONObject4;
        JSONObject optJSONObject5;
        JSONObject optJSONObject6;
        JSONObject optJSONObject7;
        JSONObject optJSONObject8;
        JSONObject optJSONObject9;
        JSONObject optJSONObject10;
        JSONObject optJSONObject11;
        int i2;
        if (jSONArray == null) {
            try {
                a(this.b, "called reporter failed, params empty", obj);
            } catch (Throwable th) {
                w.a(c, th.getMessage());
                a(this.b, "exception: " + th.getMessage(), obj);
            }
        } else {
            int length = jSONArray.length();
            if (length == 0) {
                a(this.b, "called reporter failed, params empty", obj);
                return;
            }
            if ("reportMessageR".equalsIgnoreCase(str)) {
                StringBuffer stringBuffer = new StringBuffer();
                int i3 = 0;
                while (true) {
                    i2 = length - 1;
                    if (i3 >= i2) {
                        break;
                    }
                    JSONObject optJSONObject12 = jSONArray.optJSONObject(i3);
                    if (optJSONObject12 != null) {
                        stringBuffer.append(optJSONObject12.optString("key"));
                        stringBuffer.append("=");
                        stringBuffer.append(optJSONObject12.opt(DomainCampaignEx.LOOPBACK_VALUE));
                        stringBuffer.append("&");
                    }
                    i3++;
                }
                JSONObject optJSONObject13 = jSONArray.optJSONObject(i2);
                if (optJSONObject13 != null) {
                    stringBuffer.append(optJSONObject13.optString("key"));
                    stringBuffer.append("=");
                    stringBuffer.append(optJSONObject13.opt(DomainCampaignEx.LOOPBACK_VALUE));
                }
                String stringBuffer2 = stringBuffer.toString();
                Context j = com.mbridge.msdk.foundation.controller.a.f().j();
                if (j != null && !TextUtils.isEmpty(stringBuffer2)) {
                    try {
                        new com.mbridge.msdk.foundation.same.report.d.a(j).c(0, d.a().a, e.a(stringBuffer2, j), new b() {
                            /* class com.mbridge.msdk.mbjscommon.a.a.AnonymousClass1 */

                            @Override // com.mbridge.msdk.foundation.same.report.d.b
                            public final void a(String str) {
                                w.d(a.c, str);
                            }

                            @Override // com.mbridge.msdk.foundation.same.report.d.b
                            public final void b(String str) {
                                w.d(a.c, str);
                            }
                        });
                    } catch (Exception e) {
                        w.d(c, e.getMessage());
                    }
                }
            } else if ("reportMessageD".equalsIgnoreCase(str)) {
                String str2 = "";
                String string = (length <= 0 || (optJSONObject11 = jSONArray.optJSONObject(0)) == null) ? str2 : optJSONObject11.getString(DomainCampaignEx.LOOPBACK_VALUE);
                int i4 = (length <= 1 || (optJSONObject10 = jSONArray.optJSONObject(1)) == null) ? -1 : optJSONObject10.getInt(DomainCampaignEx.LOOPBACK_VALUE);
                int i5 = (length <= 2 || (optJSONObject9 = jSONArray.optJSONObject(2)) == null) ? -1 : optJSONObject9.getInt(DomainCampaignEx.LOOPBACK_VALUE);
                int i6 = (length <= 3 || (optJSONObject8 = jSONArray.optJSONObject(3)) == null) ? -1 : optJSONObject8.getInt(DomainCampaignEx.LOOPBACK_VALUE);
                int i7 = (length <= 4 || (optJSONObject7 = jSONArray.optJSONObject(4)) == null) ? -1 : optJSONObject7.getInt(DomainCampaignEx.LOOPBACK_VALUE);
                String string2 = (length <= 5 || (optJSONObject6 = jSONArray.optJSONObject(5)) == null) ? str2 : optJSONObject6.getString(DomainCampaignEx.LOOPBACK_VALUE);
                String string3 = (length <= 6 || (optJSONObject5 = jSONArray.optJSONObject(6)) == null) ? str2 : optJSONObject5.getString(DomainCampaignEx.LOOPBACK_VALUE);
                int i8 = (length <= 7 || (optJSONObject4 = jSONArray.optJSONObject(7)) == null) ? -1 : optJSONObject4.getInt(DomainCampaignEx.LOOPBACK_VALUE);
                String string4 = (length <= 8 || (optJSONObject3 = jSONArray.optJSONObject(8)) == null) ? str2 : optJSONObject3.getString(DomainCampaignEx.LOOPBACK_VALUE);
                int i9 = (length <= 9 || (optJSONObject2 = jSONArray.optJSONObject(9)) == null) ? -1 : optJSONObject2.getInt(DomainCampaignEx.LOOPBACK_VALUE);
                if (length > 10 && (optJSONObject = jSONArray.optJSONObject(10)) != null) {
                    str2 = optJSONObject.getString(DomainCampaignEx.LOOPBACK_VALUE);
                }
                try {
                    Context j2 = com.mbridge.msdk.foundation.controller.a.f().j();
                    if (j2 != null) {
                        t.a(i.a(j2)).a(new p(string, i4, i5, i6, i7, string2, string3, i8, string4, i9, str2));
                    }
                } catch (Throwable th2) {
                    w.a(c, th2.getMessage());
                }
            }
            a(this.a, "called reporter success", obj);
        }
    }

    private void a(int i, String str, Object obj) {
        try {
            JSONObject jSONObject = new JSONObject();
            jSONObject.put(PluginConstants.KEY_ERROR_CODE, i);
            jSONObject.put("message", str);
            h.a().a(obj, Base64.encodeToString(jSONObject.toString().getBytes(), 2));
        } catch (JSONException e) {
            w.a(c, e.getMessage());
        } catch (Throwable th) {
            w.a(c, th.getMessage());
        }
    }
}