package com.tencent.mm.aj;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapFactory.Options;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.g;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.sdk.platformtools.d;
import com.tencent.ytcommon.BuildConfig;
import java.io.IOException;
import java.io.InputStream;

public final class m {
    public static Bitmap rk(String str) {
        boolean z = false;
        AppMethodBeat.i(11428);
        if (!bo.isNullOrNil(str) && g.RP().isSDCardAvailable() && g.RN().QY()) {
            Bitmap rl = z.afb().rl(str);
            String str2 = "MicroMsg.BrandLogic";
            String str3 = "get verify user icon = %s, is null ? %s";
            Object[] objArr = new Object[2];
            objArr[0] = str;
            if (rl == null) {
                z = true;
            }
            objArr[1] = String.valueOf(z);
            ab.i(str2, str3, objArr);
            AppMethodBeat.o(11428);
            return rl;
        }
        AppMethodBeat.o(11428);
        return null;
    }

    /* JADX WARNING: Removed duplicated region for block: B:26:0x0094  */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x00c8  */
    /* JADX WARNING: Removed duplicated region for block: B:22:0x0083  */
    public static android.graphics.Bitmap aA(java.lang.String r5, java.lang.String r6) {
        /*
        r1 = 0;
        r4 = 11429; // 0x2ca5 float:1.6015E-41 double:5.6467E-320;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r4);
        r0 = com.tencent.mm.kernel.g.RP();
        r0 = r0.isSDCardAvailable();
        if (r0 != 0) goto L_0x0018;
    L_0x0010:
        r0 = aeK();
        com.tencent.matrix.trace.core.AppMethodBeat.o(r4);
    L_0x0017:
        return r0;
    L_0x0018:
        if (r5 == 0) goto L_0x0024;
    L_0x001a:
        r0 = com.tencent.mm.kernel.g.RN();
        r0 = r0.QY();
        if (r0 != 0) goto L_0x0029;
    L_0x0024:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r4);
        r0 = r1;
        goto L_0x0017;
    L_0x0029:
        if (r6 != 0) goto L_0x0036;
    L_0x002b:
        r6 = aB(r5, r1);
        if (r6 != 0) goto L_0x0036;
    L_0x0031:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r4);
        r0 = r1;
        goto L_0x0017;
    L_0x0036:
        r2 = com.tencent.mm.aj.z.afb();
        r0 = r2.fwK;
        r0 = r0.containsKey(r5);
        if (r0 == 0) goto L_0x009b;
    L_0x0042:
        r0 = r2.fwK;
        r0 = r0.get(r5);
        r0 = (java.lang.ref.WeakReference) r0;
        r0 = r0.get();
        r0 = (android.graphics.Bitmap) r0;
        if (r0 == 0) goto L_0x0058;
    L_0x0052:
        r0 = r0.isRecycled();
        if (r0 == 0) goto L_0x008a;
    L_0x0058:
        r0 = aB(r5, r6);
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r3 = r3.append(r5);
        r0 = r3.append(r0);
        r0 = r0.toString();
        r0 = com.tencent.mm.aj.m.a.rm(r0);
        r0 = com.tencent.mm.sdk.platformtools.d.aml(r0);
        if (r0 != 0) goto L_0x0087;
    L_0x0077:
        r0 = "MicroMsg.BrandLogic";
        r2 = "not found brand icon local";
        com.tencent.mm.sdk.platformtools.ab.i(r0, r2);
    L_0x0080:
        r0 = r1;
    L_0x0081:
        if (r0 == 0) goto L_0x00c8;
    L_0x0083:
        com.tencent.matrix.trace.core.AppMethodBeat.o(r4);
        goto L_0x0017;
    L_0x0087:
        r2.g(r5, r0);
    L_0x008a:
        r0 = r2.fwK;
        r0 = r0.get(r5);
        r0 = (java.lang.ref.WeakReference) r0;
        if (r0 == 0) goto L_0x0080;
    L_0x0094:
        r0 = r0.get();
        r0 = (android.graphics.Bitmap) r0;
        goto L_0x0081;
    L_0x009b:
        r0 = aB(r5, r6);
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r3 = r3.append(r5);
        r0 = r3.append(r0);
        r0 = r0.toString();
        r0 = com.tencent.mm.aj.m.a.rm(r0);
        r0 = com.tencent.mm.sdk.platformtools.d.aml(r0);
        if (r0 != 0) goto L_0x00c4;
    L_0x00ba:
        r0 = "MicroMsg.BrandLogic";
        r2 = "not found brand icon local";
        com.tencent.mm.sdk.platformtools.ab.i(r0, r2);
        goto L_0x0080;
    L_0x00c4:
        r2.g(r5, r0);
        goto L_0x008a;
    L_0x00c8:
        r0 = new com.tencent.mm.aj.m$1;
        r0.<init>(r5, r6);
        com.tencent.mm.sdk.platformtools.al.d(r0);
        com.tencent.matrix.trace.core.AppMethodBeat.o(r4);
        r0 = r1;
        goto L_0x0017;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.aj.m.aA(java.lang.String, java.lang.String):android.graphics.Bitmap");
    }

    private static Bitmap aeK() {
        InputStream inputStream = null;
        AppMethodBeat.i(11430);
        Options options = new Options();
        d.dnX();
        try {
            inputStream = ah.getContext().getResources().openRawResource(2130839709);
            Bitmap decodeStream = BitmapFactory.decodeStream(inputStream, null, options);
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    ab.printErrStackTrace("MicroMsg.BrandLogic", e, BuildConfig.FLAVOR, new Object[0]);
                }
            }
            if (decodeStream != null) {
                decodeStream = d.a(decodeStream, false, (float) (decodeStream.getWidth() >> 1));
            }
            AppMethodBeat.o(11430);
            return decodeStream;
        } catch (Throwable th) {
            if (inputStream != null) {
                try {
                    inputStream.close();
                } catch (IOException e2) {
                    ab.printErrStackTrace("MicroMsg.BrandLogic", e2, BuildConfig.FLAVOR, new Object[0]);
                }
            }
            AppMethodBeat.o(11430);
        }
    }

    static String aB(String str, String str2) {
        AppMethodBeat.i(11431);
        if (str == null || !g.RN().QY()) {
            AppMethodBeat.o(11431);
            return null;
        }
        d qP = z.aeR().qP(str);
        if (qP.field_brandIconURL != null) {
            str2 = qP.field_brandIconURL;
            AppMethodBeat.o(11431);
            return str2;
        }
        AppMethodBeat.o(11431);
        return str2;
    }
}
