/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  android.content.Context
 *  android.content.res.AssetManager
 *  android.content.res.Resources
 *  android.graphics.Bitmap
 *  android.graphics.BitmapFactory
 *  android.util.Log
 *  java.io.IOException
 *  java.io.InputStream
 *  java.io.OutputStream
 *  java.lang.Exception
 *  java.lang.Object
 *  java.lang.RuntimeException
 *  java.lang.String
 *  java.lang.StringBuilder
 *  java.lang.Throwable
 *  java.net.HttpURLConnection
 *  java.net.URL
 *  java.net.URLConnection
 *  java.net.URLEncoder
 */
package com.xinli.portalclient.util;

import android.content.Context;
import android.content.res.AssetManager;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import com.google.code.microlog4android.Logger;
import com.google.code.microlog4android.LoggerFactory;
import com.xinli.portalclient.model.RequestModel;
import com.xinli.portalclient.util.Config;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

public class BitmapUtils {
    public static final int REQUEST_TIMEOUT = 5000;
    public static final int SO_TIMEOUT = 10000;
    protected static final Logger logger = LoggerFactory.getLogger(BitmapUtils.class);

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    public static void closeStream(InputStream inputStream, OutputStream outputStream) {
        if (inputStream != null) {
            inputStream.close();
        }
        if (outputStream == null) return;
        try {
            outputStream.close();
            return;
        }
        catch (IOException var2_2) {
            var2_2.printStackTrace();
            return;
        }
    }

    /*
     * Exception decompiling
     */
    public static RequestModel getKey(String var0_1, String var1) throws RuntimeException {
        // This method has failed to decompile.  When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
        // org.benf.cfr.reader.util.ConfusedCFRException: Tried to end blocks [1[TRYBLOCK]], but top level block is 16[UNCONDITIONALDOLOOP]
        // org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.processEndingBlocks(Op04StructuredStatement.java:394)
        // org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.buildNestedBlocks(Op04StructuredStatement.java:446)
        // org.benf.cfr.reader.bytecode.analysis.opgraph.Op03SimpleStatement.createInitialStructuredBlock(Op03SimpleStatement.java:2859)
        // org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:805)
        // org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:220)
        // org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:165)
        // org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:91)
        // org.benf.cfr.reader.entities.Method.analyse(Method.java:354)
        // org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:751)
        // org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:683)
        // org.benf.cfr.reader.Main.doJar(Main.java:128)
        // com.njlabs.showjava.processor.JavaExtractor$1.run(JavaExtractor.java:84)
        // java.lang.Thread.run(Thread.java:818)
        throw new IllegalStateException("Decompilation failed");
    }

    public static Bitmap getLoacalBitmapByAssets(Context context, String string2) {
        InputStream inputStream = null;
        try {
            inputStream = context.getResources().getAssets().open(string2);
            Bitmap bitmap = BitmapFactory.decodeStream((InputStream)inputStream);
            return bitmap;
        }
        catch (IOException var4_4) {
            var4_4.printStackTrace();
            return null;
        }
        finally {
            BitmapUtils.closeStream(inputStream, null);
        }
    }

    /*
     * Unable to fully structure code
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     * Lifted jumps to return sites
     */
    public static RequestModel getPicture(String var0_1, int var1, int var2_2) throws RuntimeException {
        var3_3 = new RequestModel();
        var4_4 = null;
        var8_5 = Config.realUrl;
        var4_4 = null;
        if (var8_5 == null) {
            BitmapUtils.initRealAddress(Config.firstRreqUrl);
        }
        Log.w((String)"url", (String)(String.valueOf((Object)Config.realUrl) + "/wf.do?code=2"));
        var11_6 = new URL(String.valueOf((Object)Config.realUrl) + "/wf.do?code=2&screen=" + URLEncoder.encode((String)new StringBuilder(String.valueOf((int)var1)).append("*").append(var2_2).toString(), (String)"UTF-8"));
        try {
            var12_7 = (HttpURLConnection)var11_6.openConnection();
            var12_7.setConnectTimeout(5000);
            var12_7.setReadTimeout(10000);
            var12_7.setDoInput(true);
            var12_7.setRequestProperty("Cookie", var0_1);
            var12_7.connect();
            var4_4 = var12_7.getInputStream();
            var3_3.setBitmap(BitmapFactory.decodeStream((InputStream)var4_4));
        }
        catch (Throwable var5_13) {
            ** GOTO lbl-1000
        }
        catch (IOException var6_10) {}
        BitmapUtils.closeStream(var4_4, null);
        return var3_3;
        catch (IOException var6_8) {}
        {
            try {
                Log.e((String)"\u8bf7\u6c42\u56fe\u7247\u5f02\u5e38", (String)var6_9.getMessage());
                throw new RuntimeException("\u8bf7\u6c42\u56fe\u7247\u5f02\u5e38\uff1a" + var6_9.getMessage());
            }
            catch (Throwable var5_11) lbl-1000: // 2 sources:
            {
                BitmapUtils.closeStream(var4_4, null);
                throw var5_12;
            }
        }
    }

    /*
     * Exception decompiling
     */
    public static boolean initRealAddress(String var0) throws RuntimeException {
        // This method has failed to decompile.  When submitting a bug report, please provide this stack trace, and (if you hold appropriate legal rights) the relevant class file.
        // java.util.ConcurrentModificationException
        // java.util.LinkedList$ReverseLinkIterator.next(LinkedList.java:217)
        // org.benf.cfr.reader.bytecode.analysis.structured.statement.Block.extractLabelledBlocks(Block.java:212)
        // org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement$LabelledBlockExtractor.transform(Op04StructuredStatement.java:485)
        // org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.transform(Op04StructuredStatement.java:639)
        // org.benf.cfr.reader.bytecode.analysis.opgraph.Op04StructuredStatement.insertLabelledBlocks(Op04StructuredStatement.java:649)
        // org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisInner(CodeAnalyser.java:816)
        // org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysisOrWrapFail(CodeAnalyser.java:220)
        // org.benf.cfr.reader.bytecode.CodeAnalyser.getAnalysis(CodeAnalyser.java:165)
        // org.benf.cfr.reader.entities.attributes.AttributeCode.analyse(AttributeCode.java:91)
        // org.benf.cfr.reader.entities.Method.analyse(Method.java:354)
        // org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:751)
        // org.benf.cfr.reader.entities.ClassFile.analyseTop(ClassFile.java:683)
        // org.benf.cfr.reader.Main.doJar(Main.java:128)
        // com.njlabs.showjava.processor.JavaExtractor$1.run(JavaExtractor.java:84)
        // java.lang.Thread.run(Thread.java:818)
        throw new IllegalStateException("Decompilation failed");
    }

    public static void main(String[] arrstring) {
        BitmapUtils.initRealAddress("http://192.168.3.198:8888");
    }

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    public static RequestModel requestBeforeLogin(String string2, int n, int n2, String string3, String string4) throws RuntimeException {
        RequestModel requestModel = new RequestModel();
        try {
            logger.debug("onCreate ==requestBeforeLogin=step1===Config.realUrl==" + Config.realUrl);
            if (Config.realUrl == null) {
                BitmapUtils.initRealAddress(Config.firstRreqUrl);
            }
            logger.debug("onCreate ==requestBeforeLogin=step2===requestUrl==" + string2);
            Log.i((String)"request key and pic=======", (String)string2);
            RequestModel requestModel2 = BitmapUtils.getKey(string3, string4);
            if (!"version01".equals((Object)requestModel2.getMessage()) && !"nat01".equals((Object)requestModel2.getMessage())) {
                logger.debug("onCreate ==requestBeforeLogin=step4===keyResult.getKeyvalue==" + requestModel2.getKeyvalue());
                logger.debug("onCreate ==requestBeforeLogin=step4===keyResult.getSessionId==" + requestModel2.getSessionId());
                requestModel.setKeyvalue(requestModel2.getKeyvalue());
                requestModel.setSessionId(requestModel2.getSessionId());
                logger.debug("onCreate ==requestBeforeLogin=step5=====");
                RequestModel requestModel3 = BitmapUtils.getPicture(requestModel2.getSessionId(), n, n2);
                logger.debug("onCreate ==requestBeforeLogin=step6=====");
                requestModel.setBitmap(requestModel3.getBitmap());
                logger.debug("onCreate ==requestBeforeLogin=step7=====");
                return requestModel;
            }
            logger.debug("onCreate ==requestBeforeLogin=step3===keyResult==" + requestModel2);
            return requestModel2;
        }
        catch (Exception var6_8) {
            logger.error("onCreate ==requestBeforeLogin=Exception=====", (Throwable)var6_8);
            throw new RuntimeException(var6_8.getMessage());
        }
    }
}

