WeChat.apk(点击下载) / v.java


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

import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.text.TextUtils;
import android.util.Pair;
import bw3.ao4;
import bw3.kc4;
import bw3.ng0;
import bw3.tf0;
import bw3.zn4;
import ck.g;
import com.tencent.mm.R;
import com.tencent.mm.autogen.events.NotifyGroupSolitatireEvent;
import com.tencent.mm.autogen.events.UpdateFailedMsgIdEvent;
import com.tencent.mm.message.l;
import com.tencent.mm.modelcdntran.h0;
import com.tencent.mm.modelimage.w;
import com.tencent.mm.opensdk.modelmsg.WXAppExtendObject;
import com.tencent.mm.opensdk.modelmsg.WXDesignerSharedObject;
import com.tencent.mm.opensdk.modelmsg.WXEmojiObject;
import com.tencent.mm.opensdk.modelmsg.WXEmojiPageSharedObject;
import com.tencent.mm.opensdk.modelmsg.WXEmojiSharedObject;
import com.tencent.mm.opensdk.modelmsg.WXFileObject;
import com.tencent.mm.opensdk.modelmsg.WXImageObject;
import com.tencent.mm.opensdk.modelmsg.WXLiteAppObject;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import com.tencent.mm.opensdk.modelmsg.WXMiniProgramObject;
import com.tencent.mm.opensdk.modelmsg.WXMusicObject;
import com.tencent.mm.opensdk.modelmsg.WXMusicVideoObject;
import com.tencent.mm.opensdk.modelmsg.WXMusicVipInfo;
import com.tencent.mm.opensdk.modelmsg.WXNativeGamePageObject;
import com.tencent.mm.opensdk.modelmsg.WXTextObject;
import com.tencent.mm.opensdk.modelmsg.WXVideoObject;
import com.tencent.mm.opensdk.modelmsg.WXWeWorkObject;
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject;
import com.tencent.mm.plugin.appbrand.config.WxaAttributes;
import com.tencent.mm.plugin.appbrand.service.c1;
import com.tencent.mm.plugin.gamesharecard.LiteAppBizDataInfo;
import com.tencent.mm.plugin.msgquote.model.MsgQuoteItem;
import com.tencent.mm.pluginsdk.ui.tools.n;
import com.tencent.mm.pluginsdk.ui.tools.q;
import com.tencent.mm.sdk.platformtools.BitmapUtil;
import com.tencent.mm.sdk.platformtools.Log;
import com.tencent.mm.sdk.platformtools.Util;
import com.tencent.mm.storage.f4;
import com.tencent.mm.storage.g4;
import com.tencent.mm.ui.chatting.viewitems.h1;
import com.tencent.mm.ui.transmit.MsgRetransmitUI;
import com.tencent.mm.vfs.VFSStrategy;
import com.tencent.mm.vfs.VFSStrategy$$b;
import com.tencent.mm.vfs.c2;
import com.tencent.mm.vfs.h0;
import com.tencent.mm.vfs.n2;
import com.tencent.mm.vfs.o2;
import com.tencent.mm.vfs.q1;
import com.tencent.mm.vfs.u1;
import com.tencent.tavkit.component.TAVExporter;
import d60.z;
import dk0.q0;
import ht2.j0;
import ht2.p;
import ie1.h;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import jh2.k0;
import jh2.x0;
import lh4.m;
import nf0.e6;
import nf0.h4;
import nf0.p3;
import nf0.u0;
import ru3.c;
import sp.c;
import t32.n1;
import xc4.j;
import yf0.l0;
import yf0.l0$$e;
import yf0.o;
import yf0.y;
import zv.r;

public class v {

    /* renamed from: a  reason: collision with root package name */
    public static p f171217a;

    public class a implements DialogInterface.OnClickListener {

        /* renamed from: d  reason: collision with root package name */
        public final /* synthetic */ f4 f171218d;

        /* renamed from: e  reason: collision with root package name */
        public final /* synthetic */ y14.b f171219e;

        public a(f4 f4Var, y14.b bVar) {
            this.f171218d = f4Var;
            this.f171219e = bVar;
        }

        public void onClick(DialogInterface dialogInterface, int i15) {
            v.w(this.f171218d);
            this.f171219e.B(true);
        }
    }

    public class b implements DialogInterface.OnClickListener {
        public void onClick(DialogInterface dialogInterface, int i15) {
        }
    }

    public class c implements o {

        /* renamed from: d  reason: collision with root package name */
        public final /* synthetic */ f f171220d;

        public c(f fVar) {
            this.f171220d = fVar;
        }

        @Override // yf0.o
        public void v(int i15, int i16, y yVar) {
            f fVar = this.f171220d;
            if (fVar != null) {
                fVar.v(i15, i16, yVar);
            }
        }
    }

    public class d implements c.a {

        /* renamed from: a  reason: collision with root package name */
        public final /* synthetic */ f4 f171221a;

        /* renamed from: b  reason: collision with root package name */
        public final /* synthetic */ long f171222b;

        /* renamed from: c  reason: collision with root package name */
        public final /* synthetic */ String f171223c;

        public d(f4 f4Var, long j15, String str) {
            this.f171221a = f4Var;
            this.f171222b = j15;
            this.f171223c = str;
        }

        @Override // ru3.c.a
        public void a(String str, String str2, String str3, String str4, String str5, String str6, long j15) {
            if (Util.isNullOrNil(str4)) {
                this.f171221a.c(5);
                ph2.b.e(this.f171221a.getMsgId(), ph2.b.c(0, 0, str, 727));
                ((g4) p3.b().z()).CA0(this.f171221a.getMsgId(), this.f171221a);
                f4 f4Var = new f4();
                f4Var.S2(nf0.f4.o(f4Var.i()));
                f4Var.i3(f4Var.i());
                f4Var.R2(str);
                f4Var.setType(10000);
                f4Var.c(6);
                f4Var.Z2(0);
                ((g4) p3.b().z()).Am0(f4Var);
                return;
            }
            x1 ZN0 = y1.ZN0();
            long j16 = this.f171222b;
            String str7 = this.f171223c;
            this.f171221a.getType();
            ZN0.getClass();
            p3.e().f(new j1(j16, str7, str4));
        }
    }

    public class e implements l0$$e {

        /* renamed from: d  reason: collision with root package name */
        public final /* synthetic */ long f171224d;

        /* renamed from: e  reason: collision with root package name */
        public final /* synthetic */ long f171225e;

        public e(long j15, long j16) {
            this.f171224d = j15;
            this.f171225e = j16;
        }

        @Override // yf0.l0$$e
        public int callback(int i15, int i16, String str, yf0.c cVar, y yVar) {
            Log.i("MicroMsg.AppMsgLogic", "sendFileUploadMsgCallback type:%d errType:%d errCode:%d errMsg:%s tempMsgId:%s", Integer.valueOf(yVar.getType()), Integer.valueOf(i15), Integer.valueOf(i16), Util.nullAs(str, ""), Long.valueOf(this.f171224d));
            zn4 zn4 = (zn4) cVar.f345548a.f345573a;
            if (zn4 != null) {
                String str2 = zn4.f44659e;
                if (Util.isEqual(str2, this.f171224d + "")) {
                    if (i15 == 0 && i16 == 0) {
                        ao4 ao4 = (ao4) cVar.f345549b.f345576a;
                        if (ao4 != null) {
                            Log.i("MicroMsg.AppMsgLogic", "FileUploadToken:%s NewMsgId:%s msgId:%s", ao4.f16483d, Long.valueOf(ao4.f16484e), zn4.f44659e);
                            f4 tz4 = ((g4) ((k0) z.q(k0.class)).WU()).tz(Util.safeParseLong(zn4.f44659e));
                            if (tz4.getMsgId() == 0) {
                                Log.e("MicroMsg.AppMsgLogic", "sendFileUploadMsgCallback msg:%s no exist!", zn4.f44659e);
                                return 0;
                            }
                            l.b v15 = l.b.v(Util.processXml(tz4.getContent()), null);
                            vb0.b bVar = new vb0.b();
                            String str3 = ao4.f16483d;
                            m.g(str3, "<set-?>");
                            bVar.f323903c = str3;
                            bVar.f323902b = ao4.f16484e;
                            v15.f(bVar);
                            tz4.R2(l.b.t(v15, null, null));
                            tz4.c(2);
                            tz4.e3(ao4.f16484e);
                            ((g4) ((k0) z.q(k0.class)).WU()).CA0(tz4.getMsgId(), tz4);
                            ((j) j.f338034d).f(new h1(v15, tz4, 1));
                        }
                    } else {
                        v.H(this.f171225e, ph2.b.c(i16, i15, str, yVar.getType()));
                    }
                    y1.ZN0().d();
                }
            }
            return 0;
        }
    }

    public interface f {
        void v(int i15, int i16, y yVar);
    }

    public static int A(l.b bVar, WXMediaMessage wXMediaMessage, String str, String str2, String str3, int i15, a aVar, Map<String, Long> map, String str4, String str5, String str6, String str7) {
        d dVar;
        String str8;
        String str9;
        String str10;
        l.b bVar2 = bVar;
        WXMediaMessage wXMediaMessage2 = wXMediaMessage;
        if (i15 == 1) {
            n nVar = new n();
            nVar.f173310b = 1;
            bVar2.f(nVar);
        }
        String r15 = r(bVar2, wXMediaMessage2, str2, aVar);
        Log.i("MicroMsg.AppMsgLogic", g.c() + "summerbig content url:" + bVar2.f76870j + " lowUrl:" + bVar2.f76874k + " attachlen:" + bVar2.f76878l + " attachid:" + bVar2.f76890o + " attach file:" + r15 + " webViewReqId: " + str4 + " msgSvrId: " + str5 + " talkerUsername: " + str6 + " snsLocalId: " + str7);
        StringBuilder sb5 = new StringBuilder();
        sb5.append(System.currentTimeMillis());
        sb5.append("");
        String sb6 = sb5.toString();
        if (!Util.isNullOrNil(r15)) {
            dVar = a(sb6, bVar2, r15);
            if (dVar == null) {
                return 0 - g.a();
            }
            BitmapFactory.Options imageOptions = BitmapUtil.getImageOptions(r15);
            if (imageOptions != null) {
                bVar2.Q = imageOptions.outWidth;
                bVar2.P = imageOptions.outHeight;
            }
        } else {
            dVar = null;
        }
        f4 f4Var = new f4();
        byte[] bArr = wXMediaMessage2.thumbData;
        if (bArr == null || bArr.length <= 0) {
            str8 = "MicroMsg.AppMsgLogic";
        } else {
            if (bArr.length <= 65536 || wXMediaMessage.getType() == 36 || wXMediaMessage.getType() == 46 || wXMediaMessage.getType() == 101) {
                str8 = "MicroMsg.AppMsgLogic";
                str10 = x(wXMediaMessage2.thumbData, false, Bitmap.CompressFormat.JPEG, true);
            } else {
                str8 = "MicroMsg.AppMsgLogic";
                str10 = x(wXMediaMessage2.thumbData, bVar2.f76866i == 2, Bitmap.CompressFormat.JPEG, false);
            }
            g.c();
            if (!Util.isNullOrNil(str10)) {
                f4Var.Y2(str10);
            }
        }
        if (dVar != null) {
            bVar2.f76890o = "" + dVar.systemRowid;
            if (bVar2.f76866i == 6 && Util.isNullOrNil(bVar2.f76906s)) {
                bVar2.f76906s = h0.fO0().e(dVar.field_fileFullPath);
            }
        }
        bVar2.f76894p = str2;
        bVar2.I1 = str4;
        f4Var.R2(l.b.t(bVar2, null, null));
        f4Var.c(1);
        f4Var.Z2(1);
        f4Var.setType(l(bVar));
        for (String str11 : Util.stringsToList(str.split(","))) {
            f4Var.i3(str11);
            f4Var.S2(nf0.f4.o(str11));
            String Za0 = ((x0) yz3.j.c(x0.class)).Za0(f4Var);
            if (!Util.isNullOrNil(str5) && !Util.isNullOrNil(str6)) {
                Za0 = ((ep.j) yz3.j.c(ep.j.class)).UX(Za0, str5, str6);
                ((ep.j) yz3.j.c(ep.j.class)).E00();
            } else if (!Util.isNullOrNil(str7)) {
                zg0.f fVar = new zg0.f();
                fVar.f352527c = str7;
                Za0 = ((ep.j) yz3.j.c(ep.j.class)).Ov(Za0, fVar);
                ((ep.j) yz3.j.c(ep.j.class)).E00();
            }
            if (!Util.isNullOrNil(Za0)) {
                f4Var.y4(Za0);
            }
            Long valueOf = Long.valueOf(map != null ? map.get(str11).longValue() : -1);
            if (valueOf == null || valueOf.longValue() < 0) {
                str9 = str8;
                valueOf = Long.valueOf(((g4) p3.b().z()).Am0(f4Var));
            } else {
                str9 = str8;
                Log.i(str9, "sendAppMsg, updateById, existMsgId:%d ", valueOf);
                ((g4) p3.b().z()).CA0(valueOf.longValue(), f4Var);
            }
            if (valueOf.longValue() < 0) {
                Log.e(str9, g.c() + " summerbig insert msg failed :" + valueOf);
                return 0 - g.a();
            }
            Log.i(str9, g.a() + " summerbig new msg inserted to db , local id = " + valueOf);
            f4Var.setMsgId(valueOf.longValue());
            l lVar = new l();
            lVar.field_xml = f4Var.getContent();
            lVar.field_title = wXMediaMessage2.title;
            lVar.field_type = wXMediaMessage2.mediaObject.type();
            lVar.field_description = wXMediaMessage2.description;
            lVar.field_msgId = valueOf.longValue();
            lVar.field_source = bVar2.F;
            y1.aO0().insert(lVar);
            if (((ar.f) yz3.j.c(ar.f.class)).Fn0(f4Var)) {
                MsgRetransmitUI.R7(valueOf);
            }
            if (dVar != null) {
                long longValue = valueOf.longValue();
                dVar.field_msgInfoId = longValue;
                dVar.field_status = 101;
                Log.i(str9, "summerbig sendAppMsg update attInfo field_msgInfoId[%d], field_status[%d], systemRowid[%d], type[%d]", Long.valueOf(longValue), Long.valueOf(dVar.field_status), Long.valueOf(dVar.systemRowid), Integer.valueOf(lVar.field_type));
                y1.VN0().update(dVar, new String[0]);
                if (!Util.isNullOrNil(str3)) {
                    y1.ZN0().f171240d.put(Long.valueOf(dVar.field_msgInfoId), str3);
                }
                K(f4Var, dVar);
            } else {
                Log.i(str9, "summerbig sendAppMsg dosceneSendAppMsg attInfo[%s], msgId[%d], sessionId[%s], type[%d]", dVar, valueOf, str3, Integer.valueOf(lVar.field_type));
                x1 ZN0 = y1.ZN0();
                long longValue2 = valueOf.longValue();
                ZN0.getClass();
                j1 j1Var = new j1(longValue2, str3, null);
                j1Var.f171069j = aVar;
                Log.i("MicroMsg.NetSceneSendAppMsg", "NetSceneSendAppMsg directShare[%d]", Integer.valueOf(i15));
                a aVar2 = j1Var.f171069j;
                if (aVar2 != null) {
                    Log.i("MicroMsg.NetSceneSendAppMsg", "NetSceneSendAppMsg tokenValid[%d], pkgName[%s]", Integer.valueOf(aVar2.f170975a), j1Var.f171069j.f170976b);
                }
                p3.e().f(j1Var);
            }
            bVar2 = bVar;
            wXMediaMessage2 = wXMediaMessage;
            str8 = str9;
        }
        return 0;
    }

    public static int B(WXMediaMessage wXMediaMessage, String str, String str2, String str3, int i15, String str4) {
        return C(wXMediaMessage, str, str2, str3, i15, str4, null, 0, null);
    }

    public static int C(WXMediaMessage wXMediaMessage, String str, String str2, String str3, int i15, String str4, String str5, int i16, a aVar) {
        return D(wXMediaMessage, str, str2, str3, i15, str4, str5, i16, aVar, null, null, null, null, null);
    }

    public static int D(WXMediaMessage wXMediaMessage, String str, String str2, String str3, int i15, String str4, String str5, int i16, a aVar, Map<String, Long> map, String str6, String str7, String str8, String str9) {
        l.b bVar = new l.b();
        bVar.f76846d = str;
        bVar.F = str2;
        bVar.f76902r = i15;
        return A(bVar, wXMediaMessage, str3, str4, str5, i16, aVar, map, str6, str7, str8, str9);
    }

    public static Pair<Integer, Long> E(l.b bVar, String str, String str2, String str3, String str4, byte[] bArr) {
        return F(bVar, str, str2, str3, str4, bArr, null);
    }

    public static Pair<Integer, Long> F(l.b bVar, String str, String str2, String str3, String str4, byte[] bArr, String str5) {
        return G(bVar, str, str2, str3, str4, bArr, str5, "", "", 0);
    }

    /* JADX DEBUG: Multi-variable search result rejected for r3v1, resolved type: int */
    /* JADX WARN: Multi-variable type inference failed */
    /* JADX WARN: Type inference failed for: r3v5 */
    /* JADX WARN: Type inference failed for: r3v11 */
    /* JADX WARN: Type inference failed for: r3v12 */
    /* JADX WARN: Type inference failed for: r3v13 */
    /* JADX WARNING: Removed duplicated region for block: B:110:0x028e  */
    /* JADX WARNING: Removed duplicated region for block: B:115:0x0299  */
    /* JADX WARNING: Removed duplicated region for block: B:121:0x02a4 A[SYNTHETIC, Splitter:B:121:0x02a4] */
    /* JADX WARNING: Removed duplicated region for block: B:138:0x032f  */
    /* JADX WARNING: Removed duplicated region for block: B:158:0x0374  */
    /* JADX WARNING: Removed duplicated region for block: B:160:0x0379 A[SYNTHETIC, Splitter:B:160:0x0379] */
    /* JADX WARNING: Removed duplicated region for block: B:166:0x0397  */
    /* JADX WARNING: Removed duplicated region for block: B:168:0x039c A[SYNTHETIC, Splitter:B:168:0x039c] */
    /* JADX WARNING: Removed duplicated region for block: B:173:0x03a8  */
    /* JADX WARNING: Removed duplicated region for block: B:174:0x03ae  */
    /* JADX WARNING: Removed duplicated region for block: B:178:0x03b8  */
    /* JADX WARNING: Removed duplicated region for block: B:180:0x03bd A[SYNTHETIC, Splitter:B:180:0x03bd] */
    /* JADX WARNING: Removed duplicated region for block: B:187:0x03ce  */
    /* JADX WARNING: Removed duplicated region for block: B:192:0x0400  */
    /* JADX WARNING: Removed duplicated region for block: B:195:0x043e  */
    /* JADX WARNING: Removed duplicated region for block: B:203:0x0458  */
    /* JADX WARNING: Removed duplicated region for block: B:206:0x0466  */
    /* JADX WARNING: Removed duplicated region for block: B:209:0x0495  */
    /* JADX WARNING: Removed duplicated region for block: B:212:0x04b6  */
    /* JADX WARNING: Removed duplicated region for block: B:214:0x04e7  */
    public static Pair<Integer, Long> G(l.b bVar, String str, String str2, String str3, String str4, byte[] bArr, String str5, String str6, String str7, long j15) {
        d dVar;
        String str8;
        String str9;
        d dVar2;
        Integer num;
        f4 f4Var;
        int i15;
        l.b bVar2;
        String Za0;
        long Am0;
        MsgQuoteItem msgQuoteItem;
        f4 f4Var2;
        String str10;
        Integer num2;
        int i16;
        int i17;
        int i18;
        String str11;
        f4 f4Var3;
        OutputStream outputStream;
        Throwable th5;
        OutputStream outputStream2;
        IOException e15;
        Exception e16;
        int i19;
        ByteArrayOutputStream byteArrayOutputStream;
        Throwable th6;
        int i25;
        int i26;
        int i27;
        ByteArrayOutputStream byteArrayOutputStream2;
        int i28;
        char c15;
        int i29;
        byte[] bArr2 = bArr;
        boolean z15 = false;
        Log.i("MicroMsg.AppMsgLogic", "summerbig sendAppMsg attachFilePath[%s], content[%s]", str4, bVar);
        String str12 = System.currentTimeMillis() + "";
        if (!Util.isNullOrNil(str4)) {
            d a15 = a(str12, bVar, str4);
            if (a15 == null) {
                return new Pair<>(Integer.valueOf(0 - g.a()), -1L);
            }
            dVar = a15;
        } else {
            dVar = null;
        }
        q.a();
        f4 f4Var4 = new f4();
        ub0.c cVar = (ub0.c) bVar.x(ub0.c.class);
        boolean z16 = cVar != null && !TextUtils.isEmpty(cVar.f317157b) && !TextUtils.isEmpty(cVar.f317159d);
        Log.i("MicroMsg.AppMsgLogic", "isUseOriginThumb:%b", Boolean.valueOf(z16));
        if (bArr2 == null || bArr2.length <= 0) {
            f4Var = f4Var4;
            dVar2 = dVar;
            str9 = "";
            str8 = "MicroMsg.AppMsgLogic";
            num = 0;
        } else {
            int i35 = bVar.f76866i;
            if (i35 == 33 || i35 == 36 || i35 == 44) {
                i16 = 48;
            } else {
                i16 = 48;
                if (i35 != 48) {
                    if (i35 == 46) {
                        if (z16) {
                            str10 = ((w) ((yt.j) yz3.j.c(yt.j.class)).ol()).te(bArr2);
                        } else {
                            str10 = ((w) ((yt.j) yz3.j.c(yt.j.class)).ol()).zW(bArr2, 100, Bitmap.CompressFormat.JPEG);
                        }
                    } else if (i35 == 101) {
                        str10 = ((w) ((yt.j) yz3.j.c(yt.j.class)).ol()).te(bArr2);
                    } else if (bVar.p() || (i29 = bVar.f76866i) == 93) {
                        c15 = 2;
                        str10 = ((w) ((yt.j) yz3.j.c(yt.j.class)).ol()).te(bArr2);
                        f4Var2 = f4Var4;
                        dVar2 = dVar;
                        str9 = "";
                        str8 = "MicroMsg.AppMsgLogic";
                        num2 = 0;
                        num = num2;
                        z15 = false;
                        g.c();
                        if (!Util.isNullOrNil(str10)) {
                            f4Var = f4Var2;
                            f4Var.Y2(str10);
                        } else {
                            f4Var = f4Var2;
                        }
                    } else {
                        c15 = 2;
                        str10 = x(bArr2, i29 == 2, Bitmap.CompressFormat.PNG, z16);
                        f4Var2 = f4Var4;
                        dVar2 = dVar;
                        str9 = "";
                        str8 = "MicroMsg.AppMsgLogic";
                        num2 = 0;
                        num = num2;
                        z15 = false;
                        g.c();
                        if (!Util.isNullOrNil(str10)) {
                        }
                    }
                    c15 = 2;
                    f4Var2 = f4Var4;
                    dVar2 = dVar;
                    str9 = "";
                    str8 = "MicroMsg.AppMsgLogic";
                    num2 = 0;
                    num = num2;
                    z15 = false;
                    g.c();
                    if (!Util.isNullOrNil(str10)) {
                    }
                }
            }
            if (i35 == i16) {
                i18 = 0;
                i17 = 0;
            } else {
                i18 = (int) (BitmapUtil.getDefaultDisplayMetrics().density * 240.0f);
                i17 = (int) (BitmapUtil.getDefaultDisplayMetrics().density * 240.0f);
            }
            com.tencent.mm.message.a aVar = (com.tencent.mm.message.a) bVar.x(com.tencent.mm.message.a.class);
            if (aVar != null) {
                f4Var3 = f4Var4;
                str11 = aVar.f76731v;
            } else {
                f4Var3 = f4Var4;
                str11 = "";
            }
            boolean z17 = aVar != null ? aVar.f76732w : false;
            if (z16) {
                str10 = ((w) ((yt.j) yz3.j.c(yt.j.class)).ol()).te(bArr2);
                dVar2 = dVar;
                str9 = "";
                str8 = "MicroMsg.AppMsgLogic";
                num2 = 0;
                f4Var2 = f4Var3;
            } else {
                int i36 = bVar.f76866i;
                if (i36 == 44 || i36 == 48) {
                    dVar2 = dVar;
                    str9 = "";
                    str8 = "MicroMsg.AppMsgLogic";
                    f4Var2 = f4Var3;
                    yt.l ol5 = ((yt.j) yz3.j.c(yt.j.class)).ol();
                    Bitmap.CompressFormat compressFormat = Bitmap.CompressFormat.JPEG;
                    w wVar = (w) ol5;
                    wVar.getClass();
                    if (Util.isNullOrNil(bArr)) {
                        Log.e("MicroMsg.ImgInfoStorage", "save dir thumb error, thumbBuf is null");
                        num = 0;
                        str10 = null;
                    } else {
                        long currentTimeMillis = System.currentTimeMillis();
                        String Se = w.Se();
                        String Xv = wVar.Xv(Se, "th_", str9, true);
                        String str13 = Xv + ".tmp";
                        int length = bArr2.length;
                        BitmapFactory.Options options = new BitmapFactory.Options();
                        options.inJustDecodeBounds = true;
                        BitmapFactory.decodeByteArray(bArr2, 0, bArr2.length, options);
                        try {
                            outputStream2 = u1.J(str13, false);
                            try {
                                outputStream2.write(bArr2);
                                outputStream2.flush();
                                Bitmap decodeByteArray = BitmapUtil.decodeByteArray(bArr2, i18, i17);
                                int length2 = bArr2.length;
                                if (decodeByteArray != null) {
                                    if (bArr2.length > 262144) {
                                        try {
                                            byteArrayOutputStream2 = new ByteArrayOutputStream();
                                            try {
                                                decodeByteArray.compress(compressFormat, 100, byteArrayOutputStream2);
                                                i26 = byteArrayOutputStream2.toByteArray().length;
                                                str9 = str9;
                                                i27 = 100;
                                                while (byteArrayOutputStream2.toByteArray().length > 262144 && i27 >= 15) {
                                                    try {
                                                        byteArrayOutputStream2.reset();
                                                        i27 -= 5;
                                                        decodeByteArray.compress(compressFormat, i27, byteArrayOutputStream2);
                                                        i26 = byteArrayOutputStream2.toByteArray().length;
                                                    } catch (Exception unused) {
                                                        i28 = i27;
                                                        i19 = i26;
                                                        try {
                                                            Log.e("MicroMsg.ImgInfoStorage", "compress bitmap failed.");
                                                            if (byteArrayOutputStream2 != null) {
                                                                i26 = i19;
                                                                i27 = i28;
                                                                byteArrayOutputStream2.close();
                                                                i25 = i27;
                                                                i19 = i26;
                                                                BitmapUtil.saveBitmapToImage(decodeByteArray, i25, compressFormat, Xv, true);
                                                                com.tencent.mm.plugin.report.service.q qVar = com.tencent.mm.plugin.report.service.q.INSTANCE;
                                                                Object[] objArr = new Object[10];
                                                                objArr[0] = ck.q.b(Util.nullAsNil(str11), "UTF-8");
                                                                objArr[1] = Boolean.valueOf(z17);
                                                                objArr[2] = Integer.valueOf(length);
                                                                objArr[3] = Integer.valueOf(options.outHeight);
                                                                objArr[4] = Integer.valueOf(options.outWidth);
                                                                objArr[5] = Integer.valueOf(i19);
                                                                objArr[6] = Integer.valueOf(decodeByteArray.getHeight());
                                                                objArr[7] = Integer.valueOf(decodeByteArray.getWidth());
                                                                num = 0;
                                                                objArr[8] = null;
                                                                objArr[9] = Long.valueOf(System.currentTimeMillis() - currentTimeMillis);
                                                                qVar.g(16498, objArr);
                                                                if (u1.k(str13)) {
                                                                }
                                                                outputStream2.close();
                                                                str10 = "THUMBNAIL_DIRPATH://th_" + Se;
                                                                z15 = false;
                                                                g.c();
                                                                if (!Util.isNullOrNil(str10)) {
                                                                }
                                                                if (dVar2 != null) {
                                                                }
                                                                f4Var.R2(l.b.t(bVar2, null, null));
                                                                f4Var.c(1);
                                                                f4Var.i3(str3);
                                                                f4Var.S2(nf0.f4.o(str3));
                                                                f4Var.Z2(1);
                                                                f4Var.setType(l(bVar));
                                                                f4Var.y4(h4.n(str7));
                                                                Za0 = ((x0) yz3.j.c(x0.class)).Za0(f4Var);
                                                                if (!Util.isNullOrNil(Za0)) {
                                                                }
                                                                f4Var.y4(msgQuoteItem.f133708n);
                                                                if (j15 != 0) {
                                                                }
                                                                if (bVar2.f76866i == 53) {
                                                                }
                                                                ((ep.j) yz3.j.c(ep.j.class)).sM(f4Var, j15);
                                                                ((ep.j) yz3.j.c(ep.j.class)).E00();
                                                                Am0 = ((g4) p3.b().z()).Am0(f4Var);
                                                                if (bVar2.f76866i == 53) {
                                                                }
                                                                g.c();
                                                                if (Am0 < 0) {
                                                                }
                                                            } else {
                                                                i25 = i28;
                                                                BitmapUtil.saveBitmapToImage(decodeByteArray, i25, compressFormat, Xv, true);
                                                                com.tencent.mm.plugin.report.service.q qVar2 = com.tencent.mm.plugin.report.service.q.INSTANCE;
                                                                Object[] objArr2 = new Object[10];
                                                                objArr2[0] = ck.q.b(Util.nullAsNil(str11), "UTF-8");
                                                                objArr2[1] = Boolean.valueOf(z17);
                                                                objArr2[2] = Integer.valueOf(length);
                                                                objArr2[3] = Integer.valueOf(options.outHeight);
                                                                objArr2[4] = Integer.valueOf(options.outWidth);
                                                                objArr2[5] = Integer.valueOf(i19);
                                                                objArr2[6] = Integer.valueOf(decodeByteArray.getHeight());
                                                                objArr2[7] = Integer.valueOf(decodeByteArray.getWidth());
                                                                num = 0;
                                                                objArr2[8] = null;
                                                                objArr2[9] = Long.valueOf(System.currentTimeMillis() - currentTimeMillis);
                                                                qVar2.g(16498, objArr2);
                                                                if (u1.k(str13)) {
                                                                }
                                                                outputStream2.close();
                                                                str10 = "THUMBNAIL_DIRPATH://th_" + Se;
                                                                z15 = false;
                                                                g.c();
                                                                if (!Util.isNullOrNil(str10)) {
                                                                }
                                                                if (dVar2 != null) {
                                                                }
                                                                f4Var.R2(l.b.t(bVar2, null, null));
                                                                f4Var.c(1);
                                                                f4Var.i3(str3);
                                                                f4Var.S2(nf0.f4.o(str3));
                                                                f4Var.Z2(1);
                                                                f4Var.setType(l(bVar));
                                                                f4Var.y4(h4.n(str7));
                                                                Za0 = ((x0) yz3.j.c(x0.class)).Za0(f4Var);
                                                                if (!Util.isNullOrNil(Za0)) {
                                                                }
                                                                f4Var.y4(msgQuoteItem.f133708n);
                                                                if (j15 != 0) {
                                                                }
                                                                if (bVar2.f76866i == 53) {
                                                                }
                                                                ((ep.j) yz3.j.c(ep.j.class)).sM(f4Var, j15);
                                                                ((ep.j) yz3.j.c(ep.j.class)).E00();
                                                                Am0 = ((g4) p3.b().z()).Am0(f4Var);
                                                                if (bVar2.f76866i == 53) {
                                                                }
                                                                g.c();
                                                                if (Am0 < 0) {
                                                                }
                                                            }
                                                        } catch (Throwable th7) {
                                                            th6 = th7;
                                                            byteArrayOutputStream = byteArrayOutputStream2;
                                                            if (byteArrayOutputStream != null) {
                                                                try {
                                                                    byteArrayOutputStream.close();
                                                                } catch (Exception unused2) {
                                                                }
                                                            }
                                                            throw th6;
                                                        }
                                                    }
                                                }
                                            } catch (Exception unused3) {
                                                str9 = str9;
                                                i19 = length2;
                                                i28 = 100;
                                                Log.e("MicroMsg.ImgInfoStorage", "compress bitmap failed.");
                                                if (byteArrayOutputStream2 != null) {
                                                }
                                            } catch (Throwable th8) {
                                                th6 = th8;
                                                byteArrayOutputStream = byteArrayOutputStream2;
                                                if (byteArrayOutputStream != null) {
                                                }
                                                throw th6;
                                            }
                                        } catch (Exception unused4) {
                                            str9 = str9;
                                            byteArrayOutputStream2 = null;
                                            i19 = length2;
                                            i28 = 100;
                                            Log.e("MicroMsg.ImgInfoStorage", "compress bitmap failed.");
                                            if (byteArrayOutputStream2 != null) {
                                            }
                                        } catch (Throwable th9) {
                                            th6 = th9;
                                            byteArrayOutputStream = null;
                                            if (byteArrayOutputStream != null) {
                                            }
                                            throw th6;
                                        }
                                        try {
                                            byteArrayOutputStream2.close();
                                        } catch (Exception unused5) {
                                        }
                                        i25 = i27;
                                        i19 = i26;
                                        try {
                                            BitmapUtil.saveBitmapToImage(decodeByteArray, i25, compressFormat, Xv, true);
                                        } catch (IOException e17) {
                                            e15 = e17;
                                        } catch (Exception e18) {
                                            e16 = e18;
                                            num = 0;
                                            try {
                                                Log.e("MicroMsg.ImgInfoStorage", "save bitmap to image error, %s", e16);
                                                str10 = wVar.UW(bArr, true, compressFormat, false);
                                                if (u1.k(str13)) {
                                                }
                                                if (outputStream2 != null) {
                                                }
                                                z15 = false;
                                                g.c();
                                                if (!Util.isNullOrNil(str10)) {
                                                }
                                                if (dVar2 != null) {
                                                }
                                                f4Var.R2(l.b.t(bVar2, null, null));
                                                f4Var.c(1);
                                                f4Var.i3(str3);
                                                f4Var.S2(nf0.f4.o(str3));
                                                f4Var.Z2(1);
                                                f4Var.setType(l(bVar));
                                                f4Var.y4(h4.n(str7));
                                                Za0 = ((x0) yz3.j.c(x0.class)).Za0(f4Var);
                                                if (!Util.isNullOrNil(Za0)) {
                                                }
                                                f4Var.y4(msgQuoteItem.f133708n);
                                                if (j15 != 0) {
                                                }
                                                if (bVar2.f76866i == 53) {
                                                }
                                                ((ep.j) yz3.j.c(ep.j.class)).sM(f4Var, j15);
                                                ((ep.j) yz3.j.c(ep.j.class)).E00();
                                                Am0 = ((g4) p3.b().z()).Am0(f4Var);
                                                if (bVar2.f76866i == 53) {
                                                }
                                                g.c();
                                                if (Am0 < 0) {
                                                }
                                            } catch (Throwable th10) {
                                                th5 = th10;
                                                outputStream = outputStream2;
                                                if (u1.k(str13)) {
                                                    u1.h(str13);
                                                }
                                                if (outputStream != null) {
                                                    try {
                                                        outputStream.close();
                                                    } catch (Exception unused6) {
                                                    }
                                                }
                                                throw th5;
                                            }
                                        }
                                    } else {
                                        str9 = str9;
                                        u1.x(str13, Xv);
                                        i19 = length2;
                                    }
                                    com.tencent.mm.plugin.report.service.q qVar22 = com.tencent.mm.plugin.report.service.q.INSTANCE;
                                    Object[] objArr22 = new Object[10];
                                    objArr22[0] = ck.q.b(Util.nullAsNil(str11), "UTF-8");
                                    objArr22[1] = Boolean.valueOf(z17);
                                    objArr22[2] = Integer.valueOf(length);
                                    objArr22[3] = Integer.valueOf(options.outHeight);
                                    objArr22[4] = Integer.valueOf(options.outWidth);
                                    objArr22[5] = Integer.valueOf(i19);
                                    objArr22[6] = Integer.valueOf(decodeByteArray.getHeight());
                                    objArr22[7] = Integer.valueOf(decodeByteArray.getWidth());
                                    num = 0;
                                    try {
                                        objArr22[8] = null;
                                        objArr22[9] = Long.valueOf(System.currentTimeMillis() - currentTimeMillis);
                                        qVar22.g(16498, objArr22);
                                    } catch (IOException e19) {
                                        e15 = e19;
                                    } catch (Exception e25) {
                                        e16 = e25;
                                        Log.e("MicroMsg.ImgInfoStorage", "save bitmap to image error, %s", e16);
                                        str10 = wVar.UW(bArr, true, compressFormat, false);
                                        if (u1.k(str13)) {
                                        }
                                        if (outputStream2 != null) {
                                        }
                                        z15 = false;
                                        g.c();
                                        if (!Util.isNullOrNil(str10)) {
                                        }
                                        if (dVar2 != null) {
                                        }
                                        f4Var.R2(l.b.t(bVar2, null, null));
                                        f4Var.c(1);
                                        f4Var.i3(str3);
                                        f4Var.S2(nf0.f4.o(str3));
                                        f4Var.Z2(1);
                                        f4Var.setType(l(bVar));
                                        f4Var.y4(h4.n(str7));
                                        Za0 = ((x0) yz3.j.c(x0.class)).Za0(f4Var);
                                        if (!Util.isNullOrNil(Za0)) {
                                        }
                                        f4Var.y4(msgQuoteItem.f133708n);
                                        if (j15 != 0) {
                                        }
                                        if (bVar2.f76866i == 53) {
                                        }
                                        ((ep.j) yz3.j.c(ep.j.class)).sM(f4Var, j15);
                                        ((ep.j) yz3.j.c(ep.j.class)).E00();
                                        Am0 = ((g4) p3.b().z()).Am0(f4Var);
                                        if (bVar2.f76866i == 53) {
                                        }
                                        g.c();
                                        if (Am0 < 0) {
                                        }
                                    }
                                } else {
                                    str9 = str9;
                                    num = 0;
                                }
                                if (u1.k(str13)) {
                                    u1.h(str13);
                                }
                                try {
                                    outputStream2.close();
                                } catch (Exception unused7) {
                                }
                                str10 = "THUMBNAIL_DIRPATH://th_" + Se;
                            } catch (IOException e26) {
                                e15 = e26;
                                str9 = str9;
                                num = 0;
                                bArr2 = bArr;
                                z15 = false;
                                Log.e("MicroMsg.ImgInfoStorage", "save bitmap to image error, %s", e15);
                                str10 = wVar.UW(bArr2, true, compressFormat, false);
                                if (u1.k(str13)) {
                                }
                                if (outputStream2 != null) {
                                }
                                g.c();
                                if (!Util.isNullOrNil(str10)) {
                                }
                                if (dVar2 != null) {
                                }
                                f4Var.R2(l.b.t(bVar2, null, null));
                                f4Var.c(1);
                                f4Var.i3(str3);
                                f4Var.S2(nf0.f4.o(str3));
                                f4Var.Z2(1);
                                f4Var.setType(l(bVar));
                                f4Var.y4(h4.n(str7));
                                Za0 = ((x0) yz3.j.c(x0.class)).Za0(f4Var);
                                if (!Util.isNullOrNil(Za0)) {
                                }
                                f4Var.y4(msgQuoteItem.f133708n);
                                if (j15 != 0) {
                                }
                                if (bVar2.f76866i == 53) {
                                }
                                ((ep.j) yz3.j.c(ep.j.class)).sM(f4Var, j15);
                                ((ep.j) yz3.j.c(ep.j.class)).E00();
                                Am0 = ((g4) p3.b().z()).Am0(f4Var);
                                if (bVar2.f76866i == 53) {
                                }
                                g.c();
                                if (Am0 < 0) {
                                }
                            } catch (Exception e27) {
                                e16 = e27;
                                str9 = str9;
                                num = 0;
                                Log.e("MicroMsg.ImgInfoStorage", "save bitmap to image error, %s", e16);
                                str10 = wVar.UW(bArr, true, compressFormat, false);
                                if (u1.k(str13)) {
                                }
                                if (outputStream2 != null) {
                                }
                                z15 = false;
                                g.c();
                                if (!Util.isNullOrNil(str10)) {
                                }
                                if (dVar2 != null) {
                                }
                                f4Var.R2(l.b.t(bVar2, null, null));
                                f4Var.c(1);
                                f4Var.i3(str3);
                                f4Var.S2(nf0.f4.o(str3));
                                f4Var.Z2(1);
                                f4Var.setType(l(bVar));
                                f4Var.y4(h4.n(str7));
                                Za0 = ((x0) yz3.j.c(x0.class)).Za0(f4Var);
                                if (!Util.isNullOrNil(Za0)) {
                                }
                                f4Var.y4(msgQuoteItem.f133708n);
                                if (j15 != 0) {
                                }
                                if (bVar2.f76866i == 53) {
                                }
                                ((ep.j) yz3.j.c(ep.j.class)).sM(f4Var, j15);
                                ((ep.j) yz3.j.c(ep.j.class)).E00();
                                Am0 = ((g4) p3.b().z()).Am0(f4Var);
                                if (bVar2.f76866i == 53) {
                                }
                                g.c();
                                if (Am0 < 0) {
                                }
                            }
                        } catch (IOException e28) {
                            e15 = e28;
                            str9 = str9;
                            num = 0;
                            outputStream2 = null;
                            z15 = false;
                            Log.e("MicroMsg.ImgInfoStorage", "save bitmap to image error, %s", e15);
                            str10 = wVar.UW(bArr2, true, compressFormat, false);
                            if (u1.k(str13)) {
                                u1.h(str13);
                            }
                            if (outputStream2 != null) {
                                try {
                                    outputStream2.close();
                                } catch (Exception unused8) {
                                }
                            }
                            g.c();
                            if (!Util.isNullOrNil(str10)) {
                            }
                            if (dVar2 != null) {
                            }
                            f4Var.R2(l.b.t(bVar2, null, null));
                            f4Var.c(1);
                            f4Var.i3(str3);
                            f4Var.S2(nf0.f4.o(str3));
                            f4Var.Z2(1);
                            f4Var.setType(l(bVar));
                            f4Var.y4(h4.n(str7));
                            Za0 = ((x0) yz3.j.c(x0.class)).Za0(f4Var);
                            if (!Util.isNullOrNil(Za0)) {
                            }
                            f4Var.y4(msgQuoteItem.f133708n);
                            if (j15 != 0) {
                            }
                            if (bVar2.f76866i == 53) {
                            }
                            ((ep.j) yz3.j.c(ep.j.class)).sM(f4Var, j15);
                            ((ep.j) yz3.j.c(ep.j.class)).E00();
                            Am0 = ((g4) p3.b().z()).Am0(f4Var);
                            if (bVar2.f76866i == 53) {
                            }
                            g.c();
                            if (Am0 < 0) {
                            }
                        } catch (Exception e29) {
                            e16 = e29;
                            str9 = str9;
                            num = 0;
                            outputStream2 = null;
                            Log.e("MicroMsg.ImgInfoStorage", "save bitmap to image error, %s", e16);
                            str10 = wVar.UW(bArr, true, compressFormat, false);
                            if (u1.k(str13)) {
                                u1.h(str13);
                            }
                            if (outputStream2 != null) {
                                try {
                                    outputStream2.close();
                                } catch (Exception unused9) {
                                }
                            }
                            z15 = false;
                            g.c();
                            if (!Util.isNullOrNil(str10)) {
                            }
                            if (dVar2 != null) {
                            }
                            f4Var.R2(l.b.t(bVar2, null, null));
                            f4Var.c(1);
                            f4Var.i3(str3);
                            f4Var.S2(nf0.f4.o(str3));
                            f4Var.Z2(1);
                            f4Var.setType(l(bVar));
                            f4Var.y4(h4.n(str7));
                            Za0 = ((x0) yz3.j.c(x0.class)).Za0(f4Var);
                            if (!Util.isNullOrNil(Za0)) {
                            }
                            f4Var.y4(msgQuoteItem.f133708n);
                            if (j15 != 0) {
                            }
                            if (bVar2.f76866i == 53) {
                            }
                            ((ep.j) yz3.j.c(ep.j.class)).sM(f4Var, j15);
                            ((ep.j) yz3.j.c(ep.j.class)).E00();
                            Am0 = ((g4) p3.b().z()).Am0(f4Var);
                            if (bVar2.f76866i == 53) {
                            }
                            g.c();
                            if (Am0 < 0) {
                            }
                        } catch (Throwable th11) {
                            th5 = th11;
                            outputStream = null;
                            if (u1.k(str13)) {
                            }
                            if (outputStream != null) {
                            }
                            throw th5;
                        }
                    }
                    z15 = false;
                    g.c();
                    if (!Util.isNullOrNil(str10)) {
                    }
                } else {
                    f4Var2 = f4Var3;
                    dVar2 = dVar;
                    str9 = "";
                    str8 = "MicroMsg.AppMsgLogic";
                    num2 = 0;
                    str10 = ((w) ((yt.j) yz3.j.c(yt.j.class)).ol()).vX(bArr, 70, Bitmap.CompressFormat.JPEG, TAVExporter.VIDEO_EXPORT_WIDTH, 0.8f, 262144, str11, z17);
                }
            }
            num = num2;
            z15 = false;
            g.c();
            if (!Util.isNullOrNil(str10)) {
            }
        }
        if (dVar2 != null) {
            bVar2 = bVar;
            boolean z18 = z15;
            bVar2.f76890o = str9 + dVar2.systemRowid;
            i15 = z18;
            if (bVar2.f76866i == 6) {
                i15 = z18;
                if (Util.isNullOrNil(bVar2.f76906s)) {
                    bVar2.f76906s = h0.fO0().e(dVar2.field_fileFullPath);
                    i15 = z18;
                }
            }
        } else {
            bVar2 = bVar;
            i15 = z15;
        }
        f4Var.R2(l.b.t(bVar2, null, null));
        f4Var.c(1);
        f4Var.i3(str3);
        f4Var.S2(nf0.f4.o(str3));
        f4Var.Z2(1);
        f4Var.setType(l(bVar));
        f4Var.y4(h4.n(str7));
        Za0 = ((x0) yz3.j.c(x0.class)).Za0(f4Var);
        if (!Util.isNullOrNil(Za0)) {
            f4Var.y4(Za0);
        }
        if (bVar2.f76866i == 57 && (msgQuoteItem = bVar2.f76925w2) != null) {
            f4Var.y4(msgQuoteItem.f133708n);
        }
        if (j15 != 0) {
            h4.K(f4Var, h4.B(2), i15);
        }
        if (bVar2.f76866i == 53) {
            f4Var.U = (String) bVar2.f76921v2.first;
            f4Var.f263806r = true;
        }
        ((ep.j) yz3.j.c(ep.j.class)).sM(f4Var, j15);
        ((ep.j) yz3.j.c(ep.j.class)).E00();
        Am0 = ((g4) p3.b().z()).Am0(f4Var);
        if (bVar2.f76866i == 53) {
            NotifyGroupSolitatireEvent notifyGroupSolitatireEvent = new NotifyGroupSolitatireEvent();
            NotifyGroupSolitatireEvent.a aVar2 = notifyGroupSolitatireEvent.f63664d;
            aVar2.f63666a = i15;
            aVar2.f63668c = f4Var.U;
            aVar2.f63667b = f4Var.i();
            notifyGroupSolitatireEvent.f63665e.f63670a = Am0;
            notifyGroupSolitatireEvent.publish();
        }
        g.c();
        if (Am0 < 0) {
            Log.e(str8, g.c() + "insert msg failed :" + Am0);
            return new Pair<>(Integer.valueOf(0 - g.a()), Long.valueOf(Am0));
        }
        Log.i(str8, g.a() + " new msg inserted to db , local id = " + Am0);
        f4Var.setMsgId(Am0);
        l lVar = new l();
        lVar.field_xml = f4Var.getContent();
        lVar.field_appId = str;
        lVar.field_title = bVar2.f76854f;
        lVar.field_type = bVar2.f76866i;
        lVar.field_description = bVar2.f76858g;
        lVar.field_msgId = Am0;
        lVar.field_source = str2;
        y1.aO0().insert(lVar);
        boolean z19 = true;
        Object[] objArr3 = new Object[1];
        if (dVar2 != null) {
            z19 = i15;
        }
        objArr3[i15] = Boolean.valueOf(z19);
        Log.i(str8, "summerbig sendAppMsg attInfo is null[%b]", objArr3);
        if (dVar2 != null) {
            dVar2.field_msgInfoId = Am0;
            dVar2.field_status = 101;
            y1.VN0().update(dVar2, new String[i15]);
            if (bVar2.f76866i == 2 || !Util.isNullOrNil(str5)) {
                y1.ZN0().f171240d.put(Long.valueOf(Am0), str5);
            }
            K(f4Var, dVar2);
        } else if (bVar2.f76910t != 0 || bVar2.f76878l > 26214400) {
            p3.e().f(new ru3.c(bVar2, str4, str3, new d(f4Var, Am0, str5)));
        } else {
            y1.ZN0().getClass();
            p3.e().f(new j1(Am0, str5, str6));
        }
        return new Pair<>(num, Long.valueOf(Am0));
    }

    public static void H(long j15, ph2.c cVar) {
        y1.VN0().te(j15, 198);
        Util.getStack();
        d dVar = new d();
        y1.VN0().get(j15, dVar);
        if (dVar.field_msgInfoId > 0) {
            f4 tz4 = ((g4) p3.b().z()).tz(dVar.field_msgInfoId);
            if (tz4.getMsgId() == dVar.field_msgInfoId) {
                if (tz4.getStatus() == 2 && tz4.getType() == 1090519089 && tz4.Y == 0) {
                    tz4.T2(100);
                    ((j) j.f338034d).f(new h1(null, tz4, 3));
                } else {
                    tz4.c(5);
                }
                if (tz4.getMsgId() > 0 && tz4.y2() == 1 && cVar != null) {
                    ph2.b.e(tz4.getMsgId(), cVar);
                    Log.i("MicroMsg.AppMsgLogic", "record err msg, %s, %s, %s", Long.valueOf(tz4.getMsgId()), Integer.valueOf(cVar.f283410a), cVar.f283411b);
                }
                ((g4) p3.b().z()).CA0(tz4.getMsgId(), tz4);
            }
        }
    }

    public static void I(y14.b bVar, f4 f4Var, int i15, l.b bVar2) {
        i14.j.A(bVar.f(), bVar.m().getString(i15), "", bVar.m().getString(R.string.f367535wd), bVar.m().getString(R.string.f367394sg), new a(f4Var, bVar), new b());
        f4 tz4 = ((g4) p3.b().z()).tz(f4Var.getMsgId());
        tz4.T2(101);
        ((g4) p3.b().z()).CA0(f4Var.getMsgId(), tz4);
        ((j) j.f338034d).f(new h1(bVar2, tz4, 5));
    }

    /* JADX WARNING: Removed duplicated region for block: B:61:0x01a5  */
    public static boolean J(String str, f4 f4Var) {
        String str2;
        String str3;
        String str4;
        String str5;
        String str6;
        d dVar;
        int i15;
        boolean z15;
        int i16;
        boolean z16 = false;
        if (f4Var == null) {
            return false;
        }
        d f15 = f(str, f4Var.getMsgId());
        h0.h hVar = null;
        l.b v15 = l.b.v(f4Var.getContent(), null);
        if (v15 != null) {
            String str7 = v15.f76854f;
            int i17 = q0.f200799a;
            String str8 = "";
            if (str7 == null) {
                str7 = str8;
            }
            String str9 = v15.f76886n;
            if (str9 == null) {
                str9 = str8;
            }
            String lowerCase = str9.toLowerCase();
            String str10 = v15.f76906s;
            if (str10 == null) {
                str10 = str8;
            }
            String str11 = v15.G;
            if (str11 == null) {
                str11 = str8;
            }
            String str12 = v15.R;
            if (str12 != null) {
                str8 = str12;
            }
            str4 = str7;
            str6 = str8;
            str3 = lowerCase;
            str5 = str10;
            str2 = str11;
        } else {
            str6 = null;
            str5 = null;
            str4 = null;
            str3 = null;
            str2 = null;
        }
        if (f15 == null) {
            n(f4Var.getMsgId(), f4Var.getContent(), null);
            f15 = f(str, f4Var.getMsgId());
            if (f15 != null) {
                Object[] objArr = new Object[8];
                objArr[0] = Long.valueOf(f15.systemRowid);
                objArr[1] = Long.valueOf(f15.field_totalLen);
                objArr[2] = f15.field_fileFullPath;
                objArr[3] = Long.valueOf(f15.field_type);
                objArr[4] = f15.field_mediaId;
                objArr[5] = Long.valueOf(f15.field_msgInfoId);
                objArr[6] = Boolean.valueOf(f15.field_isUpload);
                String str13 = f15.field_signature;
                if (str13 == null) {
                    i16 = -1;
                } else {
                    i16 = str13.length();
                }
                objArr[7] = Integer.valueOf(i16);
                Log.i("MicroMsg.AppMsgLogic", "summerbig tryInitAttachInfo newInfo systemRowid [%d], totalLen[%d], field_fileFullPath[%s], type[%d], mediaId[%s], msgid[%d], upload[%b], signature len[%d]", objArr);
                if (v15 != null && (v15.f76910t != 0 || v15.f76878l > 26214400)) {
                    dVar = f15;
                    if (!z16) {
                        p3.e().f(new ht2.n(dVar, str6, str5, str4, str3, str2));
                    }
                    return z16;
                }
            }
        } else {
            n2 a15 = n2.a(f15.field_fileFullPath);
            String str14 = a15.f189021f;
            if (str14 != null) {
                String k15 = o2.k(str14, false, false);
                if (!a15.f189021f.equals(k15)) {
                    a15 = new n2(a15.f189019d, a15.f189020e, k15, a15.f189022g, a15.f189023h);
                }
            }
            if (f15.field_status == 199) {
                h0.h l15 = h0.i.f188954a.l(a15, null);
                if (!l15.a()) {
                    z15 = false;
                } else {
                    z15 = l15.f188951a.D(l15.f188952b);
                }
                if (!z15) {
                    Log.i("MicroMsg.AppMsgLogic", "summerbig tryInitAttachInfo info exist but file not!");
                    n(f4Var.getMsgId(), f4Var.getContent(), null);
                }
                hVar = l15;
            }
            Object[] objArr2 = new Object[10];
            objArr2[0] = Long.valueOf(f15.systemRowid);
            objArr2[1] = Long.valueOf(f15.field_totalLen);
            objArr2[2] = f15.field_fileFullPath;
            objArr2[3] = Long.valueOf(f15.field_type);
            objArr2[4] = f15.field_mediaId;
            objArr2[5] = Long.valueOf(f15.field_msgInfoId);
            objArr2[6] = Boolean.valueOf(f15.field_isUpload);
            h0.h l16 = h0.i.f188954a.l(a15, hVar);
            if (l16.a()) {
                z16 = l16.f188951a.D(l16.f188952b);
            }
            objArr2[7] = Boolean.valueOf(z16);
            objArr2[8] = Long.valueOf(f15.field_status);
            String str15 = f15.field_signature;
            if (str15 == null) {
                i15 = -1;
            } else {
                i15 = str15.length();
            }
            objArr2[9] = Integer.valueOf(i15);
            Log.i("MicroMsg.AppMsgLogic", "summerbig tryInitAttachInfo info exist systemRowid [%d], totalLen[%d], field_fileFullPath[%s], type[%d], mediaId[%s], msgid[%d], upload[%b], file.exists[%b], status[%d], signature len[%d]", objArr2);
        }
        dVar = f15;
        z16 = true;
        if (!z16) {
        }
        return z16;
    }

    public static void K(f4 f4Var, d dVar) {
        if (f4Var == null || dVar == null || f4Var.getType() != 1090519089) {
            y1.ZN0().d();
            return;
        }
        l0.e(new pu3.a(dVar).f345492f, new e(dVar.field_msgInfoId, dVar.systemRowid), false);
    }

    /* JADX WARNING: Removed duplicated region for block: B:16:0x00d2  */
    /* JADX WARNING: Removed duplicated region for block: B:18:0x00f0 A[RETURN] */
    public static d a(String str, l.b bVar, String str2) {
        boolean z15;
        d dVar;
        Log.i("MicroMsg.AppMsgLogic", g.c() + " summerbig buildUploadAttachInfo clientAppDataId:" + str + " attach file :" + str2);
        String replace = str2.replace("//", "/");
        VFSStrategy$$b vFSStrategy$$b = VFSStrategy.f188778a;
        n2 e15 = h0.i.f188954a.e(n2.a(replace));
        if (e15 != null && "wcf".equals(e15.f189019d)) {
            c2 c2Var = c2.f188827a;
            String str3 = e15.f189020e;
            m.g(str3, "fsName");
            if (xg4.n.g(c2.f188830d, str3, 0, 0, 6, null) >= 0) {
                z15 = true;
                if (!z15 || !replace.startsWith(z80.b.Z())) {
                    dVar = new d();
                    dVar.field_totalLen = (long) bVar.f76878l;
                    dVar.field_fileFullPath = str2;
                    dVar.field_sdkVer = (long) bVar.f76850e;
                    dVar.field_appId = bVar.f76846d;
                    dVar.field_clientAppDataId = str;
                    dVar.field_type = (long) bVar.f76866i;
                    dVar.field_status = 200;
                    dVar.field_isUpload = true;
                    dVar.field_createTime = e6.a();
                    dVar.field_lastModifyTime = Util.nowSecond();
                    dVar.field_mediaSvrId = "" + Util.nowMilliSecond();
                    dVar.field_isUseCdn = 0;
                    y1.VN0().insert(dVar);
                    g.c();
                    if (dVar.systemRowid < 0) {
                        return dVar;
                    }
                    Log.e("MicroMsg.AppMsgLogic", g.c() + " summerbig uploadAttach insert appattach info failed :" + dVar.systemRowid);
                    return null;
                }
                Log.e("MicroMsg.AppMsgLogic", "summerbig Error attach path:%s", replace);
                return null;
            }
        }
        z15 = false;
        if (!z15) {
        }
        dVar = new d();
        dVar.field_totalLen = (long) bVar.f76878l;
        dVar.field_fileFullPath = str2;
        dVar.field_sdkVer = (long) bVar.f76850e;
        dVar.field_appId = bVar.f76846d;
        dVar.field_clientAppDataId = str;
        dVar.field_type = (long) bVar.f76866i;
        dVar.field_status = 200;
        dVar.field_isUpload = true;
        dVar.field_createTime = e6.a();
        dVar.field_lastModifyTime = Util.nowSecond();
        dVar.field_mediaSvrId = "" + Util.nowMilliSecond();
        dVar.field_isUseCdn = 0;
        y1.VN0().insert(dVar);
        g.c();
        if (dVar.systemRowid < 0) {
        }
    }

    public static boolean b(String str) {
        if (!Util.isNullOrNil(str) && !str.equals("0:0")) {
            return true;
        }
        return false;
    }

    public static int c(int i15) {
        switch (i15) {
            case -1879048191:
            case -1879048190:
            case -1879048189:
            case -1879048186:
            case -1879048185:
            case -1879048183:
            case -1879048176:
            case 74:
            case 83:
            case 84:
            case 87:
            case 95:
            case 102:
            case 103:
            case 1048625:
            case 16777265:
            case 268435505:
            case 285212721:
            case 301989937:
            case 318767153:
            case 335544369:
            case 352321585:
            case 369098801:
            case 385876017:
            case 402653233:
            case 419430449:
            case 436207665:
            case 452984881:
            case 469762097:
            case 486539313:
            case 503316529:
            case 520093745:
            case 536870961:
            case 536936497:
            case 553648177:
            case 587202609:
            case 603979825:
            case 687865905:
            case 704643121:
            case 738197553:
            case 754974769:
            case 771751985:
            case 805306417:
            case 822083633:
            case 855638065:
            case 905969713:
            case 922746929:
            case 939524145:
            case 973078577:
            case 974127153:
            case 975175729:
            case 976224305:
            case 977272881:
            case 1040187441:
            case 1077936177:
            case 1090519089:
            case 1107296305:
            case 1124073521:
            case 1140850737:
            case 1157627953:
            case 1174405169:
            case 1409286193:
            case 1426063409:
                return 49;
            default:
                return i15;
        }
    }

    public static void d(f4 f4Var, f fVar) {
        l.b v15 = l.b.v(f4Var.getContent(), null);
        if (v15 == null) {
            Log.e("MicroMsg.AppMsgLogic", "parse msgContent error, %s", f4Var.getContent());
            return;
        }
        if (Util.isNullOrNil(v15.f76890o) && !Util.isNullOrNil(v15.J)) {
            Log.e("MicroMsg.AppMsgLogic", "msgContent format error, %s", f4Var.getContent());
            v15.f76890o = "" + v15.J.hashCode();
        }
        String str = v15.f76890o;
        if (!p(f4Var, f(str, f4Var.getMsgId())) && J(str, f4Var)) {
            f171217a = new p(f4Var.getMsgId(), str, new c(fVar));
            p3.e().f(f171217a);
        }
    }

    public static String e(String str, String str2, String str3) {
        boolean z15;
        String str4;
        n2 a15 = n2.a(str);
        String str5 = a15.f189021f;
        if (str5 != null) {
            String k15 = o2.k(str5, false, false);
            if (!a15.f189021f.equals(k15)) {
                a15 = new n2(a15.f189019d, a15.f189020e, k15, a15.f189022g, a15.f189023h);
            }
        }
        h0.h l15 = h0.i.f188954a.l(a15, null);
        if (!l15.a()) {
            z15 = false;
        } else {
            z15 = l15.f188951a.D(l15.f188952b);
        }
        if (!z15) {
            h0.h l16 = h0.i.f188954a.l(a15, l15);
            if (l16.a()) {
                l16.f188951a.i(l16.f188952b);
            }
        }
        if (Util.isNullOrNil(str2)) {
            str4 = str + "da_" + Util.nowMilliSecond();
            if (!Util.isNullOrNil(str3)) {
                str4 = str4 + "." + str3;
            }
        } else {
            if (!Util.isNullOrNil(str3) && !str2.endsWith(str3)) {
                str2 = str2 + "." + str3;
            }
            str4 = str + str2;
            if (u1.k(str4)) {
                int i15 = 1;
                while (true) {
                    if (i15 >= 20) {
                        break;
                    }
                    if (!u1.k(str + i15 + "_" + str2)) {
                        str4 = str + i15 + "_" + str2;
                        break;
                    }
                    i15++;
                }
                if (i15 == 20) {
                    str4 = str + "da_" + Util.nowMilliSecond();
                    if (!Util.isNullOrNil(str3)) {
                        str4 = str4 + "." + str3;
                    }
                }
            }
        }
        try {
            if (new q1(str4).r().o().equalsIgnoreCase(new q1(n2.a(str)).o())) {
                return str4;
            }
            String str6 = str + "da_" + Util.nowMilliSecond();
            if (!Util.isNullOrNil(str2)) {
                str6 = str6 + str2;
            }
            if (!Util.isNullOrNil(str3)) {
                str6 = str6 + "." + str3;
            }
            Log.w("MicroMsg.AppMsgLogic", "maybe DirTraversal attach. %s", str6);
            return str6;
        } catch (Exception e15) {
            Log.printErrStackTrace("MicroMsg.AppMsgLogic", e15, "", new Object[0]);
            String str7 = str + "da_" + Util.nowMilliSecond();
            if (Util.isNullOrNil(str3)) {
                return str7;
            }
            return str7 + "." + str3;
        }
    }

    public static d f(String str, long j15) {
        d g15 = g(str);
        if (g15 == null) {
            g15 = y1.VN0().sb(j15);
        }
        if (g15 != null) {
            Log.i("MicroMsg.AppMsgLogic", "summerbig getAppAttachInfo info[%s], rowid[%d], isUpload[%b], fullpath[%s], totallen[%d], offset[%d], mediaSvrId[%s], mediaid[%s], msgid[%d], type[%d], stack[%s]", g15, Long.valueOf(g15.systemRowid), Boolean.valueOf(g15.field_isUpload), g15.field_fileFullPath, Long.valueOf(g15.field_totalLen), Long.valueOf(g15.field_offset), g15.field_mediaSvrId, g15.field_mediaId, Long.valueOf(g15.field_msgInfoId), Long.valueOf(g15.field_type), Util.getStack());
        } else {
            Log.w("MicroMsg.AppMsgLogic", "summerbig getAppAttachInfo is null stack[%s]", Util.getStack());
        }
        return g15;
    }

    public static d g(String str) {
        d dVar = new d();
        if (Util.isNullOrNil(str)) {
            return null;
        }
        Log.i("MicroMsg.AppMsgLogic", "getAppAttachInfoByAttachId %s", str);
        long j15 = Util.getLong(str, -1);
        if (j15 != -1) {
            y1.VN0().get(j15, dVar);
            if (dVar.systemRowid != j15 && ((dVar = y1.VN0().fb(str)) == null || !dVar.field_mediaSvrId.equals(str))) {
                Log.i("MicroMsg.AppMsgLogic", "summerbig getAppAttachInfoByAttachId set appAttachInfo null 1");
            }
            Log.i("MicroMsg.AppMsgLogic", "getAppAttachInfoByAttachId %s id %s", str, Long.valueOf(j15));
            return dVar;
        }
        dVar = y1.VN0().fb(str);
        if (dVar == null || !dVar.field_mediaSvrId.equals(str)) {
            Log.i("MicroMsg.AppMsgLogic", "summerbig getAppAttachInfoByAttachId set appAttachInfo null 2");
        }
        Log.i("MicroMsg.AppMsgLogic", "getAppAttachInfoByAttachId %s id %s", str, Long.valueOf(j15));
        return dVar;
        dVar = null;
        Log.i("MicroMsg.AppMsgLogic", "getAppAttachInfoByAttachId %s id %s", str, Long.valueOf(j15));
        return dVar;
    }

    public static d h(String str, long j15, int i15, String str2, String str3, int i16) {
        d dVar = new d();
        dVar.field_fileFullPath = str;
        dVar.field_appId = str2;
        dVar.field_sdkVer = (long) i15;
        dVar.field_mediaSvrId = str3;
        dVar.field_totalLen = (long) i16;
        dVar.field_status = 101;
        dVar.field_isUpload = false;
        dVar.field_createTime = e6.a();
        dVar.field_lastModifyTime = Util.nowSecond();
        dVar.field_msgInfoId = j15;
        dVar.field_netTimes = 0;
        return dVar;
    }

    public static String i() {
        return VFSStrategy.b("attachment") + '/';
    }

    public static String j() {
        return VFSStrategy.b("attachment") + '/';
    }

    public static d k(f4 f4Var, String str) {
        d g15 = g(str);
        if (g15 != null) {
            return g15;
        }
        n(f4Var.getMsgId(), f4Var.getContent(), null);
        return g(str);
    }

    public static int l(l.b bVar) {
        int i15;
        h.c cVar = h.c.Pi;
        h.c cVar2 = h.c.f231845eg;
        if (bVar == null) {
            return 49;
        }
        int i16 = bVar.f76866i;
        int i17 = bVar.H;
        int i18 = bVar.Y;
        int i19 = bVar.Z;
        int i25 = bVar.f76928x1;
        int i26 = bVar.D1;
        if (i16 == 76) {
            return 1040187441;
        }
        if (i16 == 92) {
            return 1409286193;
        }
        if (i16 == 93) {
            return 1426063409;
        }
        if (i16 == 3 && (((r) yz3.j.c(r.class)).E1(bVar.f76846d) || "wx485a97c844086dc9".equals(bVar.f76846d))) {
            return 1040187441;
        }
        if (i18 == 4 || i19 != 0) {
            return 318767153;
        }
        if (i16 == 2001) {
            if (i17 == 1 || i26 == 1) {
                return 469762097;
            }
            return i25 == 4 ? 503316529 : 436207665;
        } else if (i16 == 2002) {
            return 536870961;
        } else {
            if (i16 == 2003) {
                return 536936497;
            }
            if (i16 == 66) {
                return 905969713;
            }
            if (i17 == 1) {
                return i16 == 21 ? -1879048185 : 285212721;
            }
            if (i17 != 2) {
                if (i17 == 3) {
                    return i16 == 21 ? -1879048176 : -1879048189;
                }
                if (i17 != 4) {
                    if (i17 == 5) {
                        return -1879048191;
                    }
                    if (i17 == 17) {
                        return -1879048186;
                    }
                    if (i16 == 1) {
                        return 16777265;
                    }
                    if (i16 == 2) {
                        return 268435505;
                    }
                    if (i16 == 16) {
                        return 452984881;
                    }
                    if (i16 == 17) {
                        return -1879048186;
                    }
                    if (i16 != 33) {
                        if (i16 == 34) {
                            return 520093745;
                        }
                        if (i16 != 59) {
                            if (i16 == 60) {
                                return 855638065;
                            }
                            if (i16 == 62) {
                                return 922746929;
                            }
                            if (i16 != 63) {
                                switch (i16) {
                                    case 6:
                                        return 1090519089;
                                    case 8:
                                        return 1048625;
                                    case 10:
                                        return 335544369;
                                    case 13:
                                        return 369098801;
                                    case 20:
                                        return 402653233;
                                    case 36:
                                        break;
                                    case 50:
                                        if (((h) yz3.j.c(h.class)).Xj0(cVar2, 0) != 1 && ((h) yz3.j.c(h.class)).Xj0(cVar, 0) == 1) {
                                            return 49;
                                        }
                                        return 771751985;
                                    case 51:
                                        if (((h) yz3.j.c(h.class)).Xj0(cVar2, 0) != 1 && ((h) yz3.j.c(h.class)).Xj0(cVar, 0) == 1) {
                                            return 49;
                                        }
                                        return 754974769;
                                    case 52:
                                        if (((h) yz3.j.c(h.class)).Xj0(cVar2, 0) != 1 && ((h) yz3.j.c(h.class)).Xj0(cVar, 0) == 1) {
                                            return 49;
                                        }
                                        return 788529201;
                                    case 53:
                                        return 805306417;
                                    case 54:
                                        com.tencent.mm.message.f fVar = (com.tencent.mm.message.f) bVar.x(com.tencent.mm.message.f.class);
                                        if (fVar == null || fVar.f76803l == null) {
                                            return 49;
                                        }
                                        return 486539313;
                                    case 57:
                                        return 822083633;
                                    case 65:
                                        if (((h) yz3.j.c(h.class)).Xj0(cVar2, 0) != 1 && ((h) yz3.j.c(h.class)).Xj0(cVar, 0) == 1) {
                                            return 49;
                                        }
                                        return 989855793;
                                    case 69:
                                        return 939524145;
                                    case 77:
                                        return 1074790449;
                                    case 94:
                                        return 976224305;
                                    case 95:
                                        return 1080033329;
                                    case 96:
                                        return 977272881;
                                    case 98:
                                        return 1124073521;
                                    case 101:
                                        return 1140850737;
                                    case 105:
                                        return 1157627953;
                                    case 106:
                                        if (((h) yz3.j.c(h.class)).Xj0(cVar2, 0) != 1 && ((h) yz3.j.c(h.class)).Xj0(cVar, 0) == 1) {
                                            return 49;
                                        }
                                        return 1174405169;
                                    case 2000:
                                    case 2011:
                                        return 419430449;
                                    case 671088689:
                                        return 671088689;
                                    default:
                                        switch (i16) {
                                            case 46:
                                                return 687865905;
                                            case 47:
                                                return 704643121;
                                            case 48:
                                                return 738197553;
                                            default:
                                                switch (i16) {
                                                    case 71:
                                                        if (((h) yz3.j.c(h.class)).Xj0(cVar2, 0) != 1 && ((h) yz3.j.c(h.class)).Xj0(cVar, 0) == 1) {
                                                            return 49;
                                                        }
                                                        return 1023410225;
                                                    case 72:
                                                        if (((h) yz3.j.c(h.class)).Xj0(cVar2, 0) != 1 && ((h) yz3.j.c(h.class)).Xj0(cVar, 0) == 1) {
                                                            return 49;
                                                        }
                                                        return 1006633009;
                                                    case 73:
                                                        if (((h) yz3.j.c(h.class)).Xj0(cVar2, 0) != 1 && ((h) yz3.j.c(h.class)).Xj0(cVar, 0) == 1) {
                                                            return 49;
                                                        }
                                                        return 956301361;
                                                    case 74:
                                                        return 1090519089;
                                                    case 75:
                                                        int b15 = n1.b(bVar.G2, bVar.D2);
                                                        if (b15 == 2) {
                                                            return 1057030193;
                                                        }
                                                        if (b15 == 3) {
                                                            return 1023541297;
                                                        }
                                                        if (b15 == 4) {
                                                            return 1023606833;
                                                        }
                                                        if (b15 != 100000000) {
                                                            return 49;
                                                        }
                                                        return 1023475761;
                                                    default:
                                                        switch (i16) {
                                                            case 80:
                                                                return 1075839025;
                                                            case 81:
                                                                if (((h) yz3.j.c(h.class)).Xj0(cVar2, 0) != 1 && ((h) yz3.j.c(h.class)).Xj0(cVar, 0) == 1) {
                                                                    return 49;
                                                                }
                                                                return 1076887601;
                                                            case 82:
                                                                return 974127153;
                                                            default:
                                                                switch (i16) {
                                                                    case 87:
                                                                        return 1107296305;
                                                                    case 88:
                                                                        return 975175729;
                                                                    case 89:
                                                                        return 1078984753;
                                                                    default:
                                                                        return 49;
                                                                }
                                                        }
                                                }
                                        }
                                }
                            } else if (((h) yz3.j.c(h.class)).Xj0(cVar2, 0) != 1 && ((h) yz3.j.c(h.class)).Xj0(cVar, 0) == 1) {
                                return 49;
                            } else {
                                return 973078577;
                            }
                        } else if (((h) yz3.j.c(h.class)).Xj0(cVar2, 0) != 1 && ((h) yz3.j.c(h.class)).Xj0(cVar, 0) == 1) {
                            return 49;
                        } else {
                            return 838860849;
                        }
                    }
                    com.tencent.mm.message.a aVar = (com.tencent.mm.message.a) bVar.x(com.tencent.mm.message.a.class);
                    if (aVar != null && aVar.f76711b && ((i15 = bVar.f76865h2) == 2 || i15 == 3)) {
                        return 553648177;
                    }
                    if (aVar == null || !aVar.f76714e || bVar.f76865h2 != 3) {
                        return 49;
                    }
                    return 587202609;
                } else if (i16 == 21) {
                    return -1879048183;
                } else {
                    return -1879048190;
                }
            } else if (i16 == 21) {
                return -1879048183;
            } else {
                return 301989937;
            }
        }
    }

    public static int m(String str) {
        l.b v15 = l.b.v(str, null);
        if (v15 == null || !b(v15.f76890o)) {
            return -1;
        }
        d dVar = new d();
        long j15 = Util.getLong(v15.f76890o, -1);
        if (j15 != -1) {
            y1.VN0().get(j15, dVar);
            if (dVar.systemRowid != j15 && ((dVar = y1.VN0().fb(v15.f76890o)) == null || !dVar.field_mediaSvrId.equals(v15.f76890o))) {
                return -1;
            }
        } else {
            dVar = y1.VN0().fb(v15.f76890o);
            if (dVar == null || !dVar.field_mediaSvrId.equals(v15.f76890o)) {
                return -1;
            }
        }
        long j16 = dVar.field_totalLen;
        if (j16 == 0) {
            return -1;
        }
        return (int) ((dVar.field_offset * 100) / j16);
    }

    public static String n(long j15, String str, String str2) {
        Log.i("MicroMsg.AppMsgLogic", "summerbig initDownloadAttach msgLocalId[%d], msgXml[%s], downloadPath[%s]", Long.valueOf(j15), str, str2);
        l.b v15 = l.b.v(str, null);
        if (v15 == null) {
            return null;
        }
        if (str2 == null) {
            str2 = e(j(), v15.f76854f, v15.f76886n);
        }
        if (Util.isNullOrNil(v15.f76890o) && !Util.isNullOrNil(v15.J)) {
            v15.f76890o = "" + v15.J.hashCode();
        }
        int i15 = v15.f76850e;
        String str3 = v15.f76846d;
        String str4 = v15.f76890o;
        o(str2, j15, i15, str3, str4, v15.f76878l, v15.f76866i, v15.R, v15.f76910t);
        return str4;
    }

    public static String o(String str, long j15, int i15, String str2, String str3, int i16, int i17, String str4, int i18) {
        d dVar = new d();
        dVar.field_fileFullPath = str;
        dVar.field_appId = str2;
        dVar.field_sdkVer = (long) i15;
        dVar.field_mediaSvrId = str3;
        dVar.field_totalLen = (long) i16;
        dVar.field_status = 101;
        dVar.field_isUpload = false;
        dVar.field_createTime = e6.a();
        dVar.field_lastModifyTime = Util.nowSecond();
        dVar.field_msgInfoId = j15;
        dVar.field_netTimes = 0;
        dVar.field_type = (long) i17;
        Log.i("MicroMsg.AppMsgLogic", "summerbig initDownloadAttach ret[%b], rowid[%d], field_totalLen[%d], type[%d], isLargeFile[%d], destFile[%s], msgLocalId[%s], stack[%s]", Boolean.valueOf(y1.VN0().insert(dVar)), Long.valueOf(dVar.systemRowid), Long.valueOf(dVar.field_totalLen), Long.valueOf(dVar.field_type), Integer.valueOf(i18), str, Long.valueOf(j15), Util.getStack());
        return str3;
    }

    public static boolean p(f4 f4Var, d dVar) {
        if (dVar == null || !u1.k(dVar.field_fileFullPath)) {
            return false;
        }
        if (dVar.q2() || (f4Var.y2() == 1 && dVar.field_isUpload)) {
            return true;
        }
        return false;
    }

    public static boolean q(int i15) {
        switch (i15) {
            case -1879048191:
            case -1879048190:
            case -1879048189:
                return true;
            default:
                return false;
        }
    }

    public static String r(l.b bVar, WXMediaMessage wXMediaMessage, String str, a aVar) {
        byte[] xj02;
        int i15;
        ub0.c cVar;
        g.c();
        int i16 = wXMediaMessage.sdkVer;
        wXMediaMessage.mediaObject.type();
        bVar.f76850e = wXMediaMessage.sdkVer;
        bVar.f76854f = wXMediaMessage.title;
        bVar.f76858g = wXMediaMessage.description;
        bVar.V = wXMediaMessage.mediaTagName;
        bVar.W = wXMediaMessage.messageAction;
        bVar.X = wXMediaMessage.messageExt;
        WXMediaMessage.IMediaObject iMediaObject = wXMediaMessage.mediaObject;
        bVar.f76866i = iMediaObject.type();
        if (aVar != null && !Util.isNullOrNil(aVar.f170978d)) {
            ub0.c cVar2 = (ub0.c) bVar.x(ub0.c.class);
            if (cVar2 != null) {
                cVar = cVar2;
            } else {
                cVar = new ub0.c();
            }
            cVar.f317159d = aVar.f170978d;
            cVar.f317157b = wXMediaMessage.thumbDataHash;
            WXMediaMessage.IMediaObject iMediaObject2 = wXMediaMessage.mediaObject;
            if (iMediaObject2 instanceof WXMusicVideoObject) {
                cVar.f317158c = ((WXMusicVideoObject) iMediaObject2).hdAlbumThumbFileHash;
            }
            if (cVar2 == null) {
                bVar.f(cVar);
            }
        }
        int i17 = bVar.f76866i;
        if (i17 == 7) {
            WXAppExtendObject wXAppExtendObject = (WXAppExtendObject) iMediaObject;
            bVar.f76898q = wXAppExtendObject.extInfo;
            if (!Util.isNullOrNil(wXAppExtendObject.fileData)) {
                g.c();
                byte[] bArr = wXAppExtendObject.fileData;
                int length = bArr.length;
                bVar.f76878l = bArr.length;
                return y(bArr);
            }
            bVar.f76878l = (int) u1.l(wXAppExtendObject.filePath);
            g.c();
            String str2 = wXAppExtendObject.filePath;
            if (bVar.f76878l <= 0) {
                return null;
            }
            bVar.f76886n = u1.o(str2);
            return wXAppExtendObject.filePath;
        }
        int i18 = -1;
        if (i17 == 49) {
            int i19 = ((WXWeWorkObject) iMediaObject).subType;
            if (i19 == 1 || i19 == 2) {
                i18 = 19;
            }
            bVar.f76866i = i18;
            return null;
        } else if (i17 == 6) {
            WXFileObject wXFileObject = (WXFileObject) iMediaObject;
            if (!Util.isNullOrNil(wXFileObject.fileData)) {
                g.c();
                byte[] bArr2 = wXFileObject.fileData;
                int length2 = bArr2.length;
                bVar.f76878l = bArr2.length;
                return y(bArr2);
            }
            bVar.f76878l = (int) u1.l(wXFileObject.filePath);
            g.c();
            String str3 = wXFileObject.filePath;
            if (bVar.f76878l <= 0) {
                return null;
            }
            bVar.f76886n = u1.o(str3);
            return wXFileObject.filePath;
        } else {
            String str4 = "";
            boolean z15 = false;
            if (i17 == 2) {
                WXImageObject wXImageObject = (WXImageObject) iMediaObject;
                if (!Util.isNullOrNil(wXImageObject.imageData)) {
                    g.c();
                    byte[] bArr3 = wXImageObject.imageData;
                    int length3 = bArr3.length;
                    bVar.f76878l = bArr3.length;
                    return y(bArr3);
                }
                if (!Util.isNullOrNil(wXImageObject.imagePath)) {
                    bVar.f76878l = (int) u1.l(wXImageObject.imagePath);
                    g.c();
                    String str5 = wXImageObject.imagePath;
                    if (bVar.f76878l > 0) {
                        bVar.f76886n = u1.o(str5);
                        String o15 = new q1(p3.b().d(), "appmsg_img_" + System.currentTimeMillis()).o();
                        BitmapFactory.Options imageOptions = BitmapUtil.getImageOptions(wXImageObject.imagePath);
                        if (imageOptions == null || imageOptions.outWidth <= 0 || imageOptions.outHeight <= 0) {
                            Object[] objArr = new Object[3];
                            objArr[0] = Boolean.valueOf(imageOptions == null);
                            if (imageOptions == null) {
                                i15 = -1;
                            } else {
                                i15 = imageOptions.outWidth;
                            }
                            objArr[1] = Integer.valueOf(i15);
                            if (imageOptions != null) {
                                i18 = imageOptions.outHeight;
                            }
                            objArr[2] = Integer.valueOf(i18);
                            Log.e("MicroMsg.AppMsgLogic", "options is null! %B, bitmapWidth = %d, bitmapHeight = %d", objArr);
                        } else if (u0.a(wXImageObject.imagePath, str4, true)) {
                            Log.i("MicroMsg.AppMsgLogic", "this picture can send raw image but must copy [%s] to [%s]", wXImageObject.imagePath, o15);
                            if (u1.d(wXImageObject.imagePath, o15, false) >= 0) {
                                return o15;
                            }
                            Log.w("MicroMsg.AppMsgLogic", "copy file error path[%s, %s]", wXImageObject.imagePath, o15);
                            return null;
                        } else {
                            if (imageOptions.outWidth > 960 || imageOptions.outHeight > 960) {
                                Bitmap extractThumbNail = BitmapUtil.extractThumbNail(wXImageObject.imagePath, 960, 960, false);
                                if (extractThumbNail != null) {
                                    try {
                                        BitmapUtil.saveBitmapToImage(extractThumbNail, 100, Bitmap.CompressFormat.JPEG, o15, true);
                                    } catch (IOException e15) {
                                        Log.printErrStackTrace("MicroMsg.AppMsgLogic", e15, str4, new Object[0]);
                                    }
                                }
                                return null;
                            } else if (u1.d(wXImageObject.imagePath, o15, false) < 0) {
                                return null;
                            }
                            return o15;
                        }
                    }
                }
                return null;
            } else if (i17 == 3) {
                WXMusicObject wXMusicObject = (WXMusicObject) iMediaObject;
                bVar.f76870j = wXMusicObject.musicUrl;
                bVar.f76874k = wXMusicObject.musicLowBandUrl;
                bVar.T = wXMusicObject.musicDataUrl;
                bVar.U = wXMusicObject.musicLowBandDataUrl;
                com.tencent.mm.pluginsdk.ui.tools.m mVar = new com.tencent.mm.pluginsdk.ui.tools.m();
                mVar.f173290b = wXMusicObject.songAlbumUrl;
                mVar.f173291c = wXMusicObject.songLyric;
                bVar.f(mVar);
                return null;
            } else if (i17 == 76) {
                WXMusicVideoObject wXMusicVideoObject = (WXMusicVideoObject) iMediaObject;
                String str6 = wXMusicVideoObject.hdAlbumThumbFilePath;
                if (u1.k(str6) && (xj02 = ((zz.g) yz3.j.c(zz.g.class)).xj0(u1.N(str6, 0, -1))) != null) {
                    wXMediaMessage.thumbData = xj02;
                }
                bVar.f76870j = wXMusicVideoObject.musicUrl;
                bVar.T = wXMusicVideoObject.musicDataUrl;
                com.tencent.mm.pluginsdk.ui.tools.m mVar2 = new com.tencent.mm.pluginsdk.ui.tools.m();
                mVar2.f173290b = aVar != null ? aVar.f170977c : str4;
                mVar2.f173296h = wXMusicVideoObject.singerName;
                mVar2.f173297i = wXMusicVideoObject.albumName;
                mVar2.f173291c = wXMusicVideoObject.songLyric;
                mVar2.f173298j = wXMusicVideoObject.musicGenre;
                mVar2.f173299k = String.valueOf(wXMusicVideoObject.issueDate);
                mVar2.f173300l = wXMusicVideoObject.identification;
                mVar2.f173302n = wXMusicVideoObject.duration;
                mVar2.f173301m = bVar.X;
                mVar2.f173303o = wXMusicVideoObject.musicOperationUrl;
                WXMusicVipInfo wXMusicVipInfo = wXMusicVideoObject.musicVipInfo;
                if (wXMusicVipInfo != null) {
                    str4 = bh0.d.f(wXMusicVipInfo.musicId);
                }
                mVar2.f173304p = str4;
                Object[] objArr2 = new Object[4];
                objArr2[0] = wXMusicVideoObject.singerName;
                if (wXMusicVideoObject.musicVipInfo != null) {
                    z15 = true;
                }
                objArr2[1] = Boolean.valueOf(z15);
                objArr2[2] = wXMusicVideoObject.identification;
                objArr2[3] = bVar.X;
                Log.i("MicroMsg.AppMsgLogic", "share music mv to chatting, singerName:%s, musicVipInfo is valid:%b, identification: %s, extInfo: %s", objArr2);
                bVar.f(mVar2);
                return null;
            } else if (i17 == 4) {
                WXVideoObject wXVideoObject = (WXVideoObject) iMediaObject;
                bVar.f76870j = wXVideoObject.videoUrl;
                bVar.f76874k = wXVideoObject.videoLowBandUrl;
                return null;
            } else if (i17 == 5 || i17 == 54 || i17 == 69) {
                WXWebpageObject wXWebpageObject = (WXWebpageObject) iMediaObject;
                bVar.f76870j = wXWebpageObject.webpageUrl;
                if (!Util.isNullOrNil(wXWebpageObject.extInfo)) {
                    bVar.f76898q = wXWebpageObject.extInfo;
                }
                if (!Util.isNullOrNil(wXWebpageObject.canvasPageXml)) {
                    bVar.C2 = wXWebpageObject.canvasPageXml;
                }
                if (bVar.f76866i == 69 && (wXWebpageObject instanceof c92.b)) {
                    c92.b bVar2 = (c92.b) wXWebpageObject;
                    c92.a aVar2 = new c92.a();
                    aVar2.f48330b = bVar2.f48335a;
                    aVar2.f48331c = bVar2.f48336b;
                    aVar2.f48332d = bVar2.f48337c;
                    aVar2.f48333e = bVar2.f48338d;
                    aVar2.f48334f = bVar2.f48339e;
                    bVar.f(aVar2);
                }
                return null;
            } else {
                if (i17 == 36 || i17 == 46 || i17 == 48) {
                    WXMiniProgramObject wXMiniProgramObject = (WXMiniProgramObject) iMediaObject;
                    bVar.f76857f2 = wXMiniProgramObject.userName;
                    bVar.f76853e2 = wXMiniProgramObject.path;
                    bVar.f76870j = wXMiniProgramObject.webpageUrl;
                    WxaAttributes e35 = ((c1) yz3.j.c(c1.class)).e3(wXMiniProgramObject.userName);
                    if (e35 != null) {
                        if (e35.t2() != null) {
                            bVar.A2 = e35.t2().f85657d;
                        }
                        bVar.B2 = e35.field_brandIconURL;
                        Log.i("MicroMsg.AppMsgLogic", "add appbrand version and appbrand icon url : %d, %s", Integer.valueOf(bVar.A2), bVar.B2);
                    }
                } else if (i17 == 1) {
                    bVar.f76854f = ((WXTextObject) iMediaObject).text;
                    return null;
                } else if (i17 == 8) {
                    WXEmojiObject wXEmojiObject = (WXEmojiObject) iMediaObject;
                    if (!Util.isNullOrNil(wXEmojiObject.emojiData)) {
                        g.c();
                        byte[] bArr4 = wXEmojiObject.emojiData;
                        int length4 = bArr4.length;
                        bVar.f76878l = bArr4.length;
                        return y(bArr4);
                    } else if (!Util.isNullOrNil(wXEmojiObject.emojiPath)) {
                        bVar.f76878l = (int) u1.l(wXEmojiObject.emojiPath);
                        g.c();
                        String str7 = wXEmojiObject.emojiPath;
                        if (bVar.f76878l <= 0) {
                            return null;
                        }
                        bVar.f76886n = u1.o(str7);
                        return wXEmojiObject.emojiPath;
                    } else {
                        bVar.f76894p = str;
                    }
                } else if (i17 == 15) {
                    WXEmojiSharedObject wXEmojiSharedObject = (WXEmojiSharedObject) iMediaObject;
                    bVar.f76930y = wXEmojiSharedObject.thumburl;
                    bVar.f76871j0 = wXEmojiSharedObject.packageflag;
                    bVar.f76867i0 = wXEmojiSharedObject.packageid;
                    bVar.H = 8;
                    bVar.f76870j = wXEmojiSharedObject.url;
                    return null;
                } else if (i17 == 13) {
                    WXEmojiSharedObject wXEmojiSharedObject2 = (WXEmojiSharedObject) iMediaObject;
                    bVar.f76930y = wXEmojiSharedObject2.thumburl;
                    bVar.f76871j0 = wXEmojiSharedObject2.packageflag;
                    bVar.f76867i0 = wXEmojiSharedObject2.packageid;
                    bVar.H = 8;
                    bVar.f76870j = wXEmojiSharedObject2.url;
                    return null;
                } else if (i17 == 68) {
                    WXLiteAppObject wXLiteAppObject = (WXLiteAppObject) iMediaObject;
                    bVar.f76870j = wXLiteAppObject.webpageUrl;
                    bVar.f76905r2 = wXLiteAppObject.userName;
                    bVar.f76909s2 = wXLiteAppObject.path;
                    bVar.f76913t2 = wXLiteAppObject.query;
                    bVar.f76917u2 = wXLiteAppObject.source;
                    bVar.H = 0;
                    return null;
                } else if (i17 == 25) {
                    WXDesignerSharedObject wXDesignerSharedObject = (WXDesignerSharedObject) iMediaObject;
                    bVar.f76930y = wXDesignerSharedObject.thumburl;
                    bVar.f76870j = wXDesignerSharedObject.url;
                    bVar.J1 = wXDesignerSharedObject.designerUIN;
                    bVar.K1 = wXDesignerSharedObject.designerName;
                    bVar.L1 = wXDesignerSharedObject.designerRediretctUrl;
                    bVar.H = 18;
                    return null;
                } else if (i17 == 27 || i17 == 26) {
                    WXEmojiPageSharedObject wXEmojiPageSharedObject = (WXEmojiPageSharedObject) iMediaObject;
                    String str8 = wXEmojiPageSharedObject.iconUrl;
                    bVar.f76930y = str8;
                    bVar.f76870j = wXEmojiPageSharedObject.url;
                    bVar.M1 = wXEmojiPageSharedObject.tid;
                    bVar.N1 = wXEmojiPageSharedObject.title;
                    bVar.O1 = wXEmojiPageSharedObject.desc;
                    bVar.P1 = str8;
                    bVar.Q1 = wXEmojiPageSharedObject.secondUrl;
                    bVar.R1 = wXEmojiPageSharedObject.pageType;
                    bVar.H = 20;
                    return null;
                } else if (i17 == 97) {
                    qc1.k0 k0Var = (qc1.k0) iMediaObject;
                    String str9 = k0Var.iconUrl;
                    bVar.f76930y = str9;
                    bVar.f76870j = k0Var.url;
                    bVar.M1 = k0Var.tid;
                    bVar.N1 = k0Var.title;
                    bVar.O1 = k0Var.desc;
                    bVar.P1 = str9;
                    bVar.Q1 = k0Var.secondUrl;
                    bVar.R1 = k0Var.pageType;
                    bVar.S1 = k0Var.f288731a;
                    bVar.H = 0;
                    return null;
                } else if (i17 == 101) {
                    WXNativeGamePageObject wXNativeGamePageObject = (WXNativeGamePageObject) iMediaObject;
                    com.tencent.mm.pluginsdk.ui.tools.l lVar = new com.tencent.mm.pluginsdk.ui.tools.l();
                    bVar.f76870j = "https://support.weixin.qq.com/update/";
                    LiteAppBizDataInfo liteAppBizDataInfo = aVar.f170980f;
                    if (liteAppBizDataInfo == null) {
                        Log.e("MicroMsg.AppMsgLogic", "johnjh msg gamepageobject or liteappbizdatainfo is null");
                        return null;
                    }
                    bVar.f76905r2 = liteAppBizDataInfo.f127728d;
                    bVar.f76909s2 = liteAppBizDataInfo.f127729e;
                    bVar.f76913t2 = liteAppBizDataInfo.f127730f;
                    bVar.f76917u2 = liteAppBizDataInfo.f127732h.intValue();
                    LiteAppBizDataInfo liteAppBizDataInfo2 = aVar.f170980f;
                    lVar.f173273b = liteAppBizDataInfo2.f127731g;
                    lVar.f173274c = liteAppBizDataInfo2.f127733i;
                    if (wXNativeGamePageObject.isVideo) {
                        lVar.f173277f = 1;
                    } else {
                        lVar.f173277f = 0;
                    }
                    lVar.f173278g = wXNativeGamePageObject.videoDuration;
                    lVar.f173276e = wXNativeGamePageObject.shareData;
                    lVar.f173275d = aVar.f170979e;
                    lVar.f173279h = 0;
                    bVar.f(lVar);
                    return null;
                }
                return null;
            }
        }
    }

    public static int s(long j15, String str, String str2) {
        d sb5 = y1.VN0().sb(j15);
        if (sb5 == null) {
            Log.e("MicroMsg.AppMsgLogic", "ERR:" + g.c() + " getinfo failed: " + str2);
            return -1;
        } else if (sb5.field_status != 101) {
            Log.e("MicroMsg.AppMsgLogic", "ERR:" + g.c() + " get status failed: " + str2 + " status:" + sb5.field_status);
            return -1;
        } else {
            sb5.field_status = 102;
            sb5.field_lastModifyTime = Util.nowSecond();
            y1.VN0().update(sb5, new String[0]);
            String m15 = p.m1(sb5.field_createTime, str, j15);
            com.tencent.mm.modelcdntran.e.f78686a.a(m15, new WeakReference<>(null));
            Log.i("MicroMsg.AppMsgLogic", "pauseDownloadAttach %s %s %s %s", Long.valueOf(j15), str, str2, m15);
            return 0;
        }
    }

    public static int t(long j15, String str) {
        d sb5 = y1.VN0().sb(j15);
        if (sb5 == null) {
            Log.e("MicroMsg.AppMsgLogic", "ERR:" + g.c() + " getinfo failed: " + str);
            return -1;
        } else if (sb5.field_status != 101) {
            Log.e("MicroMsg.AppMsgLogic", "ERR:" + g.c() + " get status failed: " + str + " status:" + sb5.field_status);
            return -1;
        } else {
            if (!Util.isNullOrNil(sb5.field_clientAppDataId) || Util.isNullOrNil(sb5.field_mediaSvrId)) {
                sb5.field_status = 105;
            } else {
                sb5.field_status = 102;
            }
            sb5.field_lastModifyTime = Util.nowSecond();
            y1.VN0().update(sb5, new String[0]);
            return 0;
        }
    }

    public static int u(long j15, String str) {
        d sb5 = y1.VN0().sb(j15);
        if (sb5 == null) {
            Log.e("MicroMsg.AppMsgLogic", "ERR:" + g.c() + " getinfo failed: " + str);
            return -1;
        }
        long j16 = sb5.field_status;
        if (j16 == 105 || j16 == 101) {
            sb5.field_status = 101;
            sb5.field_lastModifyTime = Util.nowSecond();
            y1.VN0().update(sb5, new String[0]);
            y1.ZN0().d();
            return 0;
        }
        Log.e("MicroMsg.AppMsgLogic", "ERR:" + g.c() + " get status failed: " + str + " status:" + sb5.field_status);
        return -1;
    }

    public static int v(long j15, String str, vi.f fVar, boolean z15) {
        String str2;
        String str3;
        String str4;
        String str5;
        int a15;
        f4 tz4 = ((g4) p3.b().z()).tz(j15);
        if (tz4.getMsgId() != j15) {
            Log.e("MicroMsg.AppMsgLogic", g.c() + " getmsgFailed id:" + j15);
            a15 = g.a();
        } else {
            l.b v15 = l.b.v(tz4.getContent(), null);
            if (v15 == null) {
                Log.e("MicroMsg.AppMsgLogic", g.c() + " getmsgFailed id:" + j15);
                a15 = g.a();
            } else if (v15.f76866i == 6 && tz4.getType() == 10000) {
                Log.e("MicroMsg.AppMsgLogic", "rebuildXMLAtUploadFin: stop send revoke msg(%s)", Long.valueOf(tz4.getMsgId()));
                return -1;
            } else {
                v15.f76890o = str;
                if (z15 && fVar != null) {
                    if (fVar.field_aesKey.equals("")) {
                        str2 = v15.R;
                    } else {
                        str2 = fVar.field_aesKey;
                    }
                    v15.R = str2;
                    if (fVar.field_fileId.equals("")) {
                        str3 = v15.J;
                    } else {
                        str3 = fVar.field_fileId;
                    }
                    v15.J = str3;
                    if (fVar.field_filemd5.equals("")) {
                        str4 = v15.f76906s;
                    } else {
                        str4 = fVar.field_filemd5;
                    }
                    v15.f76906s = str4;
                    long j16 = fVar.field_fileLength;
                    v15.f76878l = j16 == 0 ? v15.f76878l : (int) j16;
                    if (fVar.field_thumbUrl.equals("")) {
                        str5 = v15.K;
                    } else {
                        str5 = fVar.field_thumbUrl;
                    }
                    v15.K = str5;
                }
                tz4.R2(l.b.t(v15, v15.f76890o, fVar));
                ((g4) p3.b().z()).CA0(tz4.getMsgId(), tz4);
                l c05 = y1.aO0().c0(j15);
                if (c05 != null) {
                    c05.field_xml = tz4.getContent();
                    y1.aO0().update(c05, "msgId");
                }
                if (z15) {
                    d sb5 = y1.VN0().sb(j15);
                    sb5.field_mediaSvrId = str;
                    sb5.field_offset = sb5.field_totalLen;
                    y1.VN0().update(sb5, new String[0]);
                }
                return 0;
            }
        }
        return 0 - a15;
    }

    /* JADX WARNING: Removed duplicated region for block: B:23:0x008d  */
    /* JADX WARNING: Removed duplicated region for block: B:26:0x00a9  */
    /* JADX WARNING: Removed duplicated region for block: B:33:0x00ba  */
    /* JADX WARNING: Removed duplicated region for block: B:34:0x00cf  */
    /* JADX WARNING: Removed duplicated region for block: B:41:0x00e4  */
    /* JADX WARNING: Removed duplicated region for block: B:43:0x00e9  */
    /* JADX WARNING: Removed duplicated region for block: B:50:0x014d  */
    /* JADX WARNING: Removed duplicated region for block: B:53:0x0156  */
    /* JADX WARNING: Removed duplicated region for block: B:54:0x015f  */
    /* JADX WARNING: Removed duplicated region for block: B:57:0x0173  */
    /* JADX WARNING: Removed duplicated region for block: B:60:0x0196  */
    /* JADX WARNING: Removed duplicated region for block: B:61:0x01c5  */
    public static Pair<Integer, Long> w(f4 f4Var) {
        String str;
        byte[] bArr;
        l.b i15;
        d dVar;
        String Za0;
        long Am0;
        int i16;
        String str2;
        String str3;
        l.b v15 = l.b.v(f4Var.getContent(), null);
        if (v15 == null) {
            Log.e("MicroMsg.AppMsgLogic", "resend app message error: app content null");
            return null;
        }
        d g15 = g(v15.f76890o);
        if (g15 == null || (str3 = g15.field_fileFullPath) == null || str3.equals("")) {
            str = "";
        } else {
            str = e(p3.b().d(), v15.f76854f, v15.f76886n);
            u1.c(g15.field_fileFullPath, str);
        }
        int i17 = 1;
        if (f4Var.x2() != null && !f4Var.x2().equals("")) {
            try {
                bArr = u1.N(((w) ((yt.j) yz3.j.c(yt.j.class)).ol()).BD(f4Var.x2(), true), 0, -1);
            } catch (Exception unused) {
            }
            i15 = l.b.i(v15);
            String str4 = v15.F;
            String str5 = System.currentTimeMillis() + "";
            if (Util.isNullOrNil(str)) {
                dVar = a(str5, i15, str);
                if (dVar == null) {
                    return new Pair<>(Integer.valueOf(0 - g.a()), -1L);
                }
            } else {
                dVar = null;
            }
            f4 f4Var2 = new f4();
            if (bArr != null && bArr.length > 0) {
                i16 = i15.f76866i;
                if (i16 != 46) {
                    str2 = ((w) ((yt.j) yz3.j.c(yt.j.class)).ol()).zW(bArr, 100, Bitmap.CompressFormat.JPEG);
                } else {
                    str2 = x(bArr, i16 == 2, Bitmap.CompressFormat.PNG, false);
                }
                g.c();
                if (!Util.isNullOrNil(str2)) {
                    f4Var2.Y2(str2);
                }
            }
            if (dVar != null) {
                i15.f76890o = "" + dVar.systemRowid;
                if (i15.f76866i == 6 && Util.isNullOrNil(i15.f76906s)) {
                    i15.f76906s = com.tencent.mm.modelcdntran.h0.fO0().e(dVar.field_fileFullPath);
                }
            }
            f4Var2.R2(l.b.t(i15, null, null));
            f4Var2.c(1);
            f4Var2.i3(f4Var.i());
            f4Var2.S2(nf0.f4.o(f4Var.i()));
            f4Var2.Z2(1);
            f4Var2.setType(l(i15));
            Za0 = ((x0) yz3.j.c(x0.class)).Za0(f4Var2);
            if (!Util.isNullOrNil(Za0)) {
                f4Var2.y4(Za0);
            }
            if (i15.f76866i != 53) {
                f4Var2.U = f4Var.U;
                f4Var2.f263806r = true;
            }
            Am0 = ((g4) p3.b().z()).Am0(f4Var2);
            if (i15.f76866i == 53) {
                NotifyGroupSolitatireEvent notifyGroupSolitatireEvent = new NotifyGroupSolitatireEvent();
                NotifyGroupSolitatireEvent.a aVar = notifyGroupSolitatireEvent.f63664d;
                aVar.f63666a = 0;
                aVar.f63668c = f4Var2.U;
                aVar.f63667b = f4Var2.i();
                notifyGroupSolitatireEvent.f63665e.f63670a = Am0;
                notifyGroupSolitatireEvent.publish();
            }
            g.c();
            if (Am0 >= 0) {
                Log.e("MicroMsg.AppMsgLogic", g.c() + "insert msg failed :" + Am0);
                return new Pair<>(Integer.valueOf(0 - g.a()), Long.valueOf(Am0));
            }
            Log.i("MicroMsg.AppMsgLogic", g.a() + " new msg inserted to db , local id = " + Am0);
            f4Var2.setMsgId(Am0);
            UpdateFailedMsgIdEvent updateFailedMsgIdEvent = new UpdateFailedMsgIdEvent();
            updateFailedMsgIdEvent.f64940d.f64941a = f4Var.getMsgId();
            updateFailedMsgIdEvent.f64940d.f64942b = Am0;
            updateFailedMsgIdEvent.publish();
            l lVar = new l();
            lVar.field_xml = f4Var2.getContent();
            lVar.field_title = i15.f76854f;
            lVar.field_type = i15.f76866i;
            lVar.field_description = i15.f76858g;
            lVar.field_msgId = Am0;
            lVar.field_source = str4;
            y1.aO0().insert(lVar);
            if (dVar != null) {
                dVar.field_msgInfoId = Am0;
                dVar.field_status = 101;
                y1.VN0().update(dVar, new String[0]);
                K(f4Var2, dVar);
            } else {
                int i18 = i15.f76866i;
                if (i18 == 24 || i18 == 19) {
                    kc4 x15 = j0.x(i15.f76855f0);
                    ng0 ng02 = new ng0();
                    if (x15 != null) {
                        ng02.f30861f.addAll(x15.f27168f);
                    }
                    String i19 = f4Var.i();
                    List synchronizedList = Collections.synchronizedList(new ArrayList());
                    Iterator<tf0> it = ng02.f30861f.iterator();
                    while (it.hasNext()) {
                        tf0 next = it.next();
                        if (next.R > 26214400) {
                            c.b bVar = new c.b();
                            String q15 = j0.q(next, Am0, i17);
                            String q16 = u1.q(q15);
                            bVar.f304316g = i19;
                            bVar.f304314e = next.R;
                            bVar.f304313d = next.K;
                            if (!Util.isNullOrNil(next.M)) {
                                q16 = next.M;
                            }
                            bVar.f304310a = q16;
                            bVar.f304311b = next.f37521u;
                            bVar.f304312c = next.f37489d;
                            if (!Util.isNullOrNil(next.V)) {
                                q15 = next.V;
                            }
                            bVar.f304315f = q15;
                            synchronizedList.add(bVar);
                            i17 = 1;
                        }
                    }
                    if (synchronizedList.size() > 0) {
                        z.d().f(new ru3.a(synchronizedList, new y(Am0, f4Var, i19, i15, ng02, x15, f4Var2)));
                    } else {
                        y1.ZN0().b(Am0);
                    }
                } else {
                    y1.ZN0().b(Am0);
                }
            }
            return new Pair<>(0, Long.valueOf(Am0));
        }
        bArr = null;
        i15 = l.b.i(v15);
        String str42 = v15.F;
        String str52 = System.currentTimeMillis() + "";
        if (Util.isNullOrNil(str)) {
        }
        f4 f4Var22 = new f4();
        i16 = i15.f76866i;
        if (i16 != 46) {
        }
        g.c();
        if (!Util.isNullOrNil(str2)) {
        }
        if (dVar != null) {
        }
        f4Var22.R2(l.b.t(i15, null, null));
        f4Var22.c(1);
        f4Var22.i3(f4Var.i());
        f4Var22.S2(nf0.f4.o(f4Var.i()));
        f4Var22.Z2(1);
        f4Var22.setType(l(i15));
        Za0 = ((x0) yz3.j.c(x0.class)).Za0(f4Var22);
        if (!Util.isNullOrNil(Za0)) {
        }
        if (i15.f76866i != 53) {
        }
        Am0 = ((g4) p3.b().z()).Am0(f4Var22);
        if (i15.f76866i == 53) {
        }
        g.c();
        if (Am0 >= 0) {
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:37:0x00d7  */
    /* JADX WARNING: Removed duplicated region for block: B:39:0x00dc A[SYNTHETIC, Splitter:B:39:0x00dc] */
    /* JADX WARNING: Removed duplicated region for block: B:47:0x0106  */
    /* JADX WARNING: Removed duplicated region for block: B:49:0x010b A[SYNTHETIC, Splitter:B:49:0x010b] */
    public static String x(byte[] bArr, boolean z15, Bitmap.CompressFormat compressFormat, boolean z16) {
        String str;
        Throwable th5;
        OutputStream outputStream;
        Exception e15;
        if (z16) {
            str = ((w) ((yt.j) yz3.j.c(yt.j.class)).ol()).te(bArr);
        } else {
            w wVar = (w) ((yt.j) yz3.j.c(yt.j.class)).ol();
            wVar.getClass();
            OutputStream outputStream2 = null;
            if (Util.isNullOrNil(bArr)) {
                Log.e("MicroMsg.ImgInfoStorage", "saveDirThumbForAppMsg save dir thumb error, thumbBuf is null");
            } else {
                String Se = w.Se();
                String Xv = wVar.Xv(Se, "msgth_", "", true);
                String str2 = Xv + ".tmp";
                try {
                    outputStream = u1.J(str2, false);
                    try {
                        outputStream.write(bArr);
                        outputStream.flush();
                        int i15 = 128;
                        int i16 = z15 ? 128 : 120;
                        if (!z15) {
                            i15 = 120;
                        }
                        Bitmap extractThumbNail = BitmapUtil.extractThumbNail(str2, i16, i15, false);
                        if (extractThumbNail != null) {
                            BitmapUtil.saveBitmapToImage(extractThumbNail, 90, compressFormat, Xv, true);
                        }
                        if (u1.k(str2)) {
                            u1.h(str2);
                        }
                        try {
                            outputStream.close();
                        } catch (Exception unused) {
                        }
                        str = "THUMBNAIL_APPMSG_DIR://msgth_" + Se;
                    } catch (Exception e16) {
                        e15 = e16;
                        try {
                            com.tencent.mm.plugin.report.service.q.INSTANCE.idkeyStat(111, 189, 1, false);
                            Log.e("MicroMsg.ImgInfoStorage", "create thumbnail from byte failed: msgth_" + Se + ", ex = " + e15.getMessage());
                            if (u1.k(str2)) {
                                u1.h(str2);
                            }
                            if (outputStream != null) {
                                try {
                                    outputStream.close();
                                } catch (Exception unused2) {
                                }
                            }
                            str = null;
                            Log.i("MicroMsg.AppMsgLogic", "saveAppMsgDirThumb directSave:" + z16 + "  path:" + str);
                            return str;
                        } catch (Throwable th6) {
                            th5 = th6;
                            outputStream2 = outputStream;
                            if (u1.k(str2)) {
                            }
                            if (outputStream2 != null) {
                            }
                            throw th5;
                        }
                    }
                } catch (Exception e17) {
                    e15 = e17;
                    outputStream = null;
                    com.tencent.mm.plugin.report.service.q.INSTANCE.idkeyStat(111, 189, 1, false);
                    Log.e("MicroMsg.ImgInfoStorage", "create thumbnail from byte failed: msgth_" + Se + ", ex = " + e15.getMessage());
                    if (u1.k(str2)) {
                    }
                    if (outputStream != null) {
                    }
                    str = null;
                    Log.i("MicroMsg.AppMsgLogic", "saveAppMsgDirThumb directSave:" + z16 + "  path:" + str);
                    return str;
                } catch (Throwable th7) {
                    th5 = th7;
                    if (u1.k(str2)) {
                        u1.h(str2);
                    }
                    if (outputStream2 != null) {
                        try {
                            outputStream2.close();
                        } catch (Exception unused3) {
                        }
                    }
                    throw th5;
                }
            }
            str = null;
        }
        Log.i("MicroMsg.AppMsgLogic", "saveAppMsgDirThumb directSave:" + z16 + "  path:" + str);
        return str;
    }

    public static String y(byte[] bArr) {
        if (Util.isNullOrNil(bArr)) {
            Log.e("MicroMsg.AppMsgLogic", g.c() + " attachBuf is null");
            return null;
        }
        String str = p3.b().d() + "ua_" + Util.nowMilliSecond();
        g.c();
        if (u1.S(str, bArr, 0, bArr.length) == 0) {
            return str;
        }
        Log.e("MicroMsg.AppMsgLogic", g.c() + " writeFile error file:" + str);
        return null;
    }

    public static int z(l.b bVar, WXMediaMessage wXMediaMessage, String str, String str2, int i15, a aVar) {
        return A(bVar, wXMediaMessage, str, str2, null, i15, aVar, null, null, null, null, null);
    }
}