package com.tencent.mm.plugin.sns.storage;

import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import android.graphics.Point;
import android.graphics.Rect;
import android.media.ExifInterface;
import android.text.TextUtils;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.a.g;
import com.tencent.mm.al.f;
import com.tencent.mm.cd.h;
import com.tencent.mm.compatible.util.Exif;
import com.tencent.mm.memory.l;
import com.tencent.mm.platformtools.ae;
import com.tencent.mm.plugin.i.a;
import com.tencent.mm.plugin.sns.data.i;
import com.tencent.mm.plugin.sns.model.af;
import com.tencent.mm.protocal.protobuf.bar;
import com.tencent.mm.protocal.protobuf.bax;
import com.tencent.mm.sdk.e.k;
import com.tencent.mm.sdk.platformtools.BackwardSupportUtil.ExifHelper;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.sdk.platformtools.d;
import com.tencent.mm.vfs.e;
import com.tencent.ttpic.util.VideoFilterUtil;
import com.tencent.ytcommon.BuildConfig;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

public final class s extends k {
    public static final String[] fnj = new String[]{"CREATE TABLE IF NOT EXISTS SnsMedia ( local_id INTEGER PRIMARY KEY, seqId LONG, type INT, createTime LONG, userName VARCHAR(40), totallen INT, offset INT, local_flag INT, tmp_path TEXT, nums INT, try_times INT, StrId VARCHAR(40), upload_buf TEXT, reserved1 INT, reserved2 TEXT, reserved3 TEXT, reserved4 TEXT, reserved5 TEXT )", "CREATE INDEX IF NOT EXISTS serverSnsMediaTimeIndex ON SnsMedia ( createTime )"};
    private static int qDU = 0;
    private static int qDc = 0;
    private static Point qLw = new Point();
    public h fni;

    static {
        AppMethodBeat.i(38001);
        AppMethodBeat.o(38001);
    }

    public s(h hVar) {
        this.fni = hVar;
    }

    public static int getScreenWidth() {
        return qDU > qDc ? qDc : qDU;
    }

    public static void fs(int i, int i2) {
        AppMethodBeat.i(37978);
        qDU = i;
        qDc = i2;
        ab.i("MicroMsg.snsMediaStorage", "SCREEN %d %d", new Object[]{Integer.valueOf(i), Integer.valueOf(i2)});
        AppMethodBeat.o(37978);
    }

    private static String Zh(String str) {
        AppMethodBeat.i(37979);
        String str2;
        if (str == null) {
            str2 = BuildConfig.FLAVOR;
            AppMethodBeat.o(37979);
            return str2;
        }
        String x = g.x(str.getBytes());
        str2 = BuildConfig.FLAVOR;
        String str3 = BuildConfig.FLAVOR;
        if (x.length() > 0) {
            str2 = x.charAt(0) + "/";
        }
        if (x.length() >= 2) {
            str3 = x.charAt(1) + "/";
        }
        str2 = af.getAccSnsPath() + str2 + str3;
        AppMethodBeat.o(37979);
        return str2;
    }

    private boolean a(r rVar) {
        AppMethodBeat.i(37980);
        ab.d("MicroMsg.snsMediaStorage", "snsMedia Insert");
        if (rVar == null) {
            AppMethodBeat.o(37980);
            return false;
        }
        if (((int) this.fni.insert("SnsMedia", "local_id", rVar.cro())) != -1) {
            AppMethodBeat.o(37980);
            return true;
        }
        AppMethodBeat.o(37980);
        return false;
    }

    public final boolean a(String str, r rVar) {
        AppMethodBeat.i(37981);
        ab.d("MicroMsg.snsMediaStorage", "replace AlbumLikeList ".concat(String.valueOf(str)));
        Cursor a = this.fni.a("SnsMedia", null, "StrId=?", new String[]{String.valueOf(str)}, null, null, null, 2);
        boolean a2;
        if (a.moveToFirst()) {
            a.close();
            a2 = a(rVar);
            AppMethodBeat.o(37981);
            return a2;
        }
        a.close();
        a2 = b(str, rVar);
        AppMethodBeat.o(37981);
        return a2;
    }

    private boolean b(String str, r rVar) {
        AppMethodBeat.i(37982);
        if (this.fni.update("SnsMedia", rVar.cro(), "StrId=?", new String[]{String.valueOf(str)}) > 0) {
            AppMethodBeat.o(37982);
            return true;
        }
        AppMethodBeat.o(37982);
        return false;
    }

    public final int a(int i, r rVar) {
        AppMethodBeat.i(37983);
        int update = this.fni.update("SnsMedia", rVar.cro(), "local_id=?", new String[]{String.valueOf(i)});
        AppMethodBeat.o(37983);
        return update;
    }

    public final r Zi(String str) {
        AppMethodBeat.i(37984);
        r rVar = new r();
        Cursor a = this.fni.a("SnsMedia", null, "StrId=?", new String[]{String.valueOf(str)}, null, null, null, 2);
        if (a.moveToFirst()) {
            rVar.d(a);
            a.close();
            AppMethodBeat.o(37984);
            return rVar;
        }
        a.close();
        AppMethodBeat.o(37984);
        return null;
    }

    public final r kE(long j) {
        AppMethodBeat.i(37985);
        r rVar = new r();
        Cursor a = this.fni.a("SnsMedia", null, "local_id=?", new String[]{String.valueOf(j)}, null, null, null, 2);
        if (a.moveToFirst()) {
            rVar.d(a);
            a.close();
            AppMethodBeat.o(37985);
            return rVar;
        }
        a.close();
        AppMethodBeat.o(37985);
        return null;
    }

    public final List<com.tencent.mm.plugin.sns.data.h> dn(List<com.tencent.mm.plugin.sns.data.h> list) {
        AppMethodBeat.i(37986);
        LinkedList linkedList = new LinkedList();
        if (list == null || list.size() == 0) {
            AppMethodBeat.o(37986);
            return null;
        }
        for (com.tencent.mm.plugin.sns.data.h hVar : list) {
            int a = a(hVar);
            if (a == -1) {
                AppMethodBeat.o(37986);
                return null;
            }
            com.tencent.mm.plugin.sns.data.h hVar2 = new com.tencent.mm.plugin.sns.data.h(a, hVar.type);
            hVar2.height = hVar.height;
            hVar2.width = hVar.width;
            hVar2.fileSize = hVar.fileSize;
            linkedList.add(hVar2);
        }
        AppMethodBeat.o(37986);
        return linkedList;
    }

    private static com.tencent.mm.plugin.sns.data.h a(com.tencent.mm.plugin.sns.data.h hVar, String str) {
        int orientationInDegree;
        Throwable e;
        InputStream inputStream = null;
        int i = 0;
        AppMethodBeat.i(37987);
        try {
            Options options = new Options();
            options.inJustDecodeBounds = true;
            inputStream = e.openRead(str);
            if (!inputStream.markSupported()) {
                inputStream = new BufferedInputStream(inputStream);
            }
            inputStream.mark(1048576);
            BitmapFactory.decodeStream(inputStream, null, options);
            inputStream.reset();
            Exif exif = new Exif();
            exif.parseFromStream(inputStream);
            orientationInDegree = exif.getOrientationInDegree();
            if (orientationInDegree == 90 || orientationInDegree == 270) {
                orientationInDegree = options.outWidth;
                try {
                    i = options.outHeight;
                } catch (Exception e2) {
                    e = e2;
                }
            } else {
                orientationInDegree = options.outHeight;
                i = options.outWidth;
            }
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e3) {
                }
            }
        } catch (Exception e4) {
            e = e4;
            orientationInDegree = i;
            try {
                ab.printErrStackTrace("MicroMsg.snsMediaStorage", e, "setImageExtInfo failed: ".concat(String.valueOf(str)), new Object[0]);
                if (inputStream != null) {
                    try {
                        inputStream.close();
                    } catch (IOException e5) {
                    }
                }
                hVar.width = i;
                hVar.height = orientationInDegree;
                hVar.fileSize = (int) e.asZ(str);
                AppMethodBeat.o(37987);
                return hVar;
            } catch (Throwable th) {
                if (inputStream != null) {
                    try {
                        inputStream.close();
                    } catch (IOException e6) {
                    }
                }
                AppMethodBeat.o(37987);
            }
        }
        hVar.width = i;
        hVar.height = orientationInDegree;
        hVar.fileSize = (int) e.asZ(str);
        AppMethodBeat.o(37987);
        return hVar;
    }

    private int a(com.tencent.mm.plugin.sns.data.h hVar) {
        AppMethodBeat.i(37988);
        String accSnsPath = af.getAccSnsPath();
        String accSnsTmpPath = af.getAccSnsTmpPath();
        ab.i("MicroMsg.snsMediaStorage", "SnsMediaStorage %s %s", new Object[]{accSnsPath, accSnsTmpPath});
        long currentTimeMillis = System.currentTimeMillis();
        String str = hVar.path;
        int i = hVar.type;
        if (e.ct(str)) {
            String x = g.x((str + System.currentTimeMillis()).getBytes());
            String Xe = i.Xe(x);
            ab.d("MicroMsg.snsMediaStorage", "insert : original img path = ".concat(String.valueOf(str)));
            if (!e.ct(accSnsTmpPath)) {
                ab.i("MicroMsg.snsMediaStorage", "create snstmp path ".concat(String.valueOf(accSnsTmpPath)));
                e.tf(accSnsTmpPath);
            }
            if (!e.ct(accSnsPath)) {
                ab.i("MicroMsg.snsMediaStorage", "create snsPath ".concat(String.valueOf(accSnsPath)));
                e.tf(accSnsPath);
            }
            a aVar = new a();
            com.tencent.mm.plugin.sns.data.h a = a(hVar, str);
            int i2 = a.width;
            int i3 = a.height;
            int i4 = a.fileSize;
            aVar.nuw = str;
            aVar.nuy = i2;
            aVar.nuz = i3;
            aVar.nuA = i4;
            if (e(accSnsTmpPath, str, Xe, true)) {
                ab.d("MicroMsg.snsMediaStorage", "insert0 " + (System.currentTimeMillis() - currentTimeMillis));
                ab.d("MicroMsg.snsMediaStorage", "insert: compressed bigMediaPath = ".concat(String.valueOf(Xe)));
                i2 = (int) e.asZ(accSnsTmpPath + Xe);
                if (str.toLowerCase().contains("jpg") || str.toLowerCase().contains("jpeg")) {
                    accSnsPath = d.bR(e.e(str, 0, i2));
                    if (accSnsPath != null) {
                        ab.i("MicroMsg.snsMediaStorage", "insert yuvInfo:%s", new Object[]{accSnsPath});
                        try {
                            ExifInterface exifInterface = new ExifInterface(accSnsTmpPath + Xe);
                            exifInterface.setAttribute("UserComment", accSnsPath);
                            exifInterface.saveAttributes();
                        } catch (Exception e) {
                            ab.printErrStackTrace("MicroMsg.snsMediaStorage", e, BuildConfig.FLAVOR, new Object[0]);
                        }
                    }
                }
                i2 = (int) e.asZ(accSnsTmpPath + Xe);
                com.tencent.mm.plugin.sns.data.h a2 = a(a, accSnsTmpPath + Xe);
                int i5 = a2.width;
                i3 = a2.height;
                aVar.nuB = i5;
                aVar.nuC = i3;
                aVar.nuD = i2;
                r rVar = new r();
                rVar.rfE = x;
                rVar.createTime = (long) ((int) bo.anT());
                rVar.type = i;
                bax bax = new bax();
                bax.wEJ = a2.qFY;
                bax.wFe = a2.qFX;
                bax.token = a2.qFZ;
                bax.wFn = a2.qGa;
                bax.wFB = 0;
                bax.wFA = new bar();
                bax.eRu = 0;
                bax.Desc = a2.desc;
                ab.d("MicroMsg.snsMediaStorage", "upload.filterId " + a2.filterId);
                bax.wFd = a2.filterId;
                bax.wFD = 2;
                bax.cvZ = e.atg(accSnsTmpPath + Xe);
                try {
                    rVar.rfI = bax.toByteArray();
                } catch (Exception e2) {
                    ab.e("MicroMsg.snsMediaStorage", "uploadInfo to byteArray error");
                }
                rVar.crp();
                rVar.rfD = i2;
                ab.i("MicroMsg.snsMediaStorage", "insert a local snsMedia  totallen  :" + i2 + " filepath: " + accSnsTmpPath + Xe);
                i = (int) this.fni.insert("SnsMedia", "local_id", rVar.cro());
                ab.d("MicroMsg.snsMediaStorage", "insert localId ".concat(String.valueOf(i)));
                String concat = "Locall_path".concat(String.valueOf(i));
                aVar.nux = String.valueOf(i);
                aVar.cvZ = bax.cvZ;
                Exif fromFile = Exif.fromFile(aVar.nuw);
                i2 = a.tF(aVar.nuw);
                if (aVar.nuw.indexOf("png") >= 0) {
                    i2 = 1;
                } else if (aVar.nuw.indexOf("jpg") >= 0 || aVar.nuw.indexOf("jpeg") >= 0) {
                    i2 = 2;
                } else if (aVar.nuw.indexOf("mp3") >= 0) {
                    i2 = 3;
                }
                str = fromFile.dateTimeOriginal;
                String str2 = aVar.nuw;
                if (bo.isNullOrNil(str)) {
                    str = a.OK(new SimpleDateFormat("yyyy:MM:dd HH:mm:ss").format(new Date(new File(str2).lastModified())));
                } else {
                    str = a.OK(str);
                }
                com.tencent.mm.modelsns.d dVar = new com.tencent.mm.modelsns.d();
                dVar.l("20 localID", aVar.nux + ",");
                dVar.l("21 MediaType", i2 + ",");
                dVar.l("22 OriginWidth", aVar.nuy + ",");
                dVar.l("23 OriginHeight", aVar.nuz + ",");
                dVar.l("24 CompressedWidth", aVar.nuB + ",");
                dVar.l("25 CompressedHeight", aVar.nuC + ",");
                dVar.l("26 OriginSize", aVar.nuA + ",");
                dVar.l("27 CompressedSize", aVar.nuD + ",");
                dVar.l("28 FNumber", fromFile.fNumber + ",");
                dVar.l("29 ExposureTime", fromFile.exposureTime + ",");
                dVar.l("30 ISO", fromFile.isoSpeedRatings + ",");
                dVar.l("31 Flash", fromFile.flash + ",");
                dVar.l("32 LensModel", a.OK(fromFile.model) + ",");
                dVar.l("33 CreatTime", str + ",");
                dVar.l("34 IsFromWeChat", "0,");
                dVar.l("35 Scene", ",");
                dVar.l("36 sceneType", fromFile.sceneType + ",");
                dVar.l("37 fileSource", fromFile.fileSource + ",");
                dVar.l("38 make", fromFile.make + ",");
                dVar.l("39 software", fromFile.software + ",");
                dVar.l("40 fileExt", a.cv(aVar.nuw) + ",");
                dVar.l("41 faceCount", "0,");
                dVar.l("42 YCbCrSubSampling", fromFile.yCbCrSubSampling + ",");
                dVar.l("43 md5", aVar.cvZ + ',');
                ab.v("MicroMsg.ImgExtInfoReport", "report logbuffer MMImageExifInfo(14525): %s, orgPath:%s", new Object[]{dVar.Fk(), aVar.nuw});
                com.tencent.mm.plugin.report.service.h.pYm.e(14525, new Object[]{dVar});
                com.tencent.mm.plugin.sns.i.d.coE().qSY.put(Integer.valueOf(i), dVar.toString());
                accSnsPath = i.Xe(concat);
                str = Zh(concat);
                e.tf(str);
                ab.i("MicroMsg.snsMediaStorage", "checkcntpath ".concat(String.valueOf(str)));
                e.y(accSnsTmpPath + Xe, str + accSnsPath);
                accSnsTmpPath = str + i.Xa(concat);
                x = str + i.Xb(concat);
                e.deleteFile(accSnsTmpPath);
                e.deleteFile(x);
                ab.i("MicroMsg.snsMediaStorage", "insert done " + (System.currentTimeMillis() - currentTimeMillis) + " targetPath : " + str + accSnsPath + " totalLen:" + e.asZ(str + accSnsPath) + "  now delete...:" + accSnsTmpPath + " & " + x);
                rVar.rfE = concat;
                a(i, rVar);
                AppMethodBeat.o(37988);
                return i;
            }
            AppMethodBeat.o(37988);
            return -1;
        }
        AppMethodBeat.o(37988);
        return -1;
    }

    public final com.tencent.mm.plugin.sns.data.h a(com.tencent.mm.plugin.sns.data.h hVar, String str, String str2, String str3, String str4) {
        AppMethodBeat.i(37989);
        r rVar = new r();
        rVar.createTime = (long) ((int) bo.anT());
        rVar.type = hVar.type;
        bax bax = new bax();
        bax.wEJ = hVar.qFY;
        bax.wFe = hVar.qFX;
        bax.token = hVar.qFZ;
        bax.wFn = hVar.qGa;
        bax.wFB = 0;
        bax.wFA = new bar();
        bax.eRu = 0;
        bax.Desc = hVar.desc;
        ab.d("MicroMsg.snsMediaStorage", "upload.filterId " + hVar.filterId);
        bax.wFd = hVar.filterId;
        bax.wFD = 2;
        bax.videoPath = str;
        bax.wFF = str2;
        bax.cvZ = hVar.qGb;
        try {
            rVar.rfI = bax.toByteArray();
        } catch (Exception e) {
            ab.e("MicroMsg.snsMediaStorage", "uploadInfo to byteArray error");
        }
        rVar.crp();
        int insert = (int) this.fni.insert("SnsMedia", "local_id", rVar.cro());
        String concat = "Locall_path".concat(String.valueOf(insert));
        ab.d("MicroMsg.snsMediaStorage", "insert localId ".concat(String.valueOf(insert)));
        String Xe = i.Xe(concat);
        String Xf = i.Xf(concat);
        String Xd = i.Xd(concat);
        String Xg = i.Xg(concat);
        String Zh = Zh(concat);
        e.tf(Zh);
        e.y(str2, Zh + Xe);
        e.y(str2, Zh + Xf);
        e.y(str2, Zh + Xd);
        e.y(str, Zh + Xg);
        bax.videoPath = Zh + Xg;
        bax.wFF = Zh + Xf;
        bax.cvZ = hVar.qGb;
        try {
            rVar.rfI = bax.toByteArray();
        } catch (Exception e2) {
            ab.e("MicroMsg.snsMediaStorage", "uploadInfo to byteArray error");
        }
        rVar.rfE = concat;
        if (!(TextUtils.isEmpty(str3) || TextUtils.isEmpty(str4))) {
            bar bar = new bar();
            bar.jCt = 1;
            bar.Url = str3;
            bax.wFA = bar;
            bax.wFD = 0;
            f.afy();
            bax.wFc = com.tencent.mm.al.a.rJ(str);
            if (!bo.isNullOrNil(str4)) {
                bar = new bar();
                bar.jCt = 1;
                bar.Url = str4;
                bax.wFC.add(bar);
            }
            try {
                rVar.rfI = bax.toByteArray();
            } catch (Exception e3) {
                ab.printErrStackTrace("MicroMsg.snsMediaStorage", e3, BuildConfig.FLAVOR, new Object[0]);
            }
            rVar.crq();
        }
        a(insert, rVar);
        com.tencent.mm.plugin.sns.data.h a = a(hVar, bax.wFF);
        a.cNE = insert;
        AppMethodBeat.o(37989);
        return a;
    }

    public static boolean crr() {
        AppMethodBeat.i(37990);
        if ("hevc".equals(ae.gjm)) {
            AppMethodBeat.o(37990);
            return true;
        }
        boolean cnP = af.cnP();
        AppMethodBeat.o(37990);
        return cnP;
    }

    public static boolean crs() {
        AppMethodBeat.i(37991);
        if ("wxpc".equals(ae.gjm)) {
            AppMethodBeat.o(37991);
            return true;
        }
        boolean cnQ = af.cnQ();
        AppMethodBeat.o(37991);
        return cnQ;
    }

    public static boolean aj(String str, String str2, String str3) {
        AppMethodBeat.i(138384);
        boolean e = e(str, str2, str3, true);
        AppMethodBeat.o(138384);
        return e;
    }

    public static boolean crt() {
        return qDc >= 1080 && qDU >= 1080;
    }

    /* JADX WARNING: Removed duplicated region for block: B:176:0x0611  */
    /* JADX WARNING: Removed duplicated region for block: B:73:0x02a6  */
    /* JADX WARNING: Removed duplicated region for block: B:15:0x004b A:{SYNTHETIC, Splitter:B:15:0x004b} */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x0141  */
    /* JADX WARNING: Removed duplicated region for block: B:106:0x03ba A:{SYNTHETIC, Splitter:B:106:0x03ba} */
    /* JADX WARNING: Removed duplicated region for block: B:43:0x0147 A:{SYNTHETIC, Splitter:B:43:0x0147} */
    /* JADX WARNING: Removed duplicated region for block: B:120:0x04a6  */
    /* JADX WARNING: Removed duplicated region for block: B:119:0x04a0  */
    /* JADX WARNING: Removed duplicated region for block: B:51:0x01cb  */
    /* JADX WARNING: Removed duplicated region for block: B:54:0x01e2  */
    /* JADX WARNING: Removed duplicated region for block: B:62:0x0204 A:{SYNTHETIC, Splitter:B:62:0x0204} */
    /* JADX WARNING: Removed duplicated region for block: B:69:0x0294  */
    /* JADX WARNING: Removed duplicated region for block: B:73:0x02a6  */
    /* JADX WARNING: Removed duplicated region for block: B:176:0x0611  */
    /* JADX WARNING: Removed duplicated region for block: B:8:0x0033  */
    /* JADX WARNING: Removed duplicated region for block: B:15:0x004b A:{SYNTHETIC, Splitter:B:15:0x004b} */
    /* JADX WARNING: Removed duplicated region for block: B:40:0x0141  */
    /* JADX WARNING: Removed duplicated region for block: B:43:0x0147 A:{SYNTHETIC, Splitter:B:43:0x0147} */
    /* JADX WARNING: Removed duplicated region for block: B:106:0x03ba A:{SYNTHETIC, Splitter:B:106:0x03ba} */
    /* JADX WARNING: Removed duplicated region for block: B:47:0x01b2 A:{SKIP} */
    /* JADX WARNING: Removed duplicated region for block: B:119:0x04a0  */
    /* JADX WARNING: Removed duplicated region for block: B:120:0x04a6  */
    /* JADX WARNING: Removed duplicated region for block: B:51:0x01cb  */
    /* JADX WARNING: Removed duplicated region for block: B:54:0x01e2  */
    /* JADX WARNING: Removed duplicated region for block: B:57:0x01f9  */
    /* JADX WARNING: Removed duplicated region for block: B:62:0x0204 A:{SYNTHETIC, Splitter:B:62:0x0204} */
    /* JADX WARNING: Removed duplicated region for block: B:69:0x0294  */
    /* JADX WARNING: Removed duplicated region for block: B:176:0x0611  */
    /* JADX WARNING: Removed duplicated region for block: B:73:0x02a6  */
    public static boolean e(java.lang.String r19, java.lang.String r20, java.lang.String r21, boolean r22) {
        /*
        r2 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r2);
        r7 = com.tencent.mm.sdk.platformtools.d.amj(r20);
        if (r7 == 0) goto L_0x0304;
    L_0x000c:
        r2 = r7.outMimeType;
        r3 = "MicroMsg.snsMediaStorage";
        r4 = "mimetype: ";
        r5 = java.lang.String.valueOf(r2);
        r4 = r4.concat(r5);
        com.tencent.mm.sdk.platformtools.ab.d(r3, r4);
        if (r2 == 0) goto L_0x0304;
    L_0x0021:
        r2 = r2.toLowerCase();
        r3 = "jpg";
        r3 = r2.indexOf(r3);
        if (r3 < 0) goto L_0x02e8;
    L_0x002e:
        r2 = 1;
        r17 = r2;
    L_0x0031:
        if (r7 == 0) goto L_0x0316;
    L_0x0033:
        r2 = r7.outMimeType;
        if (r2 == 0) goto L_0x0316;
    L_0x0037:
        r2 = r2.toLowerCase();
        r3 = "jpg";
        r3 = r2.indexOf(r3);
        if (r3 < 0) goto L_0x0309;
    L_0x0044:
        r2 = 1;
        r5 = r2;
    L_0x0046:
        r3 = -1;
        r6 = 100;
        if (r22 == 0) goto L_0x011d;
    L_0x004b:
        com.tencent.mm.al.f.afx();	 Catch:{ Exception -> 0x0958 }
        r2 = 64;
        r2 = com.tencent.mm.al.b.lg(r2);	 Catch:{ Exception -> 0x0958 }
        if (r2 != 0) goto L_0x0062;
    L_0x0056:
        r2 = crr();	 Catch:{ Exception -> 0x0958 }
        if (r2 != 0) goto L_0x0062;
    L_0x005c:
        r2 = crs();	 Catch:{ Exception -> 0x0958 }
        if (r2 == 0) goto L_0x0367;
    L_0x0062:
        r2 = com.tencent.mm.sdk.platformtools.ah.getContext();	 Catch:{ Exception -> 0x0958 }
        r2 = com.tencent.mm.sdk.platformtools.at.isWifi(r2);	 Catch:{ Exception -> 0x0958 }
        if (r2 == 0) goto L_0x031a;
    L_0x006c:
        r2 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x0958 }
        r4 = "SnsWebpCompressPicLevelForWifi";
        r2 = r2.getValue(r4);	 Catch:{ Exception -> 0x0958 }
        r4 = 70;
        r2 = com.tencent.mm.sdk.platformtools.bo.getInt(r2, r4);	 Catch:{ Exception -> 0x0958 }
    L_0x007d:
        r4 = "MicroMsg.snsMediaStorage";
        r6 = "createPic comLev---webpWifi:%s, webp2G:%s, webp3G:%s,webp4G:%s   wifi:%s, 2G:%s, 3G:%s";
        r8 = 7;
        r8 = new java.lang.Object[r8];	 Catch:{ Exception -> 0x095c }
        r9 = 0;
        r10 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x095c }
        r11 = "SnsWebpCompressPicLevelForWifi";
        r10 = r10.getValue(r11);	 Catch:{ Exception -> 0x095c }
        r8[r9] = r10;	 Catch:{ Exception -> 0x095c }
        r9 = 1;
        r10 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x095c }
        r11 = "SnsWebpCompressPicLevelFor2G";
        r10 = r10.getValue(r11);	 Catch:{ Exception -> 0x095c }
        r8[r9] = r10;	 Catch:{ Exception -> 0x095c }
        r9 = 2;
        r10 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x095c }
        r11 = "SnsWebpCompressPicLevelFor3G";
        r10 = r10.getValue(r11);	 Catch:{ Exception -> 0x095c }
        r8[r9] = r10;	 Catch:{ Exception -> 0x095c }
        r9 = 3;
        r10 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x095c }
        r11 = "SnsWebpCompressPicLevelFor4G";
        r10 = r10.getValue(r11);	 Catch:{ Exception -> 0x095c }
        r8[r9] = r10;	 Catch:{ Exception -> 0x095c }
        r9 = 4;
        r10 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x095c }
        r11 = "SnsCompressPicLevelForWifi";
        r10 = r10.getValue(r11);	 Catch:{ Exception -> 0x095c }
        r8[r9] = r10;	 Catch:{ Exception -> 0x095c }
        r9 = 5;
        r10 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x095c }
        r11 = "SnsCompressPicLevelFor2G";
        r10 = r10.getValue(r11);	 Catch:{ Exception -> 0x095c }
        r8[r9] = r10;	 Catch:{ Exception -> 0x095c }
        r9 = 6;
        r10 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x095c }
        r11 = "SnsCompressPicLevelFor3G";
        r10 = r10.getValue(r11);	 Catch:{ Exception -> 0x095c }
        r8[r9] = r10;	 Catch:{ Exception -> 0x095c }
        com.tencent.mm.sdk.platformtools.ab.d(r4, r6, r8);	 Catch:{ Exception -> 0x095c }
    L_0x00eb:
        r4 = "MicroMsg.snsMediaStorage";
        r6 = "CompresssnsPicLevel-level:%d isUpload: %s";
        r8 = 2;
        r8 = new java.lang.Object[r8];
        r9 = 0;
        r10 = java.lang.Integer.valueOf(r2);
        r8[r9] = r10;
        r9 = 1;
        r10 = java.lang.Boolean.valueOf(r22);
        r8[r9] = r10;
        com.tencent.mm.sdk.platformtools.ab.i(r4, r6, r8);
        r4 = 10;
        if (r2 <= r4) goto L_0x010d;
    L_0x0109:
        r4 = 100;
        if (r2 <= r4) goto L_0x0969;
    L_0x010d:
        r6 = 60;
    L_0x010f:
        if (r5 == 0) goto L_0x011d;
    L_0x0111:
        r2 = com.tencent.mm.sdk.platformtools.MMNativeJpeg.queryQuality(r20);
        if (r2 >= r6) goto L_0x0966;
    L_0x0117:
        r3 = 25;
        if (r2 <= r3) goto L_0x0966;
    L_0x011b:
        r6 = r2;
        r3 = r2;
    L_0x011d:
        r8 = com.tencent.mm.vfs.e.asZ(r20);
        r0 = (int) r8;
        r18 = r0;
        r4 = 0;
        r2 = 1080; // 0x438 float:1.513E-42 double:5.336E-321;
        r8 = com.tencent.mm.plugin.facedetect.FaceProNative.detectFaceCnt(r20);
        r9 = "MicroMsg.snsMediaStorage";
        r10 = "FaceCnt:%d";
        r11 = 1;
        r11 = new java.lang.Object[r11];
        r12 = 0;
        r13 = java.lang.Integer.valueOf(r8);
        r11[r12] = r13;
        com.tencent.mm.sdk.platformtools.ab.i(r9, r10, r11);
        r9 = 5;
        if (r8 < r9) goto L_0x0144;
    L_0x0141:
        r4 = 0;
        r2 = 1440; // 0x5a0 float:2.018E-42 double:7.115E-321;
    L_0x0144:
        r9 = 5;
        if (r8 < r9) goto L_0x03ba;
    L_0x0147:
        r8 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x0955 }
        r9 = "SnsCompressResolutionForMultiHead";
        r8 = r8.getValue(r9);	 Catch:{ Exception -> 0x0955 }
        r9 = "\\*";
        r9 = r8.split(r9);	 Catch:{ Exception -> 0x0955 }
        r10 = 0;
        r9 = r9[r10];	 Catch:{ Exception -> 0x0955 }
        r9 = java.lang.Integer.valueOf(r9);	 Catch:{ Exception -> 0x0955 }
        r4 = r9.intValue();	 Catch:{ Exception -> 0x0955 }
        r9 = "\\*";
        r8 = r8.split(r9);	 Catch:{ Exception -> 0x0955 }
        r9 = 1;
        r8 = r8[r9];	 Catch:{ Exception -> 0x0955 }
        r8 = java.lang.Integer.valueOf(r8);	 Catch:{ Exception -> 0x0955 }
        r2 = r8.intValue();	 Catch:{ Exception -> 0x0955 }
    L_0x0176:
        r8 = "MicroMsg.snsMediaStorage";
        r9 = "server target conf_long config_short %d %d screen %d %d comLev: %d isUpload%s";
        r10 = 6;
        r10 = new java.lang.Object[r10];
        r11 = 0;
        r12 = java.lang.Integer.valueOf(r4);
        r10[r11] = r12;
        r11 = 1;
        r12 = java.lang.Integer.valueOf(r2);
        r10[r11] = r12;
        r11 = 2;
        r12 = qDc;
        r12 = java.lang.Integer.valueOf(r12);
        r10[r11] = r12;
        r11 = 3;
        r12 = qDU;
        r12 = java.lang.Integer.valueOf(r12);
        r10[r11] = r12;
        r11 = 4;
        r12 = java.lang.Integer.valueOf(r6);
        r10[r11] = r12;
        r11 = 5;
        r12 = java.lang.Boolean.valueOf(r22);
        r10[r11] = r12;
        com.tencent.mm.sdk.platformtools.ab.i(r8, r9, r10);
        if (r4 > 0) goto L_0x049c;
    L_0x01b2:
        if (r2 > 0) goto L_0x049c;
    L_0x01b4:
        r4 = 0;
        r2 = 1080; // 0x438 float:1.513E-42 double:5.336E-321;
        r10 = r2;
    L_0x01b8:
        r2 = com.tencent.mm.m.g.Nu();
        r8 = "PicCompressAvoidanceActiveSizeNormal";
        r2 = r2.getValue(r8);
        r8 = 100;
        r2 = com.tencent.mm.sdk.platformtools.bo.getInt(r2, r8);
        if (r2 > 0) goto L_0x01cd;
    L_0x01cb:
        r2 = 100;
    L_0x01cd:
        r8 = r2 * 1024;
        r2 = com.tencent.mm.m.g.Nu();
        r9 = "PicCompressAvoidanceActiveSizeLong";
        r2 = r2.getValue(r9);
        r9 = 200; // 0xc8 float:2.8E-43 double:9.9E-322;
        r2 = com.tencent.mm.sdk.platformtools.bo.getInt(r2, r9);
        if (r2 > 0) goto L_0x01e4;
    L_0x01e2:
        r2 = 200; // 0xc8 float:2.8E-43 double:9.9E-322;
    L_0x01e4:
        r9 = r2 * 1024;
        r2 = com.tencent.mm.m.g.Nu();
        r11 = "PicCompressAvoidanceRemainderPerc";
        r2 = r2.getValue(r11);
        r11 = 10;
        r2 = com.tencent.mm.sdk.platformtools.bo.getInt(r2, r11);
        if (r2 <= 0) goto L_0x01fd;
    L_0x01f9:
        r11 = 100;
        if (r2 < r11) goto L_0x095f;
    L_0x01fd:
        r2 = 10;
        r16 = r2;
    L_0x0201:
        r2 = 0;
        if (r5 == 0) goto L_0x04cd;
    L_0x0204:
        r5 = com.tencent.mm.compatible.util.Exif.fromFile(r20);	 Catch:{ Exception -> 0x04b2 }
        if (r5 == 0) goto L_0x0210;
    L_0x020a:
        r5 = r5.getOrientationInDegree();	 Catch:{ Exception -> 0x04b2 }
        r2 = r5 % 360;
    L_0x0210:
        r15 = r2;
    L_0x0211:
        r2 = "MicroMsg.snsMediaStorage";
        r5 = new java.lang.StringBuilder;
        r11 = "option info ";
        r5.<init>(r11);
        r11 = r7.outWidth;
        r5 = r5.append(r11);
        r11 = " ";
        r5 = r5.append(r11);
        r11 = r7.outHeight;
        r5 = r5.append(r11);
        r11 = " ";
        r5 = r5.append(r11);
        r0 = r17;
        r5 = r5.append(r0);
        r11 = " origQuality: ";
        r5 = r5.append(r11);
        r3 = r5.append(r3);
        r5 = " degree:";
        r3 = r3.append(r5);
        r3 = r3.append(r15);
        r5 = " filelen ";
        r3 = r3.append(r5);
        r0 = r18;
        r3 = r3.append(r0);
        r5 = " target ";
        r3 = r3.append(r5);
        r3 = r3.append(r4);
        r5 = " ";
        r3 = r3.append(r5);
        r3 = r3.append(r10);
        r3 = r3.toString();
        com.tencent.mm.sdk.platformtools.ab.i(r2, r3);
        r2 = com.tencent.mm.m.g.Nu();
        r3 = "CompressLongImageRatio";
        r2 = r2.getValue(r3);
        r3 = 10;
        com.tencent.mm.sdk.platformtools.bo.getInt(r2, r3);
        r2 = r7.outWidth;
        r3 = r7.outHeight;
        r3 = r3 * 2;
        if (r2 >= r3) goto L_0x029c;
    L_0x0294:
        r2 = r7.outHeight;
        r3 = r7.outWidth;
        r3 = r3 * 2;
        if (r2 < r3) goto L_0x06b1;
    L_0x029c:
        r2 = r7.outWidth;
        r3 = r7.outHeight;
        r2 = r2 * r3;
        r3 = 10240000; // 0x9c4000 float:1.4349296E-38 double:5.059232E-317;
        if (r2 > r3) goto L_0x0611;
    L_0x02a6:
        r0 = r18;
        if (r0 >= r9) goto L_0x04d9;
    L_0x02aa:
        if (r17 == 0) goto L_0x04d9;
    L_0x02ac:
        if (r15 != 0) goto L_0x04d9;
    L_0x02ae:
        r2 = "MicroMsg.snsMediaStorage";
        r3 = "filelen is control in picCompressAvoidanceActiveSizeLong ";
        r4 = java.lang.String.valueOf(r9);
        r3 = r3.concat(r4);
        com.tencent.mm.sdk.platformtools.ab.i(r2, r3);
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r0 = r19;
        r2 = r2.append(r0);
        r0 = r21;
        r2 = r2.append(r0);
        r2 = r2.toString();
        r0 = r20;
        r2 = com.tencent.mm.vfs.e.y(r0, r2);
        r4 = 0;
        r2 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1));
        if (r2 < 0) goto L_0x04d0;
    L_0x02e0:
        r2 = 1;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
    L_0x02e7:
        return r2;
    L_0x02e8:
        r3 = "jpeg";
        r3 = r2.indexOf(r3);
        if (r3 < 0) goto L_0x02f6;
    L_0x02f1:
        r2 = 1;
        r17 = r2;
        goto L_0x0031;
    L_0x02f6:
        r3 = "png";
        r2 = r2.indexOf(r3);
        if (r2 < 0) goto L_0x0304;
    L_0x02ff:
        r2 = 1;
        r17 = r2;
        goto L_0x0031;
    L_0x0304:
        r2 = 0;
        r17 = r2;
        goto L_0x0031;
    L_0x0309:
        r3 = "jpeg";
        r2 = r2.indexOf(r3);
        if (r2 < 0) goto L_0x0316;
    L_0x0312:
        r2 = 1;
        r5 = r2;
        goto L_0x0046;
    L_0x0316:
        r2 = 0;
        r5 = r2;
        goto L_0x0046;
    L_0x031a:
        r2 = com.tencent.mm.sdk.platformtools.ah.getContext();	 Catch:{ Exception -> 0x0958 }
        r2 = com.tencent.mm.sdk.platformtools.at.is2G(r2);	 Catch:{ Exception -> 0x0958 }
        if (r2 == 0) goto L_0x0337;
    L_0x0324:
        r2 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x0958 }
        r4 = "SnsWebpCompressPicLevelFor2G";
        r2 = r2.getValue(r4);	 Catch:{ Exception -> 0x0958 }
        r4 = 70;
        r2 = com.tencent.mm.sdk.platformtools.bo.getInt(r2, r4);	 Catch:{ Exception -> 0x0958 }
        goto L_0x007d;
    L_0x0337:
        r2 = com.tencent.mm.sdk.platformtools.ah.getContext();	 Catch:{ Exception -> 0x0958 }
        r2 = com.tencent.mm.sdk.platformtools.at.is3G(r2);	 Catch:{ Exception -> 0x0958 }
        if (r2 == 0) goto L_0x0354;
    L_0x0341:
        r2 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x0958 }
        r4 = "SnsWebpCompressPicLevelFor3G";
        r2 = r2.getValue(r4);	 Catch:{ Exception -> 0x0958 }
        r4 = 60;
        r2 = com.tencent.mm.sdk.platformtools.bo.getInt(r2, r4);	 Catch:{ Exception -> 0x0958 }
        goto L_0x007d;
    L_0x0354:
        r2 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x0958 }
        r4 = "SnsWebpCompressPicLevelFor4G";
        r2 = r2.getValue(r4);	 Catch:{ Exception -> 0x0958 }
        r4 = 60;
        r2 = com.tencent.mm.sdk.platformtools.bo.getInt(r2, r4);	 Catch:{ Exception -> 0x0958 }
        goto L_0x007d;
    L_0x0367:
        r2 = com.tencent.mm.sdk.platformtools.ah.getContext();	 Catch:{ Exception -> 0x0958 }
        r2 = com.tencent.mm.sdk.platformtools.at.isWifi(r2);	 Catch:{ Exception -> 0x0958 }
        if (r2 == 0) goto L_0x0386;
    L_0x0371:
        r2 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x0958 }
        r4 = "SnsCompressPicLevelForWifi";
        r2 = r2.getValue(r4);	 Catch:{ Exception -> 0x0958 }
        r2 = java.lang.Integer.valueOf(r2);	 Catch:{ Exception -> 0x0958 }
        r2 = r2.intValue();	 Catch:{ Exception -> 0x0958 }
        goto L_0x007d;
    L_0x0386:
        r2 = com.tencent.mm.sdk.platformtools.ah.getContext();	 Catch:{ Exception -> 0x0958 }
        r2 = com.tencent.mm.sdk.platformtools.at.is2G(r2);	 Catch:{ Exception -> 0x0958 }
        if (r2 == 0) goto L_0x03a5;
    L_0x0390:
        r2 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x0958 }
        r4 = "SnsCompressPicLevelFor2G";
        r2 = r2.getValue(r4);	 Catch:{ Exception -> 0x0958 }
        r2 = java.lang.Integer.valueOf(r2);	 Catch:{ Exception -> 0x0958 }
        r2 = r2.intValue();	 Catch:{ Exception -> 0x0958 }
        goto L_0x007d;
    L_0x03a5:
        r2 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x0958 }
        r4 = "SnsCompressPicLevelFor3G";
        r2 = r2.getValue(r4);	 Catch:{ Exception -> 0x0958 }
        r2 = java.lang.Integer.valueOf(r2);	 Catch:{ Exception -> 0x0958 }
        r2 = r2.intValue();	 Catch:{ Exception -> 0x0958 }
        goto L_0x007d;
    L_0x03ba:
        r8 = com.tencent.mm.sdk.platformtools.ah.getContext();	 Catch:{ Exception -> 0x0955 }
        r8 = com.tencent.mm.sdk.platformtools.at.isWifi(r8);	 Catch:{ Exception -> 0x0955 }
        if (r8 == 0) goto L_0x03f5;
    L_0x03c4:
        r8 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x0955 }
        r9 = "SnsCompressResolutionForWifi";
        r8 = r8.getValue(r9);	 Catch:{ Exception -> 0x0955 }
        r9 = "\\*";
        r9 = r8.split(r9);	 Catch:{ Exception -> 0x0955 }
        r10 = 0;
        r9 = r9[r10];	 Catch:{ Exception -> 0x0955 }
        r9 = java.lang.Integer.valueOf(r9);	 Catch:{ Exception -> 0x0955 }
        r4 = r9.intValue();	 Catch:{ Exception -> 0x0955 }
        r9 = "\\*";
        r8 = r8.split(r9);	 Catch:{ Exception -> 0x0955 }
        r9 = 1;
        r8 = r8[r9];	 Catch:{ Exception -> 0x0955 }
        r8 = java.lang.Integer.valueOf(r8);	 Catch:{ Exception -> 0x0955 }
        r2 = r8.intValue();	 Catch:{ Exception -> 0x0955 }
        goto L_0x0176;
    L_0x03f5:
        r8 = com.tencent.mm.sdk.platformtools.ah.getContext();	 Catch:{ Exception -> 0x0955 }
        r8 = com.tencent.mm.sdk.platformtools.at.is2G(r8);	 Catch:{ Exception -> 0x0955 }
        if (r8 == 0) goto L_0x0430;
    L_0x03ff:
        r8 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x0955 }
        r9 = "SnsCompressResolutionFor2G";
        r8 = r8.getValue(r9);	 Catch:{ Exception -> 0x0955 }
        r9 = "\\*";
        r9 = r8.split(r9);	 Catch:{ Exception -> 0x0955 }
        r10 = 0;
        r9 = r9[r10];	 Catch:{ Exception -> 0x0955 }
        r9 = java.lang.Integer.valueOf(r9);	 Catch:{ Exception -> 0x0955 }
        r4 = r9.intValue();	 Catch:{ Exception -> 0x0955 }
        r9 = "\\*";
        r8 = r8.split(r9);	 Catch:{ Exception -> 0x0955 }
        r9 = 1;
        r8 = r8[r9];	 Catch:{ Exception -> 0x0955 }
        r8 = java.lang.Integer.valueOf(r8);	 Catch:{ Exception -> 0x0955 }
        r2 = r8.intValue();	 Catch:{ Exception -> 0x0955 }
        goto L_0x0176;
    L_0x0430:
        r8 = com.tencent.mm.sdk.platformtools.ah.getContext();	 Catch:{ Exception -> 0x0955 }
        r8 = com.tencent.mm.sdk.platformtools.at.is3G(r8);	 Catch:{ Exception -> 0x0955 }
        if (r8 == 0) goto L_0x046b;
    L_0x043a:
        r8 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x0955 }
        r9 = "SnsCompressResolutionFor3G";
        r8 = r8.getValue(r9);	 Catch:{ Exception -> 0x0955 }
        r9 = "\\*";
        r9 = r8.split(r9);	 Catch:{ Exception -> 0x0955 }
        r10 = 0;
        r9 = r9[r10];	 Catch:{ Exception -> 0x0955 }
        r9 = java.lang.Integer.valueOf(r9);	 Catch:{ Exception -> 0x0955 }
        r4 = r9.intValue();	 Catch:{ Exception -> 0x0955 }
        r9 = "\\*";
        r8 = r8.split(r9);	 Catch:{ Exception -> 0x0955 }
        r9 = 1;
        r8 = r8[r9];	 Catch:{ Exception -> 0x0955 }
        r8 = java.lang.Integer.valueOf(r8);	 Catch:{ Exception -> 0x0955 }
        r2 = r8.intValue();	 Catch:{ Exception -> 0x0955 }
        goto L_0x0176;
    L_0x046b:
        r8 = com.tencent.mm.m.g.Nu();	 Catch:{ Exception -> 0x0955 }
        r9 = "SnsCompressResolutionFor4G";
        r8 = r8.getValue(r9);	 Catch:{ Exception -> 0x0955 }
        r9 = "\\*";
        r9 = r8.split(r9);	 Catch:{ Exception -> 0x0955 }
        r10 = 0;
        r9 = r9[r10];	 Catch:{ Exception -> 0x0955 }
        r9 = java.lang.Integer.valueOf(r9);	 Catch:{ Exception -> 0x0955 }
        r4 = r9.intValue();	 Catch:{ Exception -> 0x0955 }
        r9 = "\\*";
        r8 = r8.split(r9);	 Catch:{ Exception -> 0x0955 }
        r9 = 1;
        r8 = r8[r9];	 Catch:{ Exception -> 0x0955 }
        r8 = java.lang.Integer.valueOf(r8);	 Catch:{ Exception -> 0x0955 }
        r2 = r8.intValue();	 Catch:{ Exception -> 0x0955 }
        goto L_0x0176;
    L_0x049c:
        r8 = 2160; // 0x870 float:3.027E-42 double:1.067E-320;
        if (r2 < r8) goto L_0x04a6;
    L_0x04a0:
        r4 = 0;
        r2 = 1080; // 0x438 float:1.513E-42 double:5.336E-321;
        r10 = r2;
        goto L_0x01b8;
    L_0x04a6:
        if (r2 > 0) goto L_0x0963;
    L_0x04a8:
        r8 = 3240; // 0xca8 float:4.54E-42 double:1.601E-320;
        if (r4 <= r8) goto L_0x0963;
    L_0x04ac:
        r4 = 1620; // 0x654 float:2.27E-42 double:8.004E-321;
        r2 = 0;
        r10 = r2;
        goto L_0x01b8;
    L_0x04b2:
        r5 = move-exception;
        r11 = "MicroMsg.snsMediaStorage";
        r12 = new java.lang.StringBuilder;
        r13 = "get degree error ";
        r12.<init>(r13);
        r5 = r5.getMessage();
        r5 = r12.append(r5);
        r5 = r5.toString();
        com.tencent.mm.sdk.platformtools.ab.e(r11, r5);
    L_0x04cd:
        r15 = r2;
        goto L_0x0211;
    L_0x04d0:
        r2 = 0;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x04d9:
        r4 = new android.graphics.BitmapFactory$Options;
        r4.<init>();
        com.tencent.mm.sdk.platformtools.d.dnX();
        r3 = 0;
        r3 = com.tencent.mm.vfs.e.openRead(r20);	 Catch:{ IOException -> 0x05e1 }
        r2 = r3.markSupported();	 Catch:{ IOException -> 0x05e1 }
        if (r2 != 0) goto L_0x04f2;
    L_0x04ec:
        r2 = new java.io.BufferedInputStream;	 Catch:{ IOException -> 0x05e1 }
        r2.<init>(r3);	 Catch:{ IOException -> 0x05e1 }
        r3 = r2;
    L_0x04f2:
        r2 = 1048576; // 0x100000 float:1.469368E-39 double:5.180654E-318;
        r3.mark(r2);	 Catch:{ IOException -> 0x05e1 }
        r2 = 0;
        r2 = com.tencent.mm.graphics.MMBitmapFactory.decodeStream(r3, r2, r4);	 Catch:{ IOException -> 0x05e1 }
        r3.reset();	 Catch:{ IOException -> 0x05e1 }
        if (r2 != 0) goto L_0x050f;
    L_0x0501:
        if (r3 == 0) goto L_0x0506;
    L_0x0503:
        r3.close();	 Catch:{ IOException -> 0x0943 }
    L_0x0506:
        r2 = 0;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x050f:
        r4 = (float) r15;
        r2 = com.tencent.mm.sdk.platformtools.d.b(r2, r4);	 Catch:{ IOException -> 0x05e1 }
        r4 = android.graphics.Bitmap.CompressFormat.JPEG;	 Catch:{ IOException -> 0x05e1 }
        r5 = new java.lang.StringBuilder;	 Catch:{ IOException -> 0x05e1 }
        r5.<init>();	 Catch:{ IOException -> 0x05e1 }
        r0 = r19;
        r5 = r5.append(r0);	 Catch:{ IOException -> 0x05e1 }
        r0 = r21;
        r5 = r5.append(r0);	 Catch:{ IOException -> 0x05e1 }
        r5 = r5.toString();	 Catch:{ IOException -> 0x05e1 }
        r7 = 1;
        com.tencent.mm.sdk.platformtools.d.a(r2, r6, r4, r5, r7);	 Catch:{ IOException -> 0x05e1 }
        if (r17 == 0) goto L_0x05d3;
    L_0x0531:
        if (r15 != 0) goto L_0x05d3;
    L_0x0533:
        r2 = new java.lang.StringBuilder;	 Catch:{ IOException -> 0x05e1 }
        r2.<init>();	 Catch:{ IOException -> 0x05e1 }
        r0 = r19;
        r2 = r2.append(r0);	 Catch:{ IOException -> 0x05e1 }
        r0 = r21;
        r2 = r2.append(r0);	 Catch:{ IOException -> 0x05e1 }
        r2 = r2.toString();	 Catch:{ IOException -> 0x05e1 }
        r4 = com.tencent.mm.vfs.e.asZ(r2);	 Catch:{ IOException -> 0x05e1 }
        r2 = "MicroMsg.snsMediaStorage";
        r6 = "filelen %d newFileLen %d picCompressAvoidanceRemainderPerc %d";
        r7 = 3;
        r7 = new java.lang.Object[r7];	 Catch:{ IOException -> 0x05e1 }
        r8 = 0;
        r9 = java.lang.Integer.valueOf(r18);	 Catch:{ IOException -> 0x05e1 }
        r7[r8] = r9;	 Catch:{ IOException -> 0x05e1 }
        r8 = 1;
        r9 = java.lang.Long.valueOf(r4);	 Catch:{ IOException -> 0x05e1 }
        r7[r8] = r9;	 Catch:{ IOException -> 0x05e1 }
        r8 = 2;
        r9 = java.lang.Integer.valueOf(r16);	 Catch:{ IOException -> 0x05e1 }
        r7[r8] = r9;	 Catch:{ IOException -> 0x05e1 }
        com.tencent.mm.sdk.platformtools.ab.i(r2, r6, r7);	 Catch:{ IOException -> 0x05e1 }
        r0 = r18;
        r6 = (long) r0;	 Catch:{ IOException -> 0x05e1 }
        r4 = r6 - r4;
        r6 = 100;
        r4 = r4 * r6;
        r2 = r16 * r18;
        r6 = (long) r2;	 Catch:{ IOException -> 0x05e1 }
        r2 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r2 >= 0) goto L_0x05c5;
    L_0x057c:
        r2 = new java.lang.StringBuilder;	 Catch:{ IOException -> 0x05e1 }
        r2.<init>();	 Catch:{ IOException -> 0x05e1 }
        r0 = r19;
        r2 = r2.append(r0);	 Catch:{ IOException -> 0x05e1 }
        r0 = r21;
        r2 = r2.append(r0);	 Catch:{ IOException -> 0x05e1 }
        r2 = r2.toString();	 Catch:{ IOException -> 0x05e1 }
        com.tencent.mm.vfs.e.deleteFile(r2);	 Catch:{ IOException -> 0x05e1 }
        r2 = new java.lang.StringBuilder;	 Catch:{ IOException -> 0x05e1 }
        r2.<init>();	 Catch:{ IOException -> 0x05e1 }
        r0 = r19;
        r2 = r2.append(r0);	 Catch:{ IOException -> 0x05e1 }
        r0 = r21;
        r2 = r2.append(r0);	 Catch:{ IOException -> 0x05e1 }
        r2 = r2.toString();	 Catch:{ IOException -> 0x05e1 }
        r0 = r20;
        r4 = com.tencent.mm.vfs.e.y(r0, r2);	 Catch:{ IOException -> 0x05e1 }
        r6 = 0;
        r2 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r2 < 0) goto L_0x05c3;
    L_0x05b5:
        r2 = 1;
    L_0x05b6:
        if (r3 == 0) goto L_0x05bb;
    L_0x05b8:
        r3.close();	 Catch:{ IOException -> 0x0946 }
    L_0x05bb:
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x05c3:
        r2 = 0;
        goto L_0x05b6;
    L_0x05c5:
        if (r3 == 0) goto L_0x05ca;
    L_0x05c7:
        r3.close();	 Catch:{ IOException -> 0x0949 }
    L_0x05ca:
        r2 = 1;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x05d3:
        if (r3 == 0) goto L_0x05d8;
    L_0x05d5:
        r3.close();	 Catch:{ IOException -> 0x094c }
    L_0x05d8:
        r2 = 1;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x05e1:
        r2 = move-exception;
        r4 = "MicroMsg.snsMediaStorage";
        r5 = "Decode bitmap failed: ";
        r6 = java.lang.String.valueOf(r20);	 Catch:{ all -> 0x0604 }
        r5 = r5.concat(r6);	 Catch:{ all -> 0x0604 }
        r6 = 0;
        r6 = new java.lang.Object[r6];	 Catch:{ all -> 0x0604 }
        com.tencent.mm.sdk.platformtools.ab.printErrStackTrace(r4, r2, r5, r6);	 Catch:{ all -> 0x0604 }
        if (r3 == 0) goto L_0x05fb;
    L_0x05f8:
        r3.close();	 Catch:{ IOException -> 0x094f }
    L_0x05fb:
        r2 = 0;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x0604:
        r2 = move-exception;
        if (r3 == 0) goto L_0x060a;
    L_0x0607:
        r3.close();	 Catch:{ IOException -> 0x0952 }
    L_0x060a:
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        throw r2;
    L_0x0611:
        r2 = "MicroMsg.snsMediaStorage";
        r3 = new java.lang.StringBuilder;
        r4 = "too max pic ";
        r3.<init>(r4);
        r4 = r7.outWidth;
        r3 = r3.append(r4);
        r4 = " ";
        r3 = r3.append(r4);
        r4 = r7.outHeight;
        r3 = r3.append(r4);
        r3 = r3.toString();
        com.tencent.mm.sdk.platformtools.ab.i(r2, r3);
        r2 = r7.outHeight;
        if (r2 > 0) goto L_0x063d;
    L_0x063a:
        r2 = 1;
        r7.outHeight = r2;
    L_0x063d:
        r2 = r7.outWidth;
        if (r2 > 0) goto L_0x0644;
    L_0x0641:
        r2 = 1;
        r7.outWidth = r2;
    L_0x0644:
        r2 = r7.outWidth;
        r3 = r7.outHeight;
        if (r2 <= r3) goto L_0x06a7;
    L_0x064a:
        r2 = r7.outWidth;
        r3 = r7.outHeight;
        r2 = r2 / r3;
    L_0x064f:
        if (r2 != 0) goto L_0x0652;
    L_0x0651:
        r2 = 1;
    L_0x0652:
        r3 = 10240000; // 0x9c4000 float:1.4349296E-38 double:5.059232E-317;
        r3 = r3 / r2;
        r4 = (double) r3;
        r4 = java.lang.Math.sqrt(r4);
        r5 = (int) r4;
        r3 = r7.outWidth;
        r4 = r7.outHeight;
        if (r3 <= r4) goto L_0x06ad;
    L_0x0662:
        r4 = r5 * r2;
        r3 = r5;
    L_0x0665:
        r5 = "MicroMsg.snsMediaStorage";
        r7 = new java.lang.StringBuilder;
        r8 = "new width height ";
        r7.<init>(r8);
        r7 = r7.append(r4);
        r8 = " ";
        r7 = r7.append(r8);
        r7 = r7.append(r3);
        r8 = " ";
        r7 = r7.append(r8);
        r2 = r7.append(r2);
        r2 = r2.toString();
        com.tencent.mm.sdk.platformtools.ab.i(r5, r2);
        r5 = android.graphics.Bitmap.CompressFormat.JPEG;
        r2 = r20;
        r7 = r19;
        r8 = r21;
        r9 = r22;
        r2 = a(r2, r3, r4, r5, r6, r7, r8, r9);
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x06a7:
        r2 = r7.outHeight;
        r3 = r7.outWidth;
        r2 = r2 / r3;
        goto L_0x064f;
    L_0x06ad:
        r3 = r5 * r2;
        r4 = r5;
        goto L_0x0665;
    L_0x06b1:
        r0 = r18;
        if (r0 >= r8) goto L_0x06fd;
    L_0x06b5:
        if (r17 == 0) goto L_0x06fd;
    L_0x06b7:
        if (r15 != 0) goto L_0x06fd;
    L_0x06b9:
        r2 = "MicroMsg.snsMediaStorage";
        r3 = "filelen is control in picCompressAvoidanceActiveSizeNormal ";
        r4 = java.lang.String.valueOf(r8);
        r3 = r3.concat(r4);
        com.tencent.mm.sdk.platformtools.ab.i(r2, r3);
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r0 = r19;
        r2 = r2.append(r0);
        r0 = r21;
        r2 = r2.append(r0);
        r2 = r2.toString();
        r0 = r20;
        r2 = com.tencent.mm.vfs.e.y(r0, r2);
        r4 = 0;
        r2 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1));
        if (r2 < 0) goto L_0x06f4;
    L_0x06eb:
        r2 = 1;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x06f4:
        r2 = 0;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x06fd:
        r2 = r7.outWidth;
        r3 = r7.outHeight;
        if (r2 <= r3) goto L_0x0780;
    L_0x0703:
        r2 = r7.outWidth;
    L_0x0705:
        r3 = r7.outWidth;
        r5 = r7.outHeight;
        if (r3 >= r5) goto L_0x0783;
    L_0x070b:
        r3 = r7.outWidth;
    L_0x070d:
        if (r10 <= 0) goto L_0x0711;
    L_0x070f:
        if (r3 <= r10) goto L_0x0715;
    L_0x0711:
        if (r10 > 0) goto L_0x086f;
    L_0x0713:
        if (r2 > r4) goto L_0x086f;
    L_0x0715:
        r2 = "MicroMsg.snsMediaStorage";
        r3 = "hello ieg this is little img  %d w: %d h: %d";
        r4 = 3;
        r4 = new java.lang.Object[r4];
        r5 = 0;
        r8 = java.lang.Integer.valueOf(r18);
        r4[r5] = r8;
        r5 = 1;
        r8 = r7.outWidth;
        r8 = java.lang.Integer.valueOf(r8);
        r4[r5] = r8;
        r5 = 2;
        r8 = r7.outHeight;
        r8 = java.lang.Integer.valueOf(r8);
        r4[r5] = r8;
        com.tencent.mm.sdk.platformtools.ab.i(r2, r3, r4);
        r2 = com.tencent.mm.vfs.e.asZ(r20);
        r4 = 71680; // 0x11800 float:1.00445E-40 double:3.54146E-319;
        r2 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1));
        if (r2 >= 0) goto L_0x07b5;
    L_0x0745:
        if (r17 == 0) goto L_0x078f;
    L_0x0747:
        r2 = "MicroMsg.snsMediaStorage";
        r3 = "isSysSupportedPic %s";
        r4 = 1;
        r4 = new java.lang.Object[r4];
        r5 = 0;
        r4[r5] = r20;
        com.tencent.mm.sdk.platformtools.ab.i(r2, r3, r4);
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r0 = r19;
        r2 = r2.append(r0);
        r0 = r21;
        r2 = r2.append(r0);
        r2 = r2.toString();
        r0 = r20;
        r2 = com.tencent.mm.vfs.e.y(r0, r2);
        r4 = 0;
        r2 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1));
        if (r2 < 0) goto L_0x0786;
    L_0x0777:
        r2 = 1;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x0780:
        r2 = r7.outHeight;
        goto L_0x0705;
    L_0x0783:
        r3 = r7.outHeight;
        goto L_0x070d;
    L_0x0786:
        r2 = 0;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x078f:
        r2 = r7.outWidth;
        r3 = 150; // 0x96 float:2.1E-43 double:7.4E-322;
        if (r2 >= r3) goto L_0x07b5;
    L_0x0795:
        r2 = r7.outHeight;
        r3 = 150; // 0x96 float:2.1E-43 double:7.4E-322;
        if (r2 >= r3) goto L_0x07b5;
    L_0x079b:
        r3 = r7.outHeight;
        r4 = r7.outWidth;
        r5 = android.graphics.Bitmap.CompressFormat.PNG;
        r2 = r20;
        r7 = r19;
        r8 = r21;
        r9 = r22;
        r2 = a(r2, r3, r4, r5, r6, r7, r8, r9);
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x07b5:
        r3 = r7.outHeight;
        r4 = r7.outWidth;
        r5 = android.graphics.Bitmap.CompressFormat.JPEG;
        r2 = r20;
        r7 = r19;
        r8 = r21;
        r9 = r22;
        r2 = a(r2, r3, r4, r5, r6, r7, r8, r9);
        if (r17 == 0) goto L_0x0867;
    L_0x07c9:
        if (r15 != 0) goto L_0x0867;
    L_0x07cb:
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r0 = r19;
        r3 = r3.append(r0);
        r0 = r21;
        r3 = r3.append(r0);
        r3 = r3.toString();
        r4 = com.tencent.mm.vfs.e.asZ(r3);
        r3 = "MicroMsg.snsMediaStorage";
        r6 = "filelen %d newFileLen %d picCompressAvoidanceRemainderPerc %d";
        r7 = 3;
        r7 = new java.lang.Object[r7];
        r8 = 0;
        r9 = java.lang.Integer.valueOf(r18);
        r7[r8] = r9;
        r8 = 1;
        r9 = java.lang.Long.valueOf(r4);
        r7[r8] = r9;
        r8 = 2;
        r9 = java.lang.Integer.valueOf(r16);
        r7[r8] = r9;
        com.tencent.mm.sdk.platformtools.ab.i(r3, r6, r7);
        r0 = r18;
        r6 = (long) r0;
        r4 = r6 - r4;
        r6 = 100;
        r4 = r4 * r6;
        r3 = r16 * r18;
        r6 = (long) r3;
        r3 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r3 >= 0) goto L_0x085f;
    L_0x0814:
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r0 = r19;
        r2 = r2.append(r0);
        r0 = r21;
        r2 = r2.append(r0);
        r2 = r2.toString();
        com.tencent.mm.vfs.e.deleteFile(r2);
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r0 = r19;
        r2 = r2.append(r0);
        r0 = r21;
        r2 = r2.append(r0);
        r2 = r2.toString();
        r0 = r20;
        r2 = com.tencent.mm.vfs.e.y(r0, r2);
        r4 = 0;
        r2 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1));
        if (r2 < 0) goto L_0x0856;
    L_0x084d:
        r2 = 1;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x0856:
        r2 = 0;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x085f:
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x0867:
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x086f:
        if (r10 <= 0) goto L_0x0911;
    L_0x0871:
        r8 = r7.outWidth;
        r9 = r7.outHeight;
        r11 = android.graphics.Bitmap.CompressFormat.JPEG;
        r7 = r20;
        r12 = r6;
        r13 = r19;
        r14 = r21;
        r2 = a(r7, r8, r9, r10, r11, r12, r13, r14);
    L_0x0882:
        if (r17 == 0) goto L_0x093b;
    L_0x0884:
        if (r15 != 0) goto L_0x093b;
    L_0x0886:
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r0 = r19;
        r3 = r3.append(r0);
        r0 = r21;
        r3 = r3.append(r0);
        r3 = r3.toString();
        r4 = com.tencent.mm.vfs.e.asZ(r3);
        r3 = "MicroMsg.snsMediaStorage";
        r6 = "filelen %d newFileLen %d picCompressAvoidanceRemainderPerc %d";
        r7 = 3;
        r7 = new java.lang.Object[r7];
        r8 = 0;
        r9 = java.lang.Integer.valueOf(r18);
        r7[r8] = r9;
        r8 = 1;
        r9 = java.lang.Long.valueOf(r4);
        r7[r8] = r9;
        r8 = 2;
        r9 = java.lang.Integer.valueOf(r16);
        r7[r8] = r9;
        com.tencent.mm.sdk.platformtools.ab.i(r3, r6, r7);
        r0 = r18;
        r6 = (long) r0;
        r4 = r6 - r4;
        r6 = 100;
        r4 = r4 * r6;
        r3 = r16 * r18;
        r6 = (long) r3;
        r3 = (r4 > r6 ? 1 : (r4 == r6 ? 0 : -1));
        if (r3 >= 0) goto L_0x093b;
    L_0x08cf:
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r0 = r19;
        r2 = r2.append(r0);
        r0 = r21;
        r2 = r2.append(r0);
        r2 = r2.toString();
        com.tencent.mm.vfs.e.deleteFile(r2);
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r0 = r19;
        r2 = r2.append(r0);
        r0 = r21;
        r2 = r2.append(r0);
        r2 = r2.toString();
        r0 = r20;
        r2 = com.tencent.mm.vfs.e.y(r0, r2);
        r4 = 0;
        r2 = (r2 > r4 ? 1 : (r2 == r4 ? 0 : -1));
        if (r2 < 0) goto L_0x0932;
    L_0x0908:
        r2 = 1;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x0911:
        r2 = (double) r2;
        r8 = 4607182418800017408; // 0x3ff0000000000000 float:0.0 double:1.0;
        r2 = r2 * r8;
        r4 = (double) r4;
        r2 = r2 / r4;
        r4 = r7.outWidth;
        r4 = (double) r4;
        r4 = r4 / r2;
        r4 = (int) r4;
        r5 = r7.outHeight;
        r8 = (double) r5;
        r2 = r8 / r2;
        r3 = (int) r2;
        r5 = android.graphics.Bitmap.CompressFormat.JPEG;
        r2 = r20;
        r7 = r19;
        r8 = r21;
        r9 = r22;
        r2 = a(r2, r3, r4, r5, r6, r7, r8, r9);
        goto L_0x0882;
    L_0x0932:
        r2 = 0;
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x093b:
        r3 = 37993; // 0x9469 float:5.324E-41 double:1.8771E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        goto L_0x02e7;
    L_0x0943:
        r2 = move-exception;
        goto L_0x0506;
    L_0x0946:
        r3 = move-exception;
        goto L_0x05bb;
    L_0x0949:
        r2 = move-exception;
        goto L_0x05ca;
    L_0x094c:
        r2 = move-exception;
        goto L_0x05d8;
    L_0x094f:
        r2 = move-exception;
        goto L_0x05fb;
    L_0x0952:
        r3 = move-exception;
        goto L_0x060a;
    L_0x0955:
        r8 = move-exception;
        goto L_0x0176;
    L_0x0958:
        r2 = move-exception;
        r2 = r6;
        goto L_0x00eb;
    L_0x095c:
        r4 = move-exception;
        goto L_0x00eb;
    L_0x095f:
        r16 = r2;
        goto L_0x0201;
    L_0x0963:
        r10 = r2;
        goto L_0x01b8;
    L_0x0966:
        r3 = r2;
        goto L_0x011d;
    L_0x0969:
        r6 = r2;
        goto L_0x010f;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.sns.storage.s.e(java.lang.String, java.lang.String, java.lang.String, boolean):boolean");
    }

    private static boolean a(String str, int i, int i2, CompressFormat compressFormat, int i3, String str2, String str3, boolean z) {
        AppMethodBeat.i(37994);
        Options amj = d.amj(str);
        if (amj == null || amj.outWidth <= 0 || amj.outHeight <= 0) {
            AppMethodBeat.o(37994);
            return false;
        }
        boolean a = a(str, amj.outWidth, amj.outHeight, i, i2, compressFormat, i3, str2, str3, z);
        AppMethodBeat.o(37994);
        return a;
    }

    private static boolean a(String str, int i, int i2, int i3, CompressFormat compressFormat, int i4, String str2, String str3) {
        AppMethodBeat.i(37995);
        OutputStream outputStream = null;
        try {
            Bitmap b;
            ab.i("MicroMsg.snsMediaStorage", "createThumbNailUnScale, srcWidth: %d, srcHeight: %d, fixShort: %d, quality:%d", new Object[]{Integer.valueOf(i), Integer.valueOf(i2), Integer.valueOf(i3), Integer.valueOf(i4)});
            Options options = new Options();
            int i5 = i2 > i ? i : i2;
            if (i5 == i3) {
                b = com.tencent.mm.plugin.sns.d.a.b(str, options);
            } else {
                options.inSampleSize = 1;
                if (i5 > i3) {
                    options.inSampleSize = i5 / i3;
                    if (options.inSampleSize <= 1) {
                        options.inSampleSize = 1;
                    }
                }
                while (((i2 * i) / options.inSampleSize) / options.inSampleSize > 5529600) {
                    options.inSampleSize++;
                }
                ab.i("MicroMsg.snsMediaStorage", "createThumbNailUnScale, sampleSize: %s", new Object[]{Integer.valueOf(options.inSampleSize)});
                b = com.tencent.mm.plugin.sns.d.a.b(str, options);
            }
            ab.i("MicroMsg.snsMediaStorage", "createThumbNailUnScale, result bm: %s", new Object[]{b});
            if (b == null) {
                AppMethodBeat.o(37995);
                return false;
            }
            int i6;
            int i7;
            int i8 = (i * i3) / i5;
            int i9 = (i2 * i3) / i5;
            int bJ = ExifHelper.bJ(str);
            if (bJ == 90 || bJ == 270) {
                i6 = i9;
                i7 = i8;
            } else {
                i6 = i8;
                i7 = i9;
            }
            ab.i("MicroMsg.snsMediaStorage", "createThumbNailUnScale, bm.width: %s, bm.height: %s, new:[%d,%d], src:[%d, %d], shortEdge:%d,degree:%d", new Object[]{Integer.valueOf(b.getWidth()), Integer.valueOf(b.getHeight()), Integer.valueOf(i6), Integer.valueOf(i7), Integer.valueOf(i), Integer.valueOf(i2), Integer.valueOf(i5), Integer.valueOf(bJ)});
            Bitmap createScaledBitmap = Bitmap.createScaledBitmap(b, i6, i7, true);
            if (createScaledBitmap == null) {
                createScaledBitmap = b;
            } else if (b != createScaledBitmap) {
                l.Xf().v(b);
            }
            ab.i("MicroMsg.snsMediaStorage", "createThumbNailUnScaleFixShort, bm.width: %s, bm.height: %s, quality:%d", new Object[]{Integer.valueOf(createScaledBitmap.getWidth()), Integer.valueOf(createScaledBitmap.getHeight()), Integer.valueOf(i4)});
            outputStream = e.L(str2 + str3, false);
            d.a(createScaledBitmap, i4, compressFormat, outputStream, false);
            l.Xf().v(createScaledBitmap);
            outputStream.close();
            ab.i("MicroMsg.snsMediaStorage", "createThumbNailUnScaleFixShort saving to %s, size:%d", new Object[]{str2 + str3, Long.valueOf(e.asZ(str2 + str3))});
            AppMethodBeat.o(37995);
            return true;
        } catch (IOException e) {
            ab.printErrStackTrace("MicroMsg.snsMediaStorage", e, "create thumbnail from orig failed: %s", new Object[]{str3});
            if (outputStream != null) {
                try {
                    outputStream.close();
                } catch (IOException e2) {
                }
            }
            AppMethodBeat.o(37995);
            return false;
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:20:0x0058 A:{Splitter:B:1:0x0009, ExcHandler: all (th java.lang.Throwable)} */
    /* JADX WARNING: Failed to process nested try/catch */
    /* JADX WARNING: Missing block: B:15:0x004d, code skipped:
            r0 = r2;
     */
    /* JADX WARNING: Missing block: B:21:0x0059, code skipped:
            if (r2 != null) goto L_0x005b;
     */
    /* JADX WARNING: Missing block: B:23:?, code skipped:
            r2.close();
     */
    public static boolean Zj(java.lang.String r8) {
        /*
        r2 = 0;
        r0 = 1;
        r1 = 0;
        r7 = 37996; // 0x946c float:5.3244E-41 double:1.87725E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r7);
        r2 = com.tencent.mm.vfs.e.openRead(r8);	 Catch:{ Exception -> 0x004c, all -> 0x0058 }
        r3 = new android.graphics.BitmapFactory$Options;	 Catch:{ Exception -> 0x006a, all -> 0x0058 }
        r3.<init>();	 Catch:{ Exception -> 0x006a, all -> 0x0058 }
        r4 = 1;
        r3.inJustDecodeBounds = r4;	 Catch:{ Exception -> 0x006a, all -> 0x0058 }
        r4 = 0;
        com.tencent.mm.graphics.MMBitmapFactory.decodeStream(r2, r4, r3);	 Catch:{ Exception -> 0x006a, all -> 0x0058 }
        r3 = r3.outMimeType;	 Catch:{ Exception -> 0x006a, all -> 0x0058 }
        r4 = "MicroMsg.snsMediaStorage";
        r5 = "mineType ";
        r6 = java.lang.String.valueOf(r3);	 Catch:{ Exception -> 0x006a, all -> 0x0058 }
        r5 = r5.concat(r6);	 Catch:{ Exception -> 0x006a, all -> 0x0058 }
        com.tencent.mm.sdk.platformtools.ab.d(r4, r5);	 Catch:{ Exception -> 0x006a, all -> 0x0058 }
        r3 = r3.toLowerCase();	 Catch:{ Exception -> 0x006a, all -> 0x0058 }
        r4 = "webp";
        r3 = r3.indexOf(r4);	 Catch:{ Exception -> 0x006a, all -> 0x0058 }
        if (r3 < 0) goto L_0x0042;
    L_0x0039:
        if (r2 == 0) goto L_0x003e;
    L_0x003b:
        r2.close();	 Catch:{ IOException -> 0x0062 }
    L_0x003e:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r7);
    L_0x0041:
        return r0;
    L_0x0042:
        if (r2 == 0) goto L_0x0047;
    L_0x0044:
        r2.close();	 Catch:{ IOException -> 0x0064 }
    L_0x0047:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r7);
        r0 = r1;
        goto L_0x0041;
    L_0x004c:
        r0 = move-exception;
        r0 = r2;
    L_0x004e:
        if (r0 == 0) goto L_0x0053;
    L_0x0050:
        r0.close();	 Catch:{ IOException -> 0x0066 }
    L_0x0053:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r7);
        r0 = r1;
        goto L_0x0041;
    L_0x0058:
        r0 = move-exception;
        if (r2 == 0) goto L_0x005e;
    L_0x005b:
        r2.close();	 Catch:{ IOException -> 0x0068 }
    L_0x005e:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r7);
        throw r0;
    L_0x0062:
        r1 = move-exception;
        goto L_0x003e;
    L_0x0064:
        r0 = move-exception;
        goto L_0x0047;
    L_0x0066:
        r0 = move-exception;
        goto L_0x0053;
    L_0x0068:
        r1 = move-exception;
        goto L_0x005e;
    L_0x006a:
        r0 = move-exception;
        r0 = r2;
        goto L_0x004e;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.sns.storage.s.Zj(java.lang.String):boolean");
    }

    /* JADX WARNING: Removed duplicated region for block: B:51:0x00f0  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00c6  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00c6  */
    /* JADX WARNING: Removed duplicated region for block: B:51:0x00f0  */
    /* JADX WARNING: Removed duplicated region for block: B:51:0x00f0  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00c6  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00c6  */
    /* JADX WARNING: Removed duplicated region for block: B:51:0x00f0  */
    /* JADX WARNING: Removed duplicated region for block: B:46:0x00e6 A:{SYNTHETIC, Splitter:B:46:0x00e6} */
    /* JADX WARNING: Removed duplicated region for block: B:51:0x00f0  */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00c6  */
    /* JADX WARNING: Removed duplicated region for block: B:46:0x00e6 A:{SYNTHETIC, Splitter:B:46:0x00e6} */
    /* JADX WARNING: Removed duplicated region for block: B:38:0x00c6  */
    /* JADX WARNING: Removed duplicated region for block: B:51:0x00f0  */
    public static boolean a(java.lang.String r22, java.lang.String r23, java.lang.String r24, float r25) {
        /*
        r2 = 37997; // 0x946d float:5.3245E-41 double:1.8773E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r2);
        r4 = 0;
        r12 = 0;
        r10 = 1;
        r2 = 0;
        r3 = new java.lang.StringBuilder;	 Catch:{ Exception -> 0x00dd }
        r3.<init>();	 Catch:{ Exception -> 0x00dd }
        r0 = r22;
        r3 = r3.append(r0);	 Catch:{ Exception -> 0x00dd }
        r0 = r23;
        r3 = r3.append(r0);	 Catch:{ Exception -> 0x00dd }
        r3 = r3.toString();	 Catch:{ Exception -> 0x00dd }
        r2 = com.tencent.mm.vfs.e.openRead(r3);	 Catch:{ Exception -> 0x00dd }
        r3 = new android.graphics.BitmapFactory$Options;	 Catch:{ Exception -> 0x00f3 }
        r3.<init>();	 Catch:{ Exception -> 0x00f3 }
        r6 = 1;
        r3.inJustDecodeBounds = r6;	 Catch:{ Exception -> 0x00f3 }
        r6 = 0;
        com.tencent.mm.graphics.MMBitmapFactory.decodeStream(r2, r6, r3);	 Catch:{ Exception -> 0x00f3 }
        r2.close();	 Catch:{ Exception -> 0x00f3 }
        r6 = 0;
        r2 = r3.outWidth;	 Catch:{ Exception -> 0x00f7 }
        r14 = (double) r2;	 Catch:{ Exception -> 0x00f7 }
        r2 = r3.outHeight;	 Catch:{ Exception -> 0x00f7 }
        r12 = (double) r2;
        r4 = 4638144666238189568; // 0x405e000000000000 float:0.0 double:120.0;
        r2 = (r14 > r4 ? 1 : (r14 == r4 ? 0 : -1));
        if (r2 > 0) goto L_0x0047;
    L_0x0041:
        r4 = 4638144666238189568; // 0x405e000000000000 float:0.0 double:120.0;
        r2 = (r12 > r4 ? 1 : (r12 == r4 ? 0 : -1));
        if (r2 <= 0) goto L_0x0048;
    L_0x0047:
        r10 = 0;
    L_0x0048:
        r2 = r3.outMimeType;	 Catch:{ Exception -> 0x00fa }
        r2 = 0;
        r2 = (r14 > r2 ? 1 : (r14 == r2 ? 0 : -1));
        if (r2 < 0) goto L_0x0056;
    L_0x0050:
        r2 = 0;
        r2 = (r12 > r2 ? 1 : (r12 == r2 ? 0 : -1));
        if (r2 >= 0) goto L_0x00fe;
    L_0x0056:
        r4 = 4642648265865560064; // 0x406e000000000000 float:0.0 double:240.0;
        r2 = 4642648265865560064; // 0x406e000000000000 float:0.0 double:240.0;
        r16 = r2;
        r8 = r4;
    L_0x005d:
        r0 = r25;
        r2 = (double) r0;	 Catch:{ Exception -> 0x00fa }
        r4 = 1128792064; // 0x43480000 float:200.0 double:5.5769738E-315;
        r4 = r25 / r4;
        r5 = 1110441984; // 0x42300000 float:44.0 double:5.48631236E-315;
        r4 = r4 * r5;
        r0 = (double) r4;	 Catch:{ Exception -> 0x00fa }
        r18 = r0;
        r4 = 1128792064; // 0x43480000 float:200.0 double:5.5769738E-315;
        r4 = r25 / r4;
        r5 = 1126170624; // 0x43200000 float:160.0 double:5.564022167E-315;
        r4 = r4 * r5;
        r4 = (double) r4;	 Catch:{ Exception -> 0x00fa }
        r20 = 0;
        r7 = (r8 > r20 ? 1 : (r8 == r20 ? 0 : -1));
        if (r7 <= 0) goto L_0x00da;
    L_0x0078:
        r20 = 0;
        r7 = (r16 > r20 ? 1 : (r16 == r20 ? 0 : -1));
        if (r7 <= 0) goto L_0x00da;
    L_0x007e:
        r4 = r2 / r8;
        r20 = r2 / r16;
        r0 = r20;
        r4 = java.lang.Math.min(r4, r0);	 Catch:{ Exception -> 0x00fa }
        r8 = r8 * r4;
        r4 = r4 * r16;
        r6 = (r8 > r18 ? 1 : (r8 == r18 ? 0 : -1));
        if (r6 >= 0) goto L_0x0096;
    L_0x008f:
        r6 = 4607182418800017408; // 0x3ff0000000000000 float:0.0 double:1.0;
        r6 = r6 * r18;
        r6 = r6 / r8;
        r8 = r8 * r6;
        r4 = r4 * r6;
    L_0x0096:
        r6 = (r4 > r18 ? 1 : (r4 == r18 ? 0 : -1));
        if (r6 >= 0) goto L_0x00a1;
    L_0x009a:
        r6 = 4607182418800017408; // 0x3ff0000000000000 float:0.0 double:1.0;
        r6 = r6 * r18;
        r6 = r6 / r4;
        r8 = r8 * r6;
        r4 = r4 * r6;
    L_0x00a1:
        r6 = (r8 > r2 ? 1 : (r8 == r2 ? 0 : -1));
        if (r6 <= 0) goto L_0x00a6;
    L_0x00a5:
        r8 = r2;
    L_0x00a6:
        r6 = (r4 > r2 ? 1 : (r4 == r2 ? 0 : -1));
        if (r6 <= 0) goto L_0x00fc;
    L_0x00aa:
        r6 = r2;
    L_0x00ab:
        r2 = new java.lang.StringBuilder;
        r2.<init>();
        r0 = r22;
        r2 = r2.append(r0);
        r0 = r23;
        r2 = r2.append(r0);
        r2 = r2.toString();
        r3 = (int) r14;
        r4 = (int) r12;
        r5 = (int) r6;
        r6 = (int) r8;
        if (r10 == 0) goto L_0x00f0;
    L_0x00c6:
        r7 = android.graphics.Bitmap.CompressFormat.PNG;
    L_0x00c8:
        r8 = 70;
        r11 = 0;
        r9 = r22;
        r10 = r24;
        r2 = a(r2, r3, r4, r5, r6, r7, r8, r9, r10, r11);
        r3 = 37997; // 0x946d float:5.3245E-41 double:1.8773E-319;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r3);
        return r2;
    L_0x00da:
        r6 = r4;
        r8 = r4;
        goto L_0x00ab;
    L_0x00dd:
        r3 = move-exception;
        r6 = r2;
        r14 = r4;
    L_0x00e0:
        r4 = 4642648265865560064; // 0x406e000000000000 float:0.0 double:240.0;
        r2 = 4642648265865560064; // 0x406e000000000000 float:0.0 double:240.0;
        if (r6 == 0) goto L_0x00ed;
    L_0x00e6:
        r6.close();	 Catch:{ IOException -> 0x00ec }
        r6 = r2;
        r8 = r4;
        goto L_0x00ab;
    L_0x00ec:
        r6 = move-exception;
    L_0x00ed:
        r6 = r2;
        r8 = r4;
        goto L_0x00ab;
    L_0x00f0:
        r7 = android.graphics.Bitmap.CompressFormat.JPEG;
        goto L_0x00c8;
    L_0x00f3:
        r3 = move-exception;
        r6 = r2;
        r14 = r4;
        goto L_0x00e0;
    L_0x00f7:
        r2 = move-exception;
        r14 = r4;
        goto L_0x00e0;
    L_0x00fa:
        r2 = move-exception;
        goto L_0x00e0;
    L_0x00fc:
        r2 = r4;
        goto L_0x00aa;
    L_0x00fe:
        r16 = r12;
        r8 = r14;
        goto L_0x005d;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.sns.storage.s.a(java.lang.String, java.lang.String, java.lang.String, float):boolean");
    }

    private static boolean a(String str, int i, int i2, int i3, int i4, CompressFormat compressFormat, int i5, String str2, String str3, boolean z) {
        AppMethodBeat.i(37998);
        OutputStream outputStream = null;
        try {
            Bitmap b;
            ab.i("MicroMsg.snsMediaStorage", "createThumbNailUnScale, srcWidth: %s, srcHeight: %s, width: %s, height: %s", new Object[]{Integer.valueOf(i), Integer.valueOf(i2), Integer.valueOf(i4), Integer.valueOf(i3)});
            Options options = new Options();
            double d = (((double) i2) * 1.0d) / ((double) i3);
            double d2 = (((double) i) * 1.0d) / ((double) i4);
            if (i == i4 && i2 == i3) {
                b = com.tencent.mm.plugin.sns.d.a.b(str, options);
            } else {
                options.inSampleSize = 1;
                if (i2 > i3 || i > i4) {
                    options.inSampleSize = (int) (d < d2 ? d2 : d);
                    if (options.inSampleSize <= 1) {
                        options.inSampleSize = 1;
                    }
                }
                while (((i2 * i) / options.inSampleSize) / options.inSampleSize > 2764800) {
                    options.inSampleSize++;
                }
                ab.i("MicroMsg.snsMediaStorage", "createThumbNailUnScale, sampleSize: %s", new Object[]{Integer.valueOf(options.inSampleSize)});
                b = com.tencent.mm.plugin.sns.d.a.b(str, options);
            }
            ab.i("MicroMsg.snsMediaStorage", "createThumbNailUnScale, result bm: %s", new Object[]{b});
            if (b == null) {
                AppMethodBeat.o(37998);
                return false;
            }
            ab.i("MicroMsg.snsMediaStorage", "createThumbNailUnScale, bm.width: %s, bm.height: %s", new Object[]{Integer.valueOf(b.getWidth()), Integer.valueOf(b.getHeight())});
            if (z) {
                int ceil;
                int i6;
                int i7;
                if (d < d2) {
                    ceil = (int) Math.ceil(((((double) i4) * 1.0d) * ((double) i2)) / ((double) i));
                    i6 = i4;
                } else {
                    i6 = (int) Math.ceil(((((double) i3) * 1.0d) * ((double) i)) / ((double) i2));
                    ceil = i3;
                }
                int bJ = ExifHelper.bJ(str);
                if (bJ == 90 || bJ == 270) {
                    bJ = ceil;
                    i7 = i6;
                } else {
                    bJ = i6;
                    i7 = ceil;
                }
                Bitmap createScaledBitmap = Bitmap.createScaledBitmap(b, bJ, i7, true);
                if (createScaledBitmap != null) {
                    if (b != createScaledBitmap) {
                        l.Xf().v(b);
                    }
                    b = createScaledBitmap;
                }
                ab.i("MicroMsg.snsMediaStorage", "createThumbNailUnScalebyUpload, bm.width: %s, bm.height: %s", new Object[]{Integer.valueOf(b.getWidth()), Integer.valueOf(b.getHeight())});
            }
            outputStream = e.L(str2 + str3, false);
            d.a(b, i5, compressFormat, outputStream, false);
            l.Xf().v(b);
            outputStream.close();
            AppMethodBeat.o(37998);
            return true;
        } catch (IOException e) {
            ab.printErrStackTrace("MicroMsg.snsMediaStorage", e, "create thumbnail from orig failed: %s", new Object[]{str3});
            if (outputStream != null) {
                try {
                    outputStream.close();
                } catch (IOException e2) {
                }
            }
            AppMethodBeat.o(37998);
            return false;
        }
    }

    public static boolean b(String str, String str2, String str3, float f) {
        AppMethodBeat.i(37999);
        try {
            e.deleteFile(str + str3);
            Options amj = d.amj(str + str2);
            if (amj == null) {
                ab.e("MicroMsg.snsMediaStorage", "createUserAlbum, getImageOptions error");
                AppMethodBeat.o(37999);
                return false;
            }
            Bitmap b;
            if (amj.outMimeType == null || !(amj.outMimeType.toLowerCase().endsWith("png") || amj.outMimeType.toLowerCase().endsWith("vcodec"))) {
                int i = amj.outWidth;
                int i2 = amj.outHeight;
                int i3 = (int) f;
                int i4 = (int) f;
                amj.inJustDecodeBounds = false;
                ab.i("MicroMsg.snsMediaStorage", "createUserAlbum, srcWidth: %s, srcHeight: %s, dstWidth: %s, dstHeight: %s", new Object[]{Integer.valueOf(i), Integer.valueOf(i2), Integer.valueOf(i3), Integer.valueOf(i4)});
                if (i == i3 && i2 == i4) {
                    b = com.tencent.mm.plugin.sns.d.a.b(str + str2, amj);
                } else {
                    int i5;
                    int ceil;
                    if ((((double) i2) * 1.0d) / ((double) i4) > (((double) i) * 1.0d) / ((double) i3)) {
                        i5 = i3;
                        ceil = (int) Math.ceil(((((double) i3) * 1.0d) * ((double) i2)) / ((double) i));
                    } else {
                        i5 = (int) Math.ceil(((((double) i4) * 1.0d) * ((double) i)) / ((double) i2));
                        ceil = i4;
                    }
                    ab.d("MicroMsg.snsMediaStorage", "createUserAlbum, newWidth: %s, newHeight: %s", new Object[]{Integer.valueOf(i5), Integer.valueOf(ceil)});
                    amj.inSampleSize = 1;
                    if (i2 > ceil || i > i5) {
                        amj.inSampleSize = 1;
                        if (i2 > ceil || i > i5) {
                            double d = (((double) i2) * 1.0d) / ((double) ceil);
                            double d2 = (((double) i) * 1.0d) / ((double) i5);
                            if (d >= d2) {
                                d2 = d;
                            }
                            amj.inSampleSize = (int) d2;
                            if (amj.inSampleSize <= 1) {
                                amj.inSampleSize = 1;
                            }
                        }
                        while (((i2 * i) / amj.inSampleSize) / amj.inSampleSize > 2764800) {
                            amj.inSampleSize++;
                        }
                    }
                    ab.i("MicroMsg.snsMediaStorage", "createUserAlbum, inSampleSize: %s", new Object[]{Integer.valueOf(amj.inSampleSize)});
                    Bitmap b2;
                    if (((float) i2) / ((float) i) == ((float) i4) / ((float) i3)) {
                        b2 = com.tencent.mm.plugin.sns.d.a.b(str + str2, amj);
                        ab.i("MicroMsg.snsMediaStorage", "createUserAlbum, directly use inSampleSize");
                        b = b2;
                    } else {
                        float max = Math.max(((float) i5) / ((float) i), ((float) ceil) / ((float) i2));
                        int i6 = (int) (((float) i4) / max);
                        int min = Math.min(i, (int) (((float) i3) / max));
                        i6 = Math.min(i2, i6);
                        i5 = (i2 - i6) >> 1;
                        i3 = Math.max(0, (i - min) >> 1);
                        i5 = Math.max(0, i5);
                        Rect rect = new Rect();
                        rect.left = i3;
                        rect.right = i3 + min;
                        rect.top = i5;
                        rect.bottom = i5 + i6;
                        String str4 = str + str2;
                        long currentTimeMillis = System.currentTimeMillis();
                        b2 = l.Xf().a(str4, rect, amj);
                        if (b2 != null) {
                            b2 = i.s(str4, b2);
                        }
                        ab.d("MicroMsg.SnsBitmapUtil", "regionDecodeWithRotateByExif used %dms", new Object[]{Long.valueOf(System.currentTimeMillis() - currentTimeMillis)});
                        ab.i("MicroMsg.snsMediaStorage", "createUserAlbum, dstWidth: %s, dstHeight: %s, startX: %s, startY: %s, scaleFactor: %s", new Object[]{Integer.valueOf(min), Integer.valueOf(i6), Integer.valueOf(i3), Integer.valueOf(i5), Float.valueOf(max)});
                        b = b2;
                    }
                }
            } else {
                b = d.d(str + str2, (int) f, (int) f, true);
            }
            if (b == null) {
                ab.i("MicroMsg.snsMediaStorage", "bitmap error " + str + str2);
                e.deleteFile(str + str2);
                AppMethodBeat.o(37999);
                return false;
            }
            ab.i("MicroMsg.snsMediaStorage", "createUserAlbum, bm.width: %s, bm.height: %s", new Object[]{Integer.valueOf(b.getWidth()), Integer.valueOf(b.getHeight())});
            Object obj = 1;
            if (b.getHeight() > 120 || b.getWidth() > 120) {
                obj = null;
            }
            d.a(b, 100, obj != null ? CompressFormat.PNG : CompressFormat.JPEG, str + str3, false);
            l.Xf().v(b);
            AppMethodBeat.o(37999);
            return true;
        } catch (Exception e) {
            ab.e("MicroMsg.snsMediaStorage", "createUserAlbum error: %s", new Object[]{e.getMessage()});
            ab.printErrStackTrace("MicroMsg.snsMediaStorage", e, BuildConfig.FLAVOR, new Object[0]);
        }
    }

    public static Bitmap Zk(String str) {
        int i = 640;
        AppMethodBeat.i(38000);
        Options amj = d.amj(str);
        int i2 = amj.outWidth >= amj.outHeight ? VideoFilterUtil.IMAGE_HEIGHT : 640;
        if (amj.outWidth < amj.outHeight) {
            i = VideoFilterUtil.IMAGE_HEIGHT;
        }
        Bitmap d = d.d(str, i, i2, false);
        if (d == null) {
            AppMethodBeat.o(38000);
            return null;
        }
        d = d.b(d, (float) Exif.fromFile(str).getOrientationInDegree());
        AppMethodBeat.o(38000);
        return d;
    }
}
