package com.tencent.mm.pluginsdk.model.app;

import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ai.m;
import com.tencent.mm.compatible.util.g;
import com.tencent.mm.plugin.record.b.e;
import com.tencent.mm.pluginsdk.model.app.al.a;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;

class al$a$2 implements Runnable {
    final /* synthetic */ m crb;
    final /* synthetic */ int crc;
    final /* synthetic */ int crd;
    final /* synthetic */ a vcN;

    al$a$2(a aVar, m mVar, int i, int i2) {
        this.vcN = aVar;
        this.crb = mVar;
        this.crc = i;
        this.crd = i2;
    }

    public final void run() {
        int i;
        long j;
        long j2 = 0;
        Object obj = null;
        AppMethodBeat.i(27395);
        a.Fc();
        if (this.crb.getType() == 222) {
            ab.d("MicroMsg.SceneAppMsg", "onSceneEnd  SendAppMsg errtype:" + this.crc + " errCode:" + this.crd);
            i = 0;
            j = -1;
        } else if (this.crb.getType() == 221) {
            a.a(this.vcN);
            j = ((e) this.crb).pJl;
            i = ((e) this.crb).retCode;
        } else if (this.crb.getType() == 220) {
            String str;
            long j3;
            a.b(this.vcN);
            long j4 = ((ai) this.crb).pJl;
            int i2 = ((ai) this.crb).retCode;
            ai aiVar = (ai) this.crb;
            if (aiVar.pJj == null) {
                str = null;
            } else {
                str = aiVar.pJj.field_mediaSvrId;
            }
            aiVar = (ai) this.crb;
            if (aiVar.pJj == null) {
                j3 = 0;
            } else {
                j3 = aiVar.pJj.field_msgInfoId;
            }
            String str2 = (String) a.c(this.vcN).remove(Long.valueOf(j3));
            if (!bo.isNullOrNil(((ai) this.crb).fFa)) {
                obj = 1;
            }
            if (obj == null && !bo.isNullOrNil(str)) {
                b bVar = new b();
                am.aUq().b(j4, bVar);
                if (bVar.xDa == j4) {
                    l.a(bVar.field_msgInfoId, str, null);
                    ab.d("MicroMsg.SceneAppMsg", "onSceneEnd, finish update app attach, start send app msg");
                    a.A(bVar.field_msgInfoId, str2);
                }
            }
            i = i2;
            j = j4;
        } else {
            ab.e("MicroMsg.SceneAppMsg", "onSceneEnd Error SceneType:" + this.crb.getType());
            a.Fd();
            AppMethodBeat.o(27395);
            return;
        }
        if (!(j == -1 || this.vcN.cqS.get(Long.valueOf(j)) == null)) {
            j2 = ((g.a) this.vcN.cqS.get(Long.valueOf(j))).Mr();
            this.vcN.cqS.remove(Long.valueOf(j));
        }
        ab.d("MicroMsg.SceneAppMsg", "onSceneEnd SceneType:" + this.crb.getType() + " errtype:" + this.crc + " errCode:" + this.crd + " retCode:" + i + " rowid:" + j + " time:" + j2);
        if (this.crc != 0) {
            a.d(this.vcN);
        }
        ab.d("MicroMsg.SceneAppMsg", "onSceneEnd  inCnt:" + a.access$000() + " stop:" + a.e(this.vcN) + " running:" + a.f(this.vcN) + " recving:" + a.g(this.vcN) + " sending:" + a.h(this.vcN));
        if (a.e(this.vcN) > 0) {
            a.i(this.vcN);
        } else if (!(a.h(this.vcN) || a.g(this.vcN))) {
            a.j(this.vcN);
        }
        a.Fd();
        AppMethodBeat.o(27395);
    }

    public final String toString() {
        AppMethodBeat.i(27396);
        String str = super.toString() + "|onSceneEnd";
        AppMethodBeat.o(27396);
        return str;
    }
}
