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

import X.0CB;
import X.0CH;
import X.2UX;
import X.2nK;
import X.4UQ;
import X.6Is;
import X.C6411HzA;
import X.JZx;
import X.KT7;
import X.M12;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.bullet.bridge.BaseBridgeMethod;
import org.json.JSONObject;

public final class OpenScanMethod extends BaseBridgeMethod implements 6Is {
    public static final C6411HzA LIZIZ = new C6411HzA((byte) 0);
    public final String LIZJ = "scan";

    static {
        Covode.recordClassIndex(55050);
    }

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

    public final String LIZLLL() {
        return this.LIZJ;
    }

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

    public final void LIZ(JSONObject jSONObject, 4UQ r7) {
        Context LJ;
        M12.LIZ(jSONObject, r7);
        2UX r2 = new 2UX();
        r2.LIZ("enter_from", "h5");
        2nK.LIZ("qr_code_scan_enter", r2.LIZ);
        JSONObject jSONObject2 = null;
        if (jSONObject.has("args")) {
            jSONObject2 = jSONObject.getJSONObject("args");
        }
        Context LJ2 = LJ();
        if (LJ2 != null) {
            JZx.LIZ.LIZ(LJ2, false, -1);
        }
        if (jSONObject2 != null && jSONObject2.has("should_close_self") && jSONObject2.getBoolean("should_close_self") && (LJ = LJ()) != null) {
            while (true) {
                if (!(LJ instanceof Activity)) {
                    if (LJ instanceof ContextWrapper) {
                        LJ = ((ContextWrapper) LJ).getBaseContext();
                        if (LJ == null) {
                            break;
                        }
                    } else {
                        break;
                    }
                } else {
                    Activity activity = (Activity) LJ;
                    if (activity != null) {
                        activity.finish();
                    }
                }
            }
        }
        JSONObject jSONObject3 = new JSONObject();
        jSONObject3.put("code", 1);
        r7.LIZ(jSONObject3);
    }
}
