QQ浏览器 v12.2.3.7053版本的 MD5 值为:8285ab3059e5c8b521a264dfbc5c3685

以下内容为反编译后的 g.java 源代码,内容仅作参考


package com.tencent.mm.plugin.appbrand.debugger;

import android.app.Activity;
import android.util.Log;
import android.util.Pair;
import android.webkit.ValueCallback;
import com.tencent.luggage.wxa.jl.e;
import com.tencent.luggage.wxa.ov.k;
import com.tencent.luggage.wxa.sb.cj;
import com.tencent.luggage.wxa.sb.ck;
import com.tencent.luggage.wxa.sb.kd;
import com.tencent.luggage.wxa.sb.kh;
import com.tencent.luggage.wxa.sb.kk;
import com.tencent.luggage.wxa.sb.ko;
import com.tencent.luggage.wxa.sb.kr;
import com.tencent.luggage.wxa.sb.ku;
import com.tencent.luggage.wxa.sb.kx;
import com.tencent.luggage.wxa.sb.ky;
import com.tencent.luggage.wxa.sb.la;
import com.tencent.luggage.wxa.sb.lb;
import com.tencent.luggage.wxa.sb.lc;
import com.tencent.luggage.wxa.sb.ld;
import com.tencent.luggage.wxa.sb.le;
import com.tencent.luggage.wxa.sb.li;
import com.tencent.luggage.wxa.se.ai;
import com.tencent.luggage.wxa.se.r;
import com.tencent.mm.plugin.appbrand.appstorage.n;
import com.tencent.mm.plugin.appbrand.debugger.m;
import com.tencent.mtt.video.browser.export.db.IVideoDbHelper;
import java.net.URL;
import java.nio.ByteBuffer;
import java.util.Iterator;
import org.json.JSONObject;

public class g implements com.tencent.luggage.wxa.od.i {

    private e f28244b;

    private String f28245c;

    private Activity f28246d;
    private k e;
    private com.tencent.luggage.wxa.ee.d g;
    private m h;
    private i f = new i();

    k.b f28243a = new k.b() {
        @Override
        public void a(int i, String str) {
            r.d("MicroMsg.RemoteDebugJsEngine", "onSocketClose code:%d reason:%s ", Integer.valueOf(i), str);
            if (g.this.f28244b.C()) {
                com.tencent.luggage.wxa.qg.l.a().a(new Runnable() {
                    @Override
                    public void run() {
                        g.this.e();
                    }
                }, 1000L);
                g.this.f28244b.E();
            }
            g.this.f.h();
            g.this.f28244b.q();
            g.this.h.h();
            g.this.f28244b.c(5);
            g.this.h.a(str);
        }

        @Override
        public void a(com.tencent.luggage.wxa.qr.h hVar) {
            r.d("MicroMsg.RemoteDebugJsEngine", "onSocketOpen");
            g.this.f28244b.q();
            g.this.f28244b.D();
            if (!ai.c(g.this.f28244b.c())) {
                g.this.f();
            }
            g.this.f.i();
        }

        @Override
        public void a(String str) {
            r.d("MicroMsg.RemoteDebugJsEngine", "onSocketError message:%s ", str);
            g.this.h.a(str);
        }

        @Override
        public void a(ByteBuffer byteBuffer) {
            g.this.f28244b.q();
            try {
                kd kdVar = (kd) new kd().a(com.tencent.luggage.wxa.qg.c.a(byteBuffer));
                if (kdVar.f25799c == null) {
                    r.c("MicroMsg.RemoteDebugJsEngine", "dataFormat.data is null");
                    return;
                }
                byte[] c2 = kdVar.f25799c.c();
                int i = kdVar.f25797a;
                if (i == 2006) {
                    g.this.f.a((ko) new ko().a(c2));
                } else if (i == 3001) {
                    g.this.i();
                } else if (i != 3002) {
                    switch (i) {
                        case 1001:
                            l.a(g.this.f28244b, kdVar, ((la) new la().a(c2)).f25853a, g.this.h, g.this.f);
                            g.this.f28244b.q();
                            break;
                        case 1002:
                            g.this.a((le) new le().a(c2), kdVar);
                            break;
                        case 1003:
                            if (l.a(g.this.f28244b, kdVar, ((lc) new lc().a(c2)).f25858a, g.this.h, g.this.f)) {
                                g.this.h();
                                break;
                            }
                            break;
                        case 1004:
                            if (!g.this.g.d()) {
                                g.this.f.f();
                                break;
                            } else {
                                g.this.f.e();
                                break;
                            }
                        case 1005:
                            g.this.f.a((li) new li().a(c2), kdVar);
                            break;
                        case 1006:
                            g.this.f.a((kx) new kx().a(c2), kdVar);
                            j.a(kdVar, g.this.f28244b.g().get(kdVar.f25798b));
                            break;
                    }
                } else {
                    g.this.f28244b.c(4);
                    g.this.f.d();
                }
                r.d("MicroMsg.RemoteDebugJsEngine", "onSocketMessage cmd: %d", Integer.valueOf(kdVar.f25797a));
            } catch (Throwable th) {
                r.b("MicroMsg.RemoteDebugJsEngine", "onSocketMessage %s", Log.getStackTraceString(th));
            }
        }

        @Override
        public void b(String str) {
            g.this.f28244b.q();
        }

        @Override
        public void c(String str) {
            r.d("MicroMsg.RemoteDebugJsEngine", "onSocketConnectFail reason:%s ", str);
        }
    };

    public g() {
        d();
    }

    private void a(int i, String str, ValueCallback<String> valueCallback) {
        a aVar = new a();
        if (ai.c(this.f28245c)) {
            aVar.f28231c = j.a(str);
        } else {
            aVar.f28231c = this.f28245c;
            this.f28245c = null;
        }
        aVar.f28230b = System.currentTimeMillis();
        aVar.f28232d = str.length();
        aVar.f28229a = valueCallback;
        this.f28244b.w().put(Integer.valueOf(i), aVar);
    }

    public void a(le leVar, kd kdVar) {
        if (l.a(this.f28244b, kdVar, leVar.f25861a, this.h, this.f)) {
            r.d("MicroMsg.RemoteDebugJsEngine", "onLogin");
            if (leVar.f25862b == null) {
                r.b("MicroMsg.RemoteDebugJsEngine", "onLogin room info is null");
            } else if (!leVar.f25862b.f25833a) {
                g();
            } else {
                this.f28244b.a(leVar.f25862b);
                i();
            }
        }
    }

    public void e() {
        if (this.e == null) {
            this.e = new k((com.tencent.luggage.wxa.ov.a) this.g.b(com.tencent.luggage.wxa.ov.a.class));
            this.f.a(this.e, this.f28244b, this.h);
        }
        if (!this.f28244b.G()) {
            this.e.a("wss://wxagame.weixin.qq.com/remote/", this.f28243a);
            return;
        }
        this.e.a("ws://localhost:" + this.f28244b.j().f, this.f28243a);
    }

    public void f() {
        r.d("MicroMsg.RemoteDebugJsEngine", "login");
        this.f28244b.c(1);
        ld ldVar = new ld();
        ldVar.f25859a = this.f28244b.b();
        ldVar.f25860b = this.f28244b.c();
        this.e.a(l.a(1002, ldVar));
    }

    private void g() {
        r.d("MicroMsg.RemoteDebugJsEngine", "joinRoom");
        this.f28244b.c(2);
        lb lbVar = new lb();
        lbVar.f25854a = this.f28244b.b();
        lbVar.f25856c = this.f28244b.j().f28240b;
        lbVar.f25855b = "";
        lbVar.f25857d = this.f28244b.j().f28241c;
        this.e.a(l.a(1003, lbVar));
    }

    public void h() {
        n B = this.g.B();
        ky kyVar = new ky();
        kh khVar = new kh();
        kyVar.f25844b = khVar;
        c cVar = (c) this.g.d(c.class);
        if (cVar != null) {
            kyVar.f25845c = cVar.b();
        }
        kyVar.e = this.g.m().A().T.md5;
        kyVar.f = 1;
        String a2 = this.g.B().a("WAService.js");
        if (!ai.c(a2)) {
            kyVar.f25846d = com.tencent.luggage.wxa.hb.c.a(a2.getBytes());
        }
        khVar.e = B.c();
        khVar.f25809b = com.tencent.luggage.wxa.sa.a.f25088c;
        khVar.f25808a = com.tencent.luggage.wxa.sa.a.g;
        khVar.f25811d = com.tencent.luggage.wxa.se.d.a(this.f28246d, 671090480);
        khVar.f25810c = com.tencent.luggage.wxa.sa.a.f;
        khVar.g = this.f28246d.getResources().getDisplayMetrics().density;
        khVar.f = this.f28246d.getResources().getDisplayMetrics().widthPixels / khVar.g;
        if (this.g.e(com.tencent.luggage.wxa.ea.c.class) != null && ((com.tencent.luggage.wxa.ea.c) this.g.e(com.tencent.luggage.wxa.ea.c.class)).af() != null) {
            khVar.h = ((com.tencent.luggage.wxa.ea.c) this.g.e(com.tencent.luggage.wxa.ea.c.class)).af().getUserAgentString();
        }
        ku kuVar = new ku();
        this.f.a(kuVar);
        kyVar.f25843a = kuVar;
        this.f.a(l.a(kyVar, this.f28244b, "setupContext"));
        r.e("MicroMsg.RemoteDebugJsEngine", "setupContext %s/%s/%d, %s", kyVar.f25846d, kyVar.e, Integer.valueOf(khVar.e), khVar.h);
    }

    public void i() {
        r.d("MicroMsg.RemoteDebugJsEngine", "onReady");
        this.f28244b.c(3);
        b();
        this.f.a(this.f28244b.d(), Integer.MAX_VALUE);
        this.h.h();
    }

    @Override
    public <T extends com.tencent.luggage.wxa.od.j> T a(Class<T> cls) {
        return null;
    }

    public void a() {
        this.h.bringToFront();
    }

    public void a(int i, String str) {
        this.f.a(i, str);
    }

    public void a(e eVar) {
        this.f28244b = eVar;
        this.g = this.f28244b.a();
        this.f28246d = (Activity) this.g.getContext();
        this.h = new m(this.f28246d, this.f28244b, new m.a() {
            @Override
            public void a() {
                g.this.destroy();
                com.tencent.luggage.wxa.jl.e.a(g.this.g.getAppId(), e.d.CLOSE);
                if (g.this.g.m() != null) {
                    g.this.g.m().E();
                }
            }
        });
        this.h.a(this.g.m());
        e();
        if (ai.c(this.f28244b.c())) {
            c();
        }
    }

    public void a(h hVar) {
        this.f.a(hVar);
    }

    public void a(String str) {
        this.f28245c = str;
    }

    public void a(String str, String str2) {
        this.f.a(str, str2);
    }

    @Override
    public void a(URL url, String str, ValueCallback<String> valueCallback) {
        evaluateJavascript(str, valueCallback);
    }

    @Override
    public void a(URL url, String str, String str2, int i, String str3, ValueCallback<String> valueCallback) {
        evaluateJavascript(str3, valueCallback);
    }

    @Override
    public void addJavascriptInterface(Object obj, String str) {
    }

    public void b() {
        r.d("MicroMsg.RemoteDebugJsEngine", "clearPendingScript");
        Iterator<Pair<String, ValueCallback<String>>> it = this.f28244b.v().iterator();
        while (it.hasNext()) {
            Pair<String, ValueCallback<String>> next = it.next();
            evaluateJavascript((String) next.first, (ValueCallback) next.second);
        }
        this.f28244b.v().clear();
    }

    public void c() {
        r.d("MicroMsg.RemoteDebugJsEngine", "getRemoteDebugTicket");
        ((com.tencent.luggage.wxa.pc.b) this.g.a(com.tencent.luggage.wxa.pc.b.class)).b("/cgi-bin/mmbiz-bin/wxabusiness/getremotedebugticket", this.g.getAppId(), new cj(), ck.class).a(new com.tencent.luggage.wxa.ss.b<Object, ck>() {
            @Override
            public Object a(ck ckVar) {
                if (ckVar == null) {
                    r.b("MicroMsg.RemoteDebugJsEngine", "getsubbusinessinfo cgi failed, null response");
                    return null;
                }
                if (ckVar.z.f25094a != 0) {
                    r.b("MicroMsg.RemoteDebugJsEngine", "getsubbusinessinfo cgi failed, errCode = %d, errMsg = %s, rr.resp = %b", Integer.valueOf(ckVar.z.f25094a), ckVar.z.f25095b, false);
                    return null;
                }
                g.this.f28244b.a(ckVar.f25254a);
                r.d("MicroMsg.RemoteDebugJsEngine", "loginTicket %s", ckVar.f25254a);
                if (g.this.e.a()) {
                    g.this.f();
                }
                return null;
            }
        });
    }

    public boolean d() {
        com.tencent.luggage.wxa.sd.a.f26157a.a(new com.tencent.luggage.wxa.sd.c<com.tencent.luggage.wxa.hp.a>() {
            @Override
            public boolean a(com.tencent.luggage.wxa.hp.a aVar) {
                if (aVar != null && aVar.f19451a != null && aVar.f19451a.f19454c != null) {
                    long currentTimeMillis = System.currentTimeMillis();
                    if (g.this.f28244b.j().i == 1) {
                        r.e("MicroMsg.RemoteDebugJsEngine", "NEW_REMOTE_DEBUG_TYPE and do onReceiveNetworkHeader");
                        try {
                            JSONObject jSONObject = new JSONObject();
                            jSONObject.put("api_name", aVar.f19451a.f19452a);
                            jSONObject.put(IVideoDbHelper.COLUMN_DOWNLOAD_TASK_ID, aVar.f19451a.f19453b);
                            jSONObject.put("request_headers", aVar.f19451a.f19454c.toString());
                            jSONObject.put("timestamp", currentTimeMillis);
                            if (g.this.f != null) {
                                g.this.f.a(jSONObject.toString());
                            }
                        } catch (Exception e) {
                            r.g("MicroMsg.RemoteDebugJsEngine", "", e);
                        }
                    } else {
                        kr krVar = new kr();
                        krVar.f25824a = aVar.f19451a.f19452a;
                        krVar.f25825b = aVar.f19451a.f19453b;
                        krVar.f25826c = aVar.f19451a.f19454c.toString();
                        krVar.f25827d = currentTimeMillis;
                        g.this.a(l.a(krVar, g.this.f28244b, "networkDebugAPI"));
                    }
                }
                return true;
            }
        });
        return true;
    }

    @Override
    public void destroy() {
        this.f.d();
        this.f.h();
    }

    @Override
    public void evaluateJavascript(String str, ValueCallback<String> valueCallback) {
        e eVar = this.f28244b;
        if (eVar == null) {
            if (valueCallback != null) {
                valueCallback.onReceiveValue("FATAL");
            }
        } else {
            if (eVar.y()) {
                return;
            }
            if (!this.f28244b.x()) {
                this.f28244b.v().add(new Pair<>(str, valueCallback));
                this.f28245c = null;
                return;
            }
            kk kkVar = new kk();
            kkVar.f25817b = this.f28244b.t();
            kkVar.f25816a = str;
            this.f.a(l.a(kkVar, this.f28244b, "evaluateJavascript"));
            a(kkVar.f25817b, str, valueCallback);
        }
    }

    @Override
    public void setJsExceptionHandler(com.tencent.luggage.wxa.od.h hVar) {
    }
}