/*
 * Decompiled with CFR 0_110.
 * 
 * Could not load the following classes:
 *  android.annotation.SuppressLint
 *  android.app.AlertDialog
 *  android.app.AlertDialog$Builder
 *  android.app.ProgressDialog
 *  android.content.BroadcastReceiver
 *  android.content.Context
 *  android.content.DialogInterface
 *  android.content.DialogInterface$OnClickListener
 *  android.content.Intent
 *  android.content.SharedPreferences
 *  android.content.SharedPreferences$Editor
 *  android.content.res.Resources
 *  android.graphics.Bitmap
 *  android.graphics.drawable.Drawable
 *  android.net.ConnectivityManager
 *  android.net.DhcpInfo
 *  android.net.NetworkInfo
 *  android.net.NetworkInfo$State
 *  android.net.Uri
 *  android.net.wifi.WifiInfo
 *  android.net.wifi.WifiManager
 *  android.os.Bundle
 *  android.os.Environment
 *  android.os.Handler
 *  android.os.Message
 *  android.os.Process
 *  android.text.Editable
 *  android.text.TextWatcher
 *  android.text.format.Formatter
 *  android.util.Log
 *  android.util.Xml
 *  android.view.KeyEvent
 *  android.view.LayoutInflater
 *  android.view.MotionEvent
 *  android.view.View
 *  android.view.View$OnClickListener
 *  android.view.View$OnTouchListener
 *  android.view.ViewGroup
 *  android.view.ViewGroup$LayoutParams
 *  android.widget.AdapterView
 *  android.widget.AdapterView$OnItemSelectedListener
 *  android.widget.ArrayAdapter
 *  android.widget.CheckBox
 *  android.widget.EditText
 *  android.widget.ImageView
 *  android.widget.LinearLayout
 *  android.widget.LinearLayout$LayoutParams
 *  android.widget.ListAdapter
 *  android.widget.ListView
 *  android.widget.PopupWindow
 *  android.widget.SimpleAdapter
 *  android.widget.TextView
 *  android.widget.Toast
 *  java.io.BufferedInputStream
 *  java.io.File
 *  java.io.FileOutputStream
 *  java.io.InputStream
 *  java.io.PrintStream
 *  java.io.UnsupportedEncodingException
 *  java.lang.CharSequence
 *  java.lang.Class
 *  java.lang.Exception
 *  java.lang.Object
 *  java.lang.Runnable
 *  java.lang.String
 *  java.lang.System
 *  java.lang.Thread
 *  java.net.HttpURLConnection
 *  java.net.URL
 *  java.net.URLConnection
 *  java.util.ArrayList
 *  java.util.Date
 *  java.util.HashMap
 *  java.util.List
 *  java.util.Map
 *  java.util.Set
 *  org.apache.http.message.BasicNameValuePair
 *  org.xmlpull.v1.XmlPullParser
 */
package com.xinli.portalclient;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
import android.net.DhcpInfo;
import android.net.NetworkInfo;
import android.net.Uri;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.os.Process;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.format.Formatter;
import android.util.Log;
import android.util.Xml;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.Toast;
import com.google.code.microlog4android.Logger;
import com.xinli.portalclient.BaseActivity;
import com.xinli.portalclient.MySurfaceView;
import com.xinli.portalclient.SetAccountActivity;
import com.xinli.portalclient.SucessActivity;
import com.xinli.portalclient.WifiManagerUtil;
import com.xinli.portalclient.model.RequestModel;
import com.xinli.portalclient.model.UpdataInfo;
import com.xinli.portalclient.util.BitmapUtils;
import com.xinli.portalclient.util.Config;
import com.xinli.portalclient.util.HttpUtils;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.http.message.BasicNameValuePair;
import org.xmlpull.v1.XmlPullParser;

@SuppressLint(value={"NewApi"})
public class MainActivity
extends BaseActivity {
    public static final int CHECK_DISCONNECT = 2;
    public static final int DISCOVER = 1;
    protected static final int DOWN_ERROR = 2;
    private static final int GET_UNDATAINFO_ERROR = 1;
    public static final int INIT_RESET_WIFI = 3;
    protected static final String TAG = "Client";
    private static final int UPDATA_CLIENT = 0;
    private static final int UPDATA_CLIENT_FORCE = 4;
    ArrayAdapter<String> _Adapter;
    Handler authHandler;
    private SharedPreferences defaultAccFile;
    private MyAdapter dropDownAdapter;
    ImageView errView;
    LinearLayout gestureLayout;
    Handler handler;
    Handler handlerUpdate;
    private MySurfaceView imageView;
    private UpdataInfo info;
    private String ipConfig;
    private String keyvalue;
    private List list1;
    private List list2;
    private SharedPreferences loginFile;
    private int mConnMethod;
    private ProgressDialog mDialog;
    private String mPassword;
    private String mSsid;
    private WifiInfo mWifiInfo;
    private WifiManager mWifiManager;
    private WifiManagerUtil mWifiUtil;
    private ImageView moreSelect;
    public String password;
    private int picHeight;
    private int picWidth;
    private PopupWindow popView;
    BroadcastReceiver receiver;
    RequestModel reqResource;
    String[] resultArray;
    CheckBox savePasswordCB;
    private int screenHeight;
    private int screenWidth;
    private String sessionId;
    private SharedPreferences sp;
    public EditText username;
    private String usernametext;

    public MainActivity() {
        this.handler = new Handler(){

            public void handleMessage(Message message) {
                switch (message.what) {
                    default: {
                        return;
                    }
                    case 0: {
                        MainActivity.access$0(MainActivity.this, (List)message.getData().getParcelableArrayList("list1"));
                        MainActivity.access$1(MainActivity.this, (List)message.getData().getParcelableArrayList("list2"));
                        MainActivity.access$2(MainActivity.this, message.getData().getInt("picwidth"));
                        MainActivity.access$3(MainActivity.this, message.getData().getInt("picheight"));
                        MainActivity.access$4(MainActivity.this, new ProgressDialog((Context)MainActivity.this));
                        MainActivity.this.mDialog.setTitle((CharSequence)"\u767b\u5f55");
                        MainActivity.this.mDialog.setMessage((CharSequence)"\u6b63\u5728\u767b\u5f55\u670d\u52a1\u5668\uff0c\u8bf7\u7a0d\u540e...");
                        MainActivity.this.mDialog.show();
                        new Thread((Runnable)new LoginThread()).start();
                        return;
                    }
                    case 1: {
                        MainActivity.this.sendDiscover();
                        return;
                    }
                    case 2: {
                        if (MainActivity.this.wifiConnectState()) {
                            MainActivity.this.handler.sendEmptyMessageDelayed(2, 1000);
                            return;
                        }
                        MainActivity.this.logger.debug("showDialog==CHECK_DISCONNECT=");
                        MainActivity.this.handler.removeMessages(2);
                        MainActivity.access$4(MainActivity.this, new ProgressDialog((Context)MainActivity.this));
                        MainActivity.this.mDialog.setTitle((CharSequence)"\u767b\u5f55\u5237\u65b0");
                        MainActivity.this.mDialog.setMessage((CharSequence)"\u6b63\u5728\u8fde\u63a5\u670d\u52a1\u5668\uff0c\u8bf7\u7a0d\u540e...");
                        MainActivity.this.mDialog.show();
                        MainActivity.this.mWifiUtil.connectToTargetWifi(MainActivity.this.mSsid, MainActivity.this.mPassword, MainActivity.this.mConnMethod);
                        MainActivity.this.handler.sendEmptyMessage(1);
                        return;
                    }
                    case 3: 
                }
                MainActivity.this.showDialog();
            }
        };
        this.authHandler = new Handler(){

            /*
             * Enabled aggressive block sorting
             * Enabled unnecessary exception pruning
             * Enabled aggressive exception aggregation
             */
            public void handleMessage(Message message) {
                String string2 = message.getData().getString("resultDesc");
                switch (message.what) {
                    default: {
                        return;
                    }
                    case 0: {
                        MainActivity.this.logger.debug("authHandler ==step1 ==========");
                        MainActivity.this.mDialog.cancel();
                        SucessActivity.userInfo = new RequestModel(MainActivity.this.usernametext, MainActivity.this.sessionId);
                        SharedPreferences.Editor editor = MainActivity.this.loginFile.edit();
                        editor.putString("username", MainActivity.this.usernametext);
                        editor.putString("sessionId", MainActivity.this.sessionId);
                        if (Config.realUrl != null && !Config.realUrl.isEmpty() && !Config.firstRreqUrl.equalsIgnoreCase(Config.realUrl)) {
                            MainActivity.this.logger.debug("authHandler ==Config.realUrl ==========");
                            editor.putString(Config.REDIRECTINFO, Config.realUrl);
                            editor.commit();
                        }
                        MainActivity.this.logger.debug("authHandler ==step2 =======SucessActivity===usernametext==" + MainActivity.this.usernametext + "==sessionId==" + MainActivity.this.sessionId);
                        Intent intent = new Intent(MainActivity.this.getApplicationContext(), (Class)SucessActivity.class);
                        intent.putExtra("loginTime", System.currentTimeMillis());
                        intent.putExtra("authFlag", true);
                        MainActivity.this.startActivity(intent);
                        return;
                    }
                    case 1: {
                        MainActivity.this.mDialog.cancel();
                        Toast.makeText((Context)MainActivity.this.getApplicationContext(), (CharSequence)string2, (int)0).show();
                        return;
                    }
                    case 2: {
                        RequestModel requestModel;
                        MainActivity.this.logger.debug("\u6311\u6218\u7801\u8fc7\u671f,\u91cd\u65b0\u83b7\u53d6\u56fe\u7247\u548ckey");
                        try {
                            if (MainActivity.this.privateIpAdress()) {
                                MainActivity.this.exceptionView();
                                MainActivity.this.logger.debug("\u662f\u79c1\u7f51\u5730\u5740\u2026\u2026\u5e94\u8be5\u8fd4\u56de");
                                Toast.makeText((Context)MainActivity.this.getApplicationContext(), (CharSequence)"\u7f51\u7edc\u5f02\u5e38\uff0c\u8bf7\u68c0\u67e5\u7f51\u7edc\uff01", (int)0).show();
                                MainActivity.this.mDialog.cancel();
                                return;
                            }
                            MainActivity.this.logger.debug("\u4e0d\u662f\u79c1\u7f51\u5730\u5740\u2026\u2026");
                            requestModel = BitmapUtils.getKey(MainActivity.this.getVersionName(), MainActivity.this.intToIp(MainActivity.this.getLocalIpAddress()));
                            MainActivity.this.logger.info("result===========" + requestModel.getMessage());
                            if ("nat01".equals((Object)requestModel.getMessage())) {
                                MainActivity.this.mDialog.cancel();
                                Toast.makeText((Context)MainActivity.this.getApplicationContext(), (CharSequence)"\u7f51\u7edc\u5f02\u5e38\uff0c\u8bf7\u68c0\u67e5\u7f51\u7edc\uff01", (int)0).show();
                                MainActivity.this.exceptionView();
                                return;
                            }
                        }
                        catch (Exception var3_5) {
                            MainActivity.this.logger.error("\u6311\u6218\u7801\u8fc7\u671f,\u91cd\u65b0\u83b7\u53d6\u56fe\u7247\u548ckey\u53d1\u751f\u5f02\u5e38" + var3_5.getMessage());
                            MainActivity.this.mDialog.cancel();
                            Toast.makeText((Context)MainActivity.this.getApplicationContext(), (CharSequence)"\u83b7\u53d6\u624b\u52bf\u5931\u8d25\uff0c\u8bf7\u70b9\u51fb\u6309\u94ae\u91cd\u65b0\u8bf7\u6c42\u624b\u52bf", (int)0).show();
                            return;
                        }
                        if ("version01".equals((Object)requestModel.getMessage())) {
                            MainActivity.this.logger.info("\u7248\u672c\u4e0d\u662f\u6700\u65b0\u7684========");
                            Toast.makeText((Context)MainActivity.this.getApplicationContext(), (CharSequence)"\u60a8\u7684\u7248\u672c\u8fc7\u4f4e\uff0c\u8bf7\u6309\u63d0\u793a\u8fdb\u884c\u66f4\u65b0\uff01", (int)1).show();
                            new Thread((Runnable)new CheckVersionTask(true)).start();
                            MainActivity.this.mDialog.cancel();
                            return;
                        }
                        MainActivity.this.imageView.setSessionId(requestModel.getSessionId());
                        MainActivity.this.imageView.setKeyvalue(requestModel.getKeyvalue());
                        MainActivity.access$19(MainActivity.this, requestModel.getSessionId());
                        MainActivity.access$20(MainActivity.this, requestModel.getKeyvalue());
                        MainActivity.access$18((MainActivity)MainActivity.this).bitmap = BitmapUtils.getPicture(requestModel.getSessionId(), MainActivity.this.screenWidth, MainActivity.this.screenHeight).getBitmap();
                        MainActivity.this.logger.debug("\u6311\u6218\u7801\u8fc7\u671f,\u91cd\u65b0\u83b7\u53d6\u56fe\u7247\u548ckey\u6210\u529f");
                        MainActivity.this.reqResource.setSessionId(MainActivity.this.imageView.getSessionId());
                        MainActivity.this.reqResource.setKeyvalue(MainActivity.this.imageView.getKeyvalue());
                        MainActivity.this.reqResource.setBitmap(MainActivity.access$18((MainActivity)MainActivity.this).bitmap);
                        MainActivity.this.mDialog.cancel();
                        Toast.makeText((Context)MainActivity.this.getApplicationContext(), (CharSequence)string2, (int)0).show();
                        return;
                    }
                    case 3: {
                        MainActivity.this.mDialog.cancel();
                        Toast.makeText((Context)MainActivity.this.getApplicationContext(), (CharSequence)string2, (int)0).show();
                        return;
                    }
                    case 4: {
                        MainActivity.this.mDialog.cancel();
                        MainActivity.this.exceptionView();
                        Toast.makeText((Context)MainActivity.this.getApplicationContext(), (CharSequence)string2, (int)0).show();
                        return;
                    }
                    case 100: 
                }
                MainActivity.this.mDialog.cancel();
                Toast.makeText((Context)MainActivity.this.getApplicationContext(), (CharSequence)string2, (int)0).show();
            }
        };
        this.receiver = new BroadcastReceiver(){

            public void onReceive(Context context, Intent intent) {
                if (intent.getAction().equals((Object)"mysurface")) {
                    MainActivity.this.logger.debug("receiver ==SucessActivity ==========");
                    MainActivity.this.logger.debug("receiver =====usernametext==" + MainActivity.this.usernametext + "==sessionId==" + MainActivity.this.sessionId);
                    Intent intent2 = new Intent(context, (Class)SucessActivity.class);
                    intent.putExtra("authFlag", true);
                    context.startActivity(intent2);
                    MainActivity.this.finish();
                }
            }
        };
        this.handlerUpdate = new Handler(){

            public void handleMessage(Message message) {
                super.handleMessage(message);
                switch (message.what) {
                    default: {
                        return;
                    }
                    case 0: {
                        MainActivity.this.showUpdataDialog(false);
                        return;
                    }
                    case 2: {
                        Toast.makeText((Context)MainActivity.this.getApplicationContext(), (CharSequence)"\u4e0b\u8f7d\u65b0\u7248\u672c\u5931\u8d25", (int)1).show();
                        return;
                    }
                    case 4: 
                }
                MainActivity.this.showUpdataDialog(true);
            }
        };
    }

    static /* synthetic */ void access$0(MainActivity mainActivity, List list) {
        mainActivity.list1 = list;
    }

    static /* synthetic */ void access$1(MainActivity mainActivity, List list) {
        mainActivity.list2 = list;
    }

    static /* synthetic */ void access$19(MainActivity mainActivity, String string2) {
        mainActivity.sessionId = string2;
    }

    static /* synthetic */ void access$2(MainActivity mainActivity, int n) {
        mainActivity.picWidth = n;
    }

    static /* synthetic */ void access$20(MainActivity mainActivity, String string2) {
        mainActivity.keyvalue = string2;
    }

    static /* synthetic */ void access$23(MainActivity mainActivity, UpdataInfo updataInfo) {
        mainActivity.info = updataInfo;
    }

    static /* synthetic */ String access$25(MainActivity mainActivity) {
        return mainActivity.keyvalue;
    }

    static /* synthetic */ List access$26(MainActivity mainActivity) {
        return mainActivity.list1;
    }

    static /* synthetic */ List access$27(MainActivity mainActivity) {
        return mainActivity.list2;
    }

    static /* synthetic */ int access$28(MainActivity mainActivity) {
        return mainActivity.picWidth;
    }

    static /* synthetic */ int access$29(MainActivity mainActivity) {
        return mainActivity.picHeight;
    }

    static /* synthetic */ void access$3(MainActivity mainActivity, int n) {
        mainActivity.picHeight = n;
    }

    static /* synthetic */ void access$30(MainActivity mainActivity, String string2) {
        mainActivity.usernametext = string2;
    }

    static /* synthetic */ void access$33(MainActivity mainActivity, String string2) {
        mainActivity.mPassword = string2;
    }

    static /* synthetic */ void access$37(MainActivity mainActivity) {
        mainActivity.showTips();
    }

    static /* synthetic */ RequestModel access$38(MainActivity mainActivity) {
        return mainActivity.setAuthPicAndKey();
    }

    static /* synthetic */ void access$39(MainActivity mainActivity, MySurfaceView mySurfaceView) {
        mainActivity.imageView = mySurfaceView;
    }

    static /* synthetic */ void access$4(MainActivity mainActivity, ProgressDialog progressDialog) {
        mainActivity.mDialog = progressDialog;
    }

    private void exceptionView() {
        try {
            if (this.imageView != null) {
                this.gestureLayout.removeView((View)this.imageView);
            }
            this.errView = new ImageView((Context)this);
            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2);
            this.errView.setBackgroundResource(2130837520);
            this.gestureLayout.addView((View)this.errView, (ViewGroup.LayoutParams)layoutParams);
            return;
        }
        catch (Exception var1_2) {
            return;
        }
    }

    public static File getFileFromServer(String string2, ProgressDialog progressDialog) throws Exception {
        if (Environment.getExternalStorageState().equals((Object)"mounted")) {
            HttpURLConnection httpURLConnection = (HttpURLConnection)new URL(string2).openConnection();
            httpURLConnection.setConnectTimeout(5000);
            progressDialog.setMax(httpURLConnection.getContentLength());
            InputStream inputStream = httpURLConnection.getInputStream();
            File file = new File(Environment.getExternalStorageDirectory(), "portal_client_update.apk");
            FileOutputStream fileOutputStream = new FileOutputStream(file);
            BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
            byte[] arrby = new byte[1024];
            int n = 0;
            do {
                int n2;
                if ((n2 = bufferedInputStream.read(arrby)) == -1) {
                    fileOutputStream.close();
                    bufferedInputStream.close();
                    inputStream.close();
                    return file;
                }
                fileOutputStream.write(arrby, 0, n2);
                progressDialog.setProgress(n += n2);
            } while (true);
        }
        return null;
    }

    /*
     * Enabled aggressive block sorting
     */
    public static UpdataInfo getUpdataInfo(InputStream inputStream) throws Exception {
        XmlPullParser xmlPullParser = Xml.newPullParser();
        xmlPullParser.setInput(inputStream, "utf-8");
        int n = xmlPullParser.getEventType();
        UpdataInfo updataInfo = new UpdataInfo();
        while (n != 1) {
            switch (n) {
                default: {
                    break;
                }
                case 2: {
                    if ("version".equals((Object)xmlPullParser.getName())) {
                        updataInfo.setVersion(xmlPullParser.nextText());
                        break;
                    }
                    if ("url".equals((Object)xmlPullParser.getName())) {
                        updataInfo.setUrl(xmlPullParser.nextText());
                        break;
                    }
                    if (!"description".equals((Object)xmlPullParser.getName())) break;
                    updataInfo.setDescription(xmlPullParser.nextText());
                }
            }
            n = xmlPullParser.next();
        }
        return updataInfo;
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    private String getWifiMacAddress() {
        WifiInfo wifiInfo;
        String string2;
        try {
            wifiInfo = ((WifiManager)this.getSystemService("wifi")).getConnectionInfo();
            string2 = "";
            if (wifiInfo == null) return string2;
        }
        catch (Exception var1_3) {
            var1_3.printStackTrace();
            return "";
        }
        string2 = wifiInfo.getMacAddress().replaceAll(":", "-");
        this.logger.debug("mac===" + string2);
        return string2;
    }

    private void initLoginUserName() {
        this.logger.debug("onCreate ==initLoginUserName===step1===");
        if (((String[])this.sp.getAll().keySet().toArray((Object[])new String[0])).length > 0) {
            String string2 = this.defaultAccFile.getString("default_account", "");
            this.username.setText((CharSequence)string2);
            this.usernametext = this.username.getText().toString();
            this.password = this.sp.getString(this.usernametext, "");
        }
        this.logger.debug("onCreate ==initLoginUserName=step2====usernametext==" + this.usernametext);
        this.username.addTextChangedListener(new TextWatcher(){

            public void afterTextChanged(Editable editable) {
            }

            public void beforeTextChanged(CharSequence charSequence, int n, int n2, int n3) {
            }

            public void onTextChanged(CharSequence charSequence, int n, int n2, int n3) {
                MainActivity.access$30(MainActivity.this, MainActivity.this.username.getText().toString());
                MainActivity.this.password = MainActivity.this.sp.getString(MainActivity.this.usernametext, "");
            }
        });
    }

    private void initPopView(String[] arrstring) {
        ArrayList arrayList = new ArrayList();
        int n = 0;
        do {
            if (n >= arrstring.length) {
                this.dropDownAdapter = (MainActivity)this.new MyAdapter((Context)this, (List<HashMap<String, Object>>)arrayList, 2130903043, new String[]{"name"}, new int[]{2131296269});
                ListView listView = new ListView((Context)this);
                listView.setAdapter((ListAdapter)this.dropDownAdapter);
                this.popView = new PopupWindow((View)listView, this.username.getWidth(), -2, false);
                this.popView.setBackgroundDrawable(this.getResources().getDrawable(2130837553));
                return;
            }
            HashMap hashMap = new HashMap();
            hashMap.put((Object)"name", (Object)arrstring[n]);
            arrayList.add((Object)hashMap);
            ++n;
        } while (true);
    }

    /*
     * Enabled aggressive block sorting
     */
    private boolean privateIpAdress() {
        int n = MainActivity.ntol(this.getLocalIpAddress());
        System.out.println(n);
        boolean bl = n >= -1062731776 && n <= -1062666241 ? true : (n >= 167772160 && n <= 184549375 ? true : n >= -1408237568 && n <= -1400635393);
        this.logger.debug("result ============" + bl);
        return bl;
    }

    /*
     * Enabled aggressive block sorting
     * Enabled unnecessary exception pruning
     * Enabled aggressive exception aggregation
     */
    private void sendDiscover() {
        if (!this.wifiConnectState()) {
            this.handler.sendEmptyMessageDelayed(1, 1000);
            return;
        }
        ArrayList arrayList = new ArrayList();
        this.logger.info("sendDiscover===usernametext==" + this.usernametext);
        arrayList.add((Object)new BasicNameValuePair("username", this.usernametext));
        try {
            this.logger.debug("\u5f00\u59cb\u53d1\u9001Discover\u62a5\u6587:" + Config.realUrl + "/wf.do?code=9  sessionId:" + this.sessionId + "time:" + (Object)new Date());
            String string2 = HttpUtils.sendContentByHttpClient(String.valueOf((Object)Config.realUrl) + "/wf.do?code=9", this.sessionId, (List)arrayList);
            this.logger.debug("\u63a5\u6536Discover==result==\uff1a" + string2 + "==ReturnMessage.DISCOVER_TRUE==" + "discover00");
            if ("discover00".equals((Object)string2)) {
                SucessActivity.userInfo = new RequestModel(this.usernametext, this.sessionId);
                SharedPreferences.Editor editor = this.loginFile.edit();
                editor.putString("username", this.usernametext);
                editor.putString("sessionId", this.sessionId);
                if (Config.realUrl != null && !Config.realUrl.isEmpty() && !Config.firstRreqUrl.equalsIgnoreCase(Config.realUrl)) {
                    this.logger.debug("authHandler ==Config.realUrl ==========");
                    editor.putString(Config.REDIRECTINFO, Config.realUrl);
                    editor.commit();
                }
                this.logger.debug("authHandler ==step2 =======SucessActivity===usernametext==" + this.usernametext + "==sessionId==" + this.sessionId);
                Intent intent = new Intent(this.getApplicationContext(), (Class)SucessActivity.class);
                intent.putExtra("loginTime", System.currentTimeMillis());
                intent.putExtra("authFlag", true);
                this.startActivity(intent);
                return;
            }
            this.logger.debug("sendEmptyMessageDelayed\uff1a");
            this.handler.sendEmptyMessageDelayed(1, 1000);
            return;
        }
        catch (Exception var3_5) {
            this.logger.error("\u53d1\u9001Discover\u62a5\u6587\u53d1\u751f\u5f02\u5e38message" + var3_5.toString());
            return;
        }
    }

    /*
     * Enabled force condition propagation
     * Lifted jumps to return sites
     */
    private RequestModel setAuthPicAndKey() {
        RequestModel requestModel;
        this.logger.debug("onCreate ==setAuthPicAndKey=step1=====");
        if (this.privateIpAdress()) {
            this.logger.debug("onCreate ==setAuthPicAndKey=step2=====");
            this.exceptionView();
            Toast.makeText((Context)this.getApplicationContext(), (CharSequence)"\u7f51\u7edc\u5f02\u5e38\uff0c\u8bf7\u68c0\u67e5\u7f51\u7edc\uff01", (int)0).show();
            return null;
        }
        this.gestureLayout.removeView((View)this.errView);
        try {
            this.logger.debug("onCreate get key start");
            requestModel = BitmapUtils.requestBeforeLogin(Config.firstRreqUrl, this.screenWidth, this.screenHeight, this.getVersionName(), this.intToIp(this.getLocalIpAddress()));
            this.logger.debug("onCreate get key success");
        }
        catch (Exception var1_2) {
            this.exceptionView();
            this.logger.error("onCreate\u8bf7\u6c42\u624b\u52bf key\u8d44\u6e90\u53d1\u751f\u5f02\u5e38" + var1_2.getMessage());
            Toast.makeText((Context)this.getApplicationContext(), (CharSequence)"\u83b7\u53d6\u624b\u52bf\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u7f51\u7edc\u6216\u7a0d\u5019\u518d\u8bd5", (int)0).show();
            return null;
        }
        if ("nat01".equals((Object)requestModel.getMessage())) {
            this.exceptionView();
            do {
                return requestModel;
                break;
            } while (true);
        }
        if ("version01".equals((Object)requestModel.getMessage())) {
            Toast.makeText((Context)this.getApplicationContext(), (CharSequence)"\u60a8\u7684\u7248\u672c\u8fc7\u4f4e\uff0c\u8bf7\u6309\u201c\u786e\u5b9a\u201d\u6309\u94ae\u8fdb\u884c\u7248\u672c\u66f4\u65b0\uff01", (int)1).show();
            new Thread((Runnable)new CheckVersionTask(true)).start();
            requestModel.setForceUpdated(true);
            return requestModel;
        }
        this.logger.debug("onCreate ==setAuthPicAndKey=step3=====");
        System.out.println("imageView=====1=" + (Object)((Object)this.imageView));
        this.imageView = new MySurfaceView((Context)this, requestModel.getBitmap(), this.sp, this.handler);
        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(-2, -2);
        this.imageView.setSessionId(requestModel.getSessionId());
        this.imageView.setFocusableInTouchMode(true);
        this.imageView.setKeyvalue(requestModel.getKeyvalue());
        this.gestureLayout.addView((View)this.imageView, (ViewGroup.LayoutParams)layoutParams);
        this.sessionId = requestModel.getSessionId();
        this.keyvalue = requestModel.getKeyvalue();
        System.out.println("imageView=====2=" + (Object)((Object)this.imageView));
        return requestModel;
    }

    private void showDialog() {
        this.logger.debug("showDialog==step1==");
        this.mWifiUtil = new WifiManagerUtil((Context)this, this.logger);
        this.mWifiUtil.getWifiInfo();
        this.mWifiManager = (WifiManager)this.getSystemService("wifi");
        this.mWifiInfo = this.mWifiManager.getConnectionInfo();
        this.mSsid = this.mWifiInfo.getSSID().trim();
        this.mSsid = this.trim(this.mSsid);
        this.mConnMethod = 1;
        this.logger.debug("showDialog==step2==mSsid=" + this.mSsid);
        View view = LayoutInflater.from((Context)this).inflate(2130903042, null);
        final EditText editText = (EditText)view.findViewById(2131296268);
        AlertDialog.Builder builder = new AlertDialog.Builder((Context)this);
        builder.setCancelable(false);
        builder.setTitle((CharSequence)"\u8f93\u5165WIFI\u5bc6\u7801");
        builder.setMessage((CharSequence)this.mSsid);
        builder.setView(view);
        builder.setPositiveButton((CharSequence)"\u786e\u5b9a", new DialogInterface.OnClickListener(){

            public void onClick(DialogInterface dialogInterface, int n) {
                MainActivity.access$33(MainActivity.this, editText.getText().toString().trim());
                DhcpInfo dhcpInfo = MainActivity.this.mWifiManager.getDhcpInfo();
                MainActivity.this.logger.debug("==mSsid==" + MainActivity.this.mSsid + "==mPassword==" + MainActivity.this.mPassword + "==dhcpinfo.ipAddress==" + Formatter.formatIpAddress((int)dhcpInfo.ipAddress));
                MainActivity.this.mWifiManager.disableNetwork(MainActivity.this.mWifiInfo.getNetworkId());
                MainActivity.this.mWifiManager.disconnect();
                MainActivity.this.logger.debug("showDialog==disconnect=");
                MainActivity.this.handler.sendEmptyMessage(2);
                dialogInterface.dismiss();
            }
        });
        builder.setNeutralButton((CharSequence)"\u53d6\u6d88", new DialogInterface.OnClickListener(){

            public void onClick(DialogInterface dialogInterface, int n) {
                editText.setText((CharSequence)"");
            }
        });
        builder.show();
        this.logger.debug("showDialog==step3=");
    }

    private void showTips() {
        AlertDialog.Builder builder = new AlertDialog.Builder((Context)this);
        builder.setIcon(17301543);
        builder.setTitle((CharSequence)"\u6ca1\u6709\u53ef\u7528Wifi\u7f51\u7edc");
        builder.setMessage((CharSequence)"\u5f53\u524dWifi\u7f51\u7edc\u4e0d\u53ef\u7528\uff0c\u662f\u5426\u8bbe\u7f6eWifi\u7f51\u7edc\uff1f");
        builder.setPositiveButton((CharSequence)"\u786e\u5b9a", new DialogInterface.OnClickListener(){

            public void onClick(DialogInterface dialogInterface, int n) {
                MainActivity.this.startActivity(new Intent("android.settings.WIFI_SETTINGS"));
            }
        });
        builder.setNegativeButton((CharSequence)"\u53d6\u6d88", new DialogInterface.OnClickListener(){

            public void onClick(DialogInterface dialogInterface, int n) {
                dialogInterface.cancel();
                MainActivity.this.finish();
            }
        });
        builder.create();
        builder.show();
    }

    private boolean wifiConnectState() {
        NetworkInfo networkInfo = ((ConnectivityManager)this.getSystemService("connectivity")).getNetworkInfo(1);
        if (networkInfo != null && networkInfo.isConnected() && networkInfo.getState() == NetworkInfo.State.CONNECTED) {
            System.out.println(networkInfo.toString());
            return true;
        }
        return false;
    }

    public boolean CheckNetworkState() {
        NetworkInfo.State state = ((ConnectivityManager)this.getSystemService("connectivity")).getNetworkInfo(1).getState();
        if (state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.CONNECTING) {
            return true;
        }
        return false;
    }

    protected void downLoadApk() {
        final ProgressDialog progressDialog = new ProgressDialog((Context)this);
        progressDialog.setProgressStyle(1);
        progressDialog.setMessage((CharSequence)"\u6b63\u5728\u4e0b\u8f7d\u66f4\u65b0");
        progressDialog.show();
        new Thread(){

            public void run() {
                try {
                    System.out.println("\u4e0b\u8f7dapkurl===============" + MainActivity.this.info.getUrl());
                    MainActivity.this.logger.debug("\u4e0b\u8f7dapkurl===============" + MainActivity.this.info.getUrl());
                    File file = MainActivity.getFileFromServer(MainActivity.this.info.getUrl(), progressDialog);
                    .sleep((long)3000);
                    MainActivity.this.installApk(file);
                    progressDialog.dismiss();
                    return;
                }
                catch (Exception var1_2) {
                    MainActivity.this.logger.error("\u4e0b\u8f7dapk\u51fa\u73b0\u5f02\u5e38===============" + var1_2.getMessage());
                    Message message = new Message();
                    message.what = 2;
                    MainActivity.this.handlerUpdate.sendMessage(message);
                    var1_2.printStackTrace();
                    progressDialog.cancel();
                    return;
                }
            }
        }.start();
    }

    protected void installApk(File file) {
        Intent intent = new Intent();
        intent.addFlags(268435456);
        intent.setAction("android.intent.action.VIEW");
        intent.setDataAndType(Uri.fromFile((File)file), "application/vnd.android.package-archive");
        this.startActivity(intent);
    }

    /*
     * Exception decompiling
     */
    @Override
    protected void onCreate(Bundle var1) {
        // 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");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        this.unregisterReceiver(this.receiver);
    }

    public boolean onKeyDown(int n, KeyEvent keyEvent) {
        if (n == 4) {
            this.finish();
        }
        return false;
    }

    protected void showUpdataDialog(boolean bl) {
        AlertDialog.Builder builder = new AlertDialog.Builder((Context)this);
        builder.setTitle((CharSequence)"\u7248\u672c\u5347\u7ea7");
        try {
            builder.setMessage((CharSequence)new String(this.info.getDescription().getBytes(), "UTF-8"));
        }
        catch (UnsupportedEncodingException var4_4) {
            this.logger.error("\u5347\u7ea7\u4fe1\u606f\u8f6c\u6362\u7f16\u7801\u5f02\u5e38" + var4_4.getMessage());
            return;
        }
        builder.setPositiveButton((CharSequence)"\u786e\u5b9a", new DialogInterface.OnClickListener(){

            public void onClick(DialogInterface dialogInterface, int n) {
                MainActivity.this.logger.debug("\u4e0b\u8f7dapk,\u66f4\u65b0");
                MainActivity.this.downLoadApk();
            }
        });
        this.logger.error("button  \u663e\u793a======" + bl);
        if (!bl) {
            this.logger.error("button  \u53d6\u6d88 \u663e\u793a======" + bl);
            builder.setNegativeButton((CharSequence)"\u53d6\u6d88", new DialogInterface.OnClickListener(){

                public void onClick(DialogInterface dialogInterface, int n) {
                    Process.killProcess((int)Process.myPid());
                }
            });
        }
        AlertDialog alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(false);
        alertDialog.show();
    }

    /*
     * Enabled aggressive block sorting
     */
    public String trim(String string2) {
        int n;
        int n2 = string2.length();
        char[] arrc = string2.toCharArray();
        for (n = 0; n < n2 && arrc[0 + n] <= '\"'; ++n) {
        }
        do {
            if (n >= n2 || arrc[-1 + (0 + n2)] > '\"') {
                if (n > 0) return string2.substring(n, n2);
                if (n2 >= string2.length()) return string2;
                return string2.substring(n, n2);
            }
            --n2;
        } while (true);
    }

    public class CheckVersionTask
    implements Runnable {
        boolean force;

        public CheckVersionTask(boolean bl) {
            this.force = false;
            this.force = bl;
        }

        /*
         * Enabled aggressive block sorting
         * Enabled unnecessary exception pruning
         * Enabled aggressive exception aggregation
         */
        public void run() {
            try {
                URL uRL = new URL(String.valueOf((Object)Config.realUrl) + "/apps/version.xml");
                System.out.println("\u5347\u7ea7url=========" + uRL.toString());
                HttpURLConnection httpURLConnection = (HttpURLConnection)uRL.openConnection();
                httpURLConnection.setConnectTimeout(5000);
                InputStream inputStream = httpURLConnection.getInputStream();
                MainActivity.access$23(MainActivity.this, MainActivity.getUpdataInfo(inputStream));
                String string2 = MainActivity.this.getVersionName();
                if (MainActivity.this.info.getVersion().equals((Object)string2)) {
                    MainActivity.this.logger.debug("\u7248\u672c\u53f7\u76f8\u540c\u65e0\u9700\u5347\u7ea7");
                    return;
                }
                MainActivity.this.logger.debug("\u7248\u672c\u53f7\u4e0d\u540c ,\u63d0\u793a\u7528\u6237\u5347\u7ea7 ");
                Message message = new Message();
                MainActivity.this.logger.error("force=========" + this.force);
                message.what = this.force ? 4 : 0;
                MainActivity.this.handlerUpdate.sendMessage(message);
                return;
            }
            catch (Exception var2_6) {
                Message message = new Message();
                message.what = 1;
                MainActivity.this.handlerUpdate.sendMessage(message);
                var2_6.printStackTrace();
                return;
            }
        }
    }

    class LoginThread
    implements Runnable {
        LoginThread() {
        }

        /*
         * Exception decompiling
         */
        public void run() {
            // 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.analyseInnerClassesPass1(ClassFile.java:664)
            // org.benf.cfr.reader.entities.ClassFile.analyseMid(ClassFile.java:747)
            // 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");
        }
    }

    class MyAdapter
    extends SimpleAdapter {
        private List<HashMap<String, Object>> data;

        public MyAdapter(Context context, List<HashMap<String, Object>> list, int n, String[] arrstring, int[] arrn) {
            super(context, list, n, arrstring, arrn);
            this.data = list;
        }

        public int getCount() {
            return this.data.size();
        }

        public Object getItem(int n) {
            return n;
        }

        public long getItemId(int n) {
            return n;
        }

        /*
         * Enabled aggressive block sorting
         */
        public View getView(final int n, View view, ViewGroup viewGroup) {
            ViewHolder viewHolder;
            if (view == null) {
                viewHolder = new ViewHolder();
                view = LayoutInflater.from((Context)MainActivity.this).inflate(2130903043, null);
                ViewHolder.access$0(viewHolder, (TextView)view.findViewById(2131296269));
                view.setTag((Object)viewHolder);
            } else {
                viewHolder = (ViewHolder)view.getTag();
            }
            viewHolder.tv.setText((CharSequence)((HashMap)this.data.get(n)).get((Object)"name").toString());
            viewHolder.tv.setOnClickListener(new View.OnClickListener(){

                public void onClick(View view) {
                    Log.w((String)"\u70b9\u51fb\u4e0b\u62c9\u6846", (String)("\u70b9\u51fb\u4e0b\u62c9\u6846" + n));
                    String[] arrstring = (String[])MyAdapter.this.MainActivity.this.sp.getAll().keySet().toArray((Object[])new String[0]);
                    MyAdapter.access$0((MyAdapter)MyAdapter.this).username.setText((CharSequence)arrstring[n]);
                    MainActivity.access$30(MyAdapter.this.MainActivity.this, MyAdapter.access$0((MyAdapter)MyAdapter.this).username.getText().toString());
                    MyAdapter.access$0((MyAdapter)MyAdapter.this).password = MyAdapter.this.MainActivity.this.sp.getString(MyAdapter.this.MainActivity.this.usernametext, "");
                    Log.w((String)"username=", (String)MyAdapter.this.MainActivity.this.usernametext);
                    MyAdapter.this.MainActivity.this.popView.dismiss();
                }
            });
            return view;
        }

    }

    class SpinnerXMLSelectedListener
    implements AdapterView.OnItemSelectedListener {
        SpinnerXMLSelectedListener() {
        }

        public void onItemSelected(AdapterView<?> adapterView, View view, int n, long l) {
            MainActivity.access$30(MainActivity.this, (String)MainActivity.this._Adapter.getItem(n));
            MainActivity.this.password = MainActivity.this.sp.getString(MainActivity.this.usernametext, "");
            Log.v((String)"\u9009\u62e9\u5e10\u53f7\u662f\uff1a", (String)((String)MainActivity.this._Adapter.getItem(n)));
        }

        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    }

    class ViewHolder {
        private TextView tv;

        ViewHolder() {
        }

        static /* synthetic */ void access$0(ViewHolder viewHolder, TextView textView) {
            viewHolder.tv = textView;
        }
    }

}

