package com.ss.android.ugc.aweme.bullet.bridge.ad;

import X.0CB;
import X.0CH;
import X.2kf;
import X.4UQ;
import X.6Is;
import X.C0984KOx;
import X.C1157KVo;
import X.C2276KqB;
import X.C2277KqC;
import X.C2334Kr7;
import X.KT7;
import X.M12;
import X.TSt;
import android.os.Bundle;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.bullet.bridge.BaseBridgeMethod;
import org.json.JSONArray;
import org.json.JSONObject;

public final class AdInfoMethod extends BaseBridgeMethod implements 6Is {
    public static final C2334Kr7 LIZIZ = new C2334Kr7((byte) 0);

    static {
        Covode.recordClassIndex(54899);
    }

    public final String LIZLLL() {
        return "adInfo";
    }

    public final void onStateChanged(0CH r1, 0CB r2) {
        super.onStateChanged(r1, r2);
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public AdInfoMethod(KT7 kt7) {
        super(kt7);
        M12.LIZ((Object) kt7);
    }

    public final void LIZ(JSONObject jSONObject, 4UQ r20) {
        C1157KVo kVo;
        C2277KqC kqC;
        int i;
        int i2;
        int i3;
        JSONObject jSONObject2 = jSONObject;
        4UQ r17 = r20;
        M12.LIZ((Object) jSONObject2, (Object) r17);
        JSONObject jSONObject3 = new JSONObject(jSONObject2.toString());
        C0984KOx LJI = LJI();
        if (LJI != null) {
            kVo = LJI.E_();
        } else {
            kVo = null;
        }
        if (!(kVo instanceof C2276KqB)) {
            kVo = null;
        }
        C2276KqB kqB = (C2276KqB) kVo;
        C0984KOx LJI2 = LJI();
        if (LJI2 != null) {
            kqC = (C2277KqC) LJI2.LIZ(C2277KqC.class);
        } else {
            kqC = null;
        }
        if (kqB != null) {
            jSONObject3.put("cid", kqB.LJJJJLL.LIZIZ());
            jSONObject3.put("group_id", kqB.LJII());
            jSONObject3.put("ad_type", kqB.LJJJJZ.LIZIZ());
            jSONObject3.put("log_extra", kqB.LIZJ());
            jSONObject3.put("download_url", kqB.LJJLIIIIJ.LIZIZ());
            jSONObject3.put("package_name", kqB.LJJLIIIJILLIZJL.LIZIZ());
            jSONObject3.put("app_name", kqB.LJJLIIIJ.LIZIZ());
            Long l = (Long) kqB.LJJJJLL.LIZIZ();
            if (l != null && l.longValue() == 0) {
                i3 = 0;
            } else {
                i3 = 1;
            }
            jSONObject3.put("code", i3);
            jSONObject3.put("land_page_data", kqB.LJLIL);
            jSONObject3.put("extra_param", kqB.LJLILLLLZI);
            Long l2 = (Long) kqB.LJJJJLL.LIZIZ();
            if (l2 != null) {
                l2.longValue();
            }
            kqB.LIZJ();
        } else if (kqC != null) {
            jSONObject3.put("cid", kqC.LIZIZ());
            jSONObject3.put("group_id", kqC.LIZJ());
            jSONObject3.put("ad_type", kqC.LJJJJ.LIZIZ());
            jSONObject3.put("log_extra", kqC.LIZLLL());
            jSONObject3.put("download_url", kqC.LJ());
            jSONObject3.put("package_name", kqC.LJFF());
            jSONObject3.put("app_name", kqC.LJI());
            if (kqC.LIZIZ() == 0) {
                i2 = 0;
            } else {
                i2 = 1;
            }
            jSONObject3.put("code", i2);
            jSONObject3.put("land_page_data", kqC.LJJLIIIJJI);
            jSONObject3.put("extra_param", kqC.LJJLIIJ);
            try {
                String LIZIZ2 = kqC.LJJJZ.LIZIZ();
                if (LIZIZ2 == null) {
                    LIZIZ2 = "";
                }
                jSONObject3.put("track_url_list", new JSONArray(LIZIZ2));
            } catch (Exception e) {
                TSt.LIZ(e);
            }
            kqC.LIZIZ();
            kqC.LIZLLL();
        } else if (this.LIZ.LIZJ(Bundle.class) != null) {
            Bundle bundle = (Bundle) this.LIZ.LIZJ(Bundle.class);
            if (bundle != null) {
                jSONObject3.put("cid", bundle.getLong("ad_id"));
                jSONObject3.put("group_id", bundle.getString("aweme_group_id"));
                jSONObject3.put("ad_type", bundle.getInt("ad_system_origin"));
                jSONObject3.put("log_extra", bundle.getString("bundle_download_app_log_extra"));
                jSONObject3.put("download_url", bundle.getString("bundle_download_url"));
                jSONObject3.put("package_name", bundle.getString("aweme_package_name"));
                jSONObject3.put("app_name", bundle.getString("bundle_download_app_name"));
                if (bundle.getLong("ad_id") == 0) {
                    i = 0;
                } else {
                    i = 1;
                }
                jSONObject3.put("code", i);
                jSONObject3.put("land_page_data", bundle.getString("landing_page_info"));
                jSONObject3.put("extra_param", bundle.getString("bundle_extra_param"));
                try {
                    jSONObject3.put("track_url_list", new JSONArray(bundle.getString("track_url_list")));
                } catch (Exception e2) {
                    TSt.LIZ(e2);
                }
            } else {
                return;
            }
        } else {
            2kf.LIZIZ(3, (String) null, "It is illegal to call adInfo in non-commercialized scenarios, please chat with zhangxiang.aaron privately");
        }
        r17.LIZ(jSONObject3);
    }
}
