360手机助手 v5.2.50版本的 MD5 值为:087c008db9e518cd556c792742e6830c

以下内容为反编译后的 b.java 源代码,内容仅作参考


package com.qihoo360.mobilesafe.d;

import android.net.Proxy;
import android.net.http.AndroidHttpClient;
import android.os.Build;
import android.text.TextUtils;
import cn.com.iresearch.mapptracker.base64.org.apache.commons.codec.CharEncoding;
import com.qihoo.appstore.install.InstallNotificationManager;
import com.qihoo.appstore.utils.ApplicationConfig;
import com.qihoo.utils.ad;
import com.qihoo.utils.al;
import com.qihoo.utils.br;
import com.qihoo360.mobilesafe.util.ah;
import com.qihoo360.mobilesafe.util.l;
import com.tencent.open.SocialConstants;
import com.tencent.tauth.AuthActivity;
import fi.iki.elonen.NanoHTTPD;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import javax.net.ssl.SSLException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.conn.HttpHostConnectException;
import org.apache.http.conn.params.ConnRouteParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.json.JSONException;
import org.json.JSONObject;

public class b extends NanoHTTPD {
    private static final Object b = 1;
    private static String c = "SimpleWebServer";
    private static String e = "mobilemgr_wififind";
    private static String f = "mobilemgr_WiFiFind";
    private final c d;
    private Queue g;
    private Queue h;

    @Override
    public void a() throws IOException {
        this.g = new ConcurrentLinkedQueue();
        this.h = new ConcurrentLinkedQueue();
        super.a();
    }

    @Override
    public void b() {
        this.g.clear();
        this.h.clear();
        super.b();
    }

    private byte[] c(String str) {
        if (str == null) {
            return null;
        }
        try {
            return ah.a(f, str.getBytes());
        } catch (Exception e2) {
            return null;
        }
    }

    private String d(String str) {
        if (str == null) {
            return null;
        }
        try {
            return ah.b(f, str);
        } catch (Exception e2) {
            return null;
        }
    }

    private boolean a(String str, String str2, String str3, String str4) {
        if (str == null || str2 == null || str3 == null || str4 == null || this.h.contains(str3)) {
            return false;
        }
        String a = ah.a(str + str2 + str3 + e);
        com.qihoo360.mobilesafe.util.f.b(c, "md5 is " + a, new Object[0]);
        com.qihoo360.mobilesafe.util.f.b(c, "sign is " + str4, new Object[0]);
        if (!a.equals(str4)) {
            return false;
        }
        this.h.add(str3);
        return true;
    }

    public b(int i, c cVar) {
        super(null, i);
        this.d = cVar;
        try {
            a();
        } catch (IOException e2) {
        }
    }

    private NanoHTTPD.Response a(Map map) {
        String d = d((String) map.get("mId"));
        if (d == null) {
            return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
        }
        byte[] c2 = c(((("{ \"model\": \"" + Build.MODEL + "\"") + ", \"Remembered\": \"" + (this.d.b(d) ? "1" : "0") + "\"") + ", \"SelectedAgree\": \"" + (this.d.g() ? "1" : "0") + "\"") + " }");
        return a(NanoHTTPD.Response.Status.OK, "text/plain", c2 == null ? null : new ByteArrayInputStream(c2), c2 == null ? 0L : c2.length);
    }

    private NanoHTTPD.Response a(String str, Map map) {
        String d = d((String) map.get("mId"));
        String d2 = d((String) map.get("mName"));
        if (!a(d, d2, d((String) map.get("r")), d((String) map.get("sign")))) {
            return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
        }
        if (this.d.a(d2)) {
            if (str != null && !this.g.contains(str)) {
                this.g.add(str);
            }
            String str2 = "{ \"DeviceId\": \"" + this.d.a() + "\"";
            String b2 = this.d.b();
            if (!b2.equals("")) {
                str2 = str2 + ", \"Toid\": \"" + b2 + "\"";
            }
            byte[] c2 = c(((((str2 + ", \"model\": \"" + Build.MODEL + "\"") + ", \"SDK\": \"" + Build.VERSION.SDK_INT + "\"") + ", \"VersionCode\": \"" + this.d.f() + "\"") + ", \"Remembered\": \"" + (this.d.b(d) ? "1" : "0") + "\"") + " }");
            return a(NanoHTTPD.Response.Status.OK, "text/plain", c2 == null ? null : new ByteArrayInputStream(c2), c2 == null ? 0L : c2.length);
        }
        return a(NanoHTTPD.Response.Status.UNAUTHORIZED, "text/plain", "Forbidden");
    }

    private NanoHTTPD.Response b(String str, Map map) {
        if (str != null && this.g.contains(str)) {
            String d = d((String) map.get("deviceId"));
            String d2 = d((String) map.get("toId"));
            String d3 = d((String) map.get("mId"));
            String d4 = d((String) map.get("pcVer"));
            if (d != null && d2 != null && d3 != null && d4 != null) {
                String a = this.d.a(d, d2, d3, Integer.valueOf(d4).intValue());
                byte[] c2 = c("{ \"SetId\": \"" + (a == null ? "Success." : "Failed: " + a) + "\" }");
                return a(NanoHTTPD.Response.Status.OK, "text/plain", c2 == null ? null : new ByteArrayInputStream(c2), c2 == null ? 0L : c2.length);
            }
            return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
        }
        return a(NanoHTTPD.Response.Status.UNAUTHORIZED, "text/plain", "Forbidden");
    }

    private NanoHTTPD.Response b(Map map) {
        int i;
        boolean z;
        int i2 = 2;
        boolean z2 = false;
        String d = d((String) map.get("pcName"));
        String d2 = d((String) map.get("imId"));
        String d3 = d((String) map.get("mid"));
        String d4 = d((String) map.get("fileName"));
        try {
            i = Integer.parseInt(d((String) map.get(SocialConstants.PARAM_TYPE)));
        } catch (NumberFormatException e2) {
            i = 0;
        }
        try {
            z = Integer.parseInt(d((String) map.get("isAccess"))) == 1;
        } catch (NumberFormatException e3) {
            z = false;
        }
        String str = "handleWifiDiscoveryConfirmRequest.pcName = " + d + ", imId = " + d2 + ", mid = " + d3 + ", type = " + i + ", isAccess = " + z;
        l.a(c, str);
        if (com.qihoo.appstore.h.a.a) {
            com.qihoo360.mobilesafe.util.f.a(c, str, new Object[0]);
        }
        ApplicationConfig.getInstance().setType(i);
        if (this.d.c() == null) {
        }
        if (!TextUtils.isEmpty(d2) && d2.compareToIgnoreCase(al.n(ad.a())) == 0) {
            z2 = true;
        }
        List e4 = this.d.e(null);
        boolean contains = e4.contains(d3);
        if (!TextUtils.isEmpty(d) && z2) {
            if (!contains) {
                int a = this.d.a(z ? 2 : 1, d3, d, 2, d4);
                if (a == 5) {
                    if (!z) {
                        e4.add(d3);
                        this.d.a(e4);
                        i2 = a;
                    }
                } else if (a == 2 && z) {
                    this.d.j();
                }
                i2 = a;
            }
            JSONObject jSONObject = new JSONObject();
            if (i2 == 1) {
                try {
                    jSONObject.put("c_code", com.qihoo360.mobilesafe.pcdaemon.c.c.i().m());
                    if (!z) {
                        this.d.a(3, d3, d, 2);
                    }
                } catch (JSONException e5) {
                    if (com.qihoo.appstore.h.a.a) {
                        e5.printStackTrace();
                    }
                }
            }
            jSONObject.put("confirm", i2);
            byte[] c2 = c(jSONObject.toString());
            return a(NanoHTTPD.Response.Status.OK, "text/plain", c2 == null ? null : new ByteArrayInputStream(c2), c2 == null ? 0L : c2.length);
        }
        return a(NanoHTTPD.Response.Status.UNAUTHORIZED, "text/plain", "Forbidden");
    }

    private NanoHTTPD.Response c(Map map) {
        String d = d((String) map.get("pcName"));
        String d2 = d((String) map.get("imId"));
        String d3 = d((String) map.get("mid"));
        String d4 = d((String) map.get("fileName"));
        if (!TextUtils.isEmpty(d4)) {
            try {
                d4 = URLDecoder.decode(d4, "UTF-8");
            } catch (UnsupportedEncodingException e2) {
                if (com.qihoo.appstore.h.a.a) {
                    e2.printStackTrace();
                }
            }
        }
        String d5 = d((String) map.get(SocialConstants.PARAM_URL));
        String d6 = d((String) map.get("icon_url"));
        String d7 = d((String) map.get("ref"));
        boolean equals = "1".equals(d((String) map.get("isAutoOpen")));
        String str = "handleDownloadConfirmRequest.pcName = " + d + ", imId = " + d2 + ", mid = " + d3 + ", fileName = " + d4 + ", url = " + d5 + ", iconUrl = " + d6 + ", isAutoOpen = " + equals;
        l.a(c, str);
        if (com.qihoo.appstore.h.a.a) {
            com.qihoo360.mobilesafe.util.f.a(c, str, new Object[0]);
        }
        String c2 = this.d.c();
        if (c2 == null) {
            c2 = "";
        }
        boolean z = !TextUtils.isEmpty(d2) && d2.equals(br.a(c2));
        List e3 = this.d.e(null);
        boolean contains = e3.contains(d3);
        if (!TextUtils.isEmpty(d) && z) {
            int i = 2;
            if (!contains) {
                i = this.d.a(7, d3, d, 0, d4);
                switch (i) {
                    case 1:
                        this.d.a(d5, d6, d4, d7, null, "pc.downloadConfirm", equals);
                        break;
                    case 5:
                        e3.add(d3);
                        this.d.a(e3);
                        break;
                }
            }
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("confirm", i);
            } catch (JSONException e4) {
                if (com.qihoo.appstore.h.a.a) {
                    e4.printStackTrace();
                }
            }
            byte[] c3 = c(jSONObject.toString());
            return a(NanoHTTPD.Response.Status.OK, "text/plain", c3 != null ? new ByteArrayInputStream(c3) : null, c3 == null ? 0L : c3.length);
        }
        return a(NanoHTTPD.Response.Status.UNAUTHORIZED, "text/plain", "Forbidden");
    }

    private NanoHTTPD.Response d(Map map) {
        String d = d((String) map.get("imId"));
        String str = "handlewifiDiscoveryCancel.imId = " + d;
        l.a(c, str);
        if (com.qihoo.appstore.h.a.a) {
            com.qihoo360.mobilesafe.util.f.a(c, str, new Object[0]);
        }
        String c2 = this.d.c();
        if (c2 == null) {
            c2 = "";
        }
        if (!TextUtils.isEmpty(d) && d.equals(br.a(c2))) {
            this.d.a(6, (String) null, (String) null, 2);
            return a(NanoHTTPD.Response.Status.OK, "text/plain", null);
        }
        return a(NanoHTTPD.Response.Status.UNAUTHORIZED, "text/plain", "Forbidden");
    }

    private NanoHTTPD.Response j() {
        try {
            return a(NanoHTTPD.Response.Status.OK, "image/png", this.d.h(), r0.available());
        } catch (IOException e2) {
            e2.printStackTrace();
            return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "image/png", "image read failed");
        }
    }

    private boolean a(String str, String str2) {
        if (str == null || str2 == null) {
            return false;
        }
        String a = ah.a(str + e);
        if (com.qihoo.appstore.h.a.a) {
            com.qihoo360.mobilesafe.util.f.a(c, "md5 = " + a + ", sign = " + str2, new Object[0]);
        }
        return a.equalsIgnoreCase(str2);
    }

    private NanoHTTPD.Response e(Map map) {
        String str = (String) map.get(SocialConstants.PARAM_URL);
        String str2 = (String) map.get("sign");
        String str3 = (String) map.get("logo");
        String str4 = (String) map.get("name");
        String str5 = (String) map.get("ref");
        String str6 = (String) map.get("log");
        if (!a(str, str2)) {
            return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
        }
        this.d.a(str, str3, str4, str5, str6, "qrcode", false);
        return b("OK");
    }

    private NanoHTTPD.Response f(Map map) {
        String str = (String) map.get("apkId");
        if (!a(str, (String) map.get("sign"))) {
            return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
        }
        this.d.c(str);
        return b("OK");
    }

    private NanoHTTPD.Response g(Map map) {
        String str = (String) map.get(AuthActivity.ACTION_KEY);
        String str2 = (String) map.get("sign");
        if ("web".equals(str)) {
            String str3 = (String) map.get("title");
            String str4 = (String) map.get(SocialConstants.PARAM_URL);
            if (!a(str4, str2)) {
                return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
            }
            this.d.d(str3, str4);
        } else if ("giftlist".equals(str)) {
            String str5 = (String) map.get("softid");
            String str6 = (String) map.get("apkid");
            if (!a(str5 + str6, str2)) {
                return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
            }
            this.d.e(str5, str6);
        } else if ("detail".equals(str)) {
            String str7 = (String) map.get("giftid");
            if (!a(str7, str2)) {
                return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
            }
            this.d.l(str7);
        } else if ("index".equalsIgnoreCase(str)) {
            this.d.k();
        }
        return a(NanoHTTPD.Response.Status.OK, "text/plain", (String) null);
    }

    private NanoHTTPD.Response h(Map map) {
        String str = (String) map.get(AuthActivity.ACTION_KEY);
        String str2 = (String) map.get("sign");
        if ("web".equals(str)) {
            String str3 = (String) map.get("title");
            String str4 = (String) map.get(SocialConstants.PARAM_URL);
            if (!a(str4, str2)) {
                return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
            }
            this.d.a(str3, str4);
        } else if ("detail".equals(str)) {
            String str5 = (String) map.get("softid");
            String str6 = (String) map.get("apkid");
            if (!a(str5 + str6, str2)) {
                return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
            }
            this.d.b(str5, str6);
        } else if ("gift".equals(str)) {
            String str7 = (String) map.get("giftid");
            if (!a(str7, str2)) {
                return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
            }
            this.d.j(str7);
        } else if ("writeAndInstall".equalsIgnoreCase(str)) {
            String str8 = (String) map.get("channel");
            String str9 = (String) map.get("apkid");
            if (!a(str8 + str9, str2)) {
                return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
            }
            this.d.c(str8, str9);
        } else if ("download".equals(str)) {
            String str10 = (String) map.get("apkid");
            String str11 = (String) map.get("logo_url");
            String str12 = (String) map.get("name");
            String str13 = (String) map.get(SocialConstants.PARAM_URL);
            if (!a(str13, str2)) {
                return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
            }
            try {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("apkid", str10);
                jSONObject.put("logo_url", str11);
                jSONObject.put("name", str12);
                jSONObject.put("down_url", str13);
                this.d.k(jSONObject.toString());
            } catch (JSONException e2) {
                e2.printStackTrace();
            }
        }
        return a(NanoHTTPD.Response.Status.OK, "text/plain", null);
    }

    private NanoHTTPD.Response i(Map map) {
        String decode;
        String str = (String) map.get(SocialConstants.PARAM_URL);
        if (str != null) {
            try {
                decode = URLDecoder.decode(str, "UTF-8");
            } catch (UnsupportedEncodingException e2) {
                e2.printStackTrace();
            }
            String str2 = (String) map.get("callback");
            if (com.qihoo.productdatainfo.b.c.E(decode)) {
                return a(NanoHTTPD.Response.Status.UNAUTHORIZED, "text/plain", "Forbidden");
            }
            boolean a = this.d.a(decode, (String) map.get("page"), "1".equals((String) map.get("needCookie")));
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("isSuccssed", a);
            } catch (JSONException e3) {
                e3.printStackTrace();
            }
            if (str2 == null) {
                str2 = "";
            }
            if (com.qihoo.appstore.h.a.a) {
                com.qihoo360.mobilesafe.util.f.a(c, "OpenPage callback=" + str2 + "(" + jSONObject.toString() + ")", new Object[0]);
            }
            return a(NanoHTTPD.Response.Status.OK, "text/plain", str2 + "(" + jSONObject.toString() + ")");
        }
        decode = str;
        String str22 = (String) map.get("callback");
        if (com.qihoo.productdatainfo.b.c.E(decode)) {
        }
    }

    private NanoHTTPD.Response j(Map map) {
        String d = d((String) map.get(SocialConstants.PARAM_URL));
        if (d != null) {
            try {
                d = URLDecoder.decode(d, "UTF-8");
            } catch (UnsupportedEncodingException e2) {
                e2.printStackTrace();
            }
        }
        if (!com.qihoo.productdatainfo.b.c.E(d)) {
            return a(NanoHTTPD.Response.Status.UNAUTHORIZED, "text/plain", "Forbidden");
        }
        boolean d2 = this.d.d(d);
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("isSuccssed", d2);
        } catch (JSONException e3) {
            e3.printStackTrace();
        }
        if (com.qihoo.appstore.h.a.a) {
            com.qihoo360.mobilesafe.util.f.a(c, "OpenBrowser url=" + d + "(" + jSONObject.toString() + ")", new Object[0]);
        }
        byte[] c2 = c(jSONObject.toString());
        return a(NanoHTTPD.Response.Status.OK, "text/plain", c2 == null ? null : new ByteArrayInputStream(c2), c2 == null ? 0L : c2.length);
    }

    private NanoHTTPD.Response k(Map map) {
        String str = (String) map.get(InstallNotificationManager.KEY_FROM);
        String str2 = (String) map.get("startIndex");
        String str3 = (String) map.get("sign");
        String str4 = (String) map.get("callback");
        String str5 = (String) map.get("jsonExtra");
        if (a(str2, str3)) {
            int parseInt = com.qihoo.express.mini.d.c.a(str2) ? Integer.parseInt(str2) : -1;
            boolean a = parseInt != -1 ? this.d.a(parseInt, str, str5) : false;
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("isSuccssed", a);
            } catch (JSONException e2) {
                if (com.qihoo.appstore.h.a.a) {
                    e2.printStackTrace();
                }
            }
            if (str4 == null) {
                str4 = "";
            }
            if (com.qihoo.appstore.h.a.a) {
                com.qihoo360.mobilesafe.util.f.a(c, "handleOpenActivityRequest callback=" + str4 + "(" + jSONObject.toString() + ")", new Object[0]);
            }
            return a(NanoHTTPD.Response.Status.OK, "text/plain", str4 + "(" + jSONObject.toString() + ")");
        }
        return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
    }

    private NanoHTTPD.Response l(Map map) {
        String str = (String) map.get("packageName");
        String str2 = (String) map.get("sign");
        String str3 = (String) map.get("callback");
        if (a(str, str2)) {
            boolean g = this.d.g(str);
            JSONObject jSONObject = new JSONObject();
            try {
                jSONObject.put("isInstalled", g);
                if (g) {
                    jSONObject.put("versionName", this.d.h(str));
                    jSONObject.put("versionCode", this.d.i(str));
                } else {
                    jSONObject.put("apkpath", this.d.m(str));
                }
            } catch (JSONException e2) {
                if (com.qihoo.appstore.h.a.a) {
                    e2.printStackTrace();
                }
            }
            if (str3 == null) {
                str3 = "";
            }
            if (com.qihoo.appstore.h.a.a) {
                com.qihoo360.mobilesafe.util.f.a(c, "handleOpenActivityRequest callback=" + str3 + "(" + jSONObject.toString() + ")", new Object[0]);
            }
            return a(NanoHTTPD.Response.Status.OK, "text/plain", str3 + "(" + jSONObject.toString() + ")");
        }
        return a(NanoHTTPD.Response.Status.INTERNAL_ERROR, "text/plain", "Bad Request");
    }

    private NanoHTTPD.Response m(Map map) {
        String str = (String) map.get("callback");
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("verCode", this.d.f());
            jSONObject.put("server_version", b);
            jSONObject.put("m2", this.d.d());
            jSONObject.put("channel", this.d.e());
            jSONObject.put("OS_version", Build.VERSION.SDK_INT);
            jSONObject.put("shake", true);
        } catch (JSONException e2) {
            e2.printStackTrace();
        }
        if (TextUtils.isEmpty(str)) {
            return a(NanoHTTPD.Response.Status.OK, "text/plain", jSONObject.toString());
        }
        return a(NanoHTTPD.Response.Status.OK, "text/plain", str + "(" + jSONObject.toString() + ")");
    }

    private String a(String str, NanoHTTPD.Response.Status status) {
        String str2 = "" + status.getRequestStatus();
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("verCode", str2);
        } catch (JSONException e2) {
            e2.printStackTrace();
        }
        return str + "(" + jSONObject.toString() + ")";
    }

    private NanoHTTPD.Response n(Map map) {
        if (map == null || map.size() == 0) {
            return a(NanoHTTPD.Response.Status.BAD_REQUEST, "text/plain", "" + NanoHTTPD.Response.Status.BAD_REQUEST.getRequestStatus());
        }
        HashMap hashMap = new HashMap();
        hashMap.put("by", map.get("by"));
        hashMap.put("token", map.get("token"));
        hashMap.put(SocialConstants.PARAM_TYPE, map.get(SocialConstants.PARAM_TYPE));
        hashMap.put("pc", map.get("pc"));
        hashMap.put("pcver", map.get("pcver"));
        hashMap.put("stype", map.get("stype"));
        StringBuilder sb = new StringBuilder("?");
        for (Map.Entry entry : hashMap.entrySet()) {
            sb.append((String) entry.getKey()).append("=").append((String) entry.getValue()).append("&");
        }
        if (sb.toString().endsWith("&") && sb.length() > 0) {
            sb.deleteCharAt(sb.length() - 1);
        }
        this.d.f(sb.toString());
        return a(NanoHTTPD.Response.Status.OK, "text/plain", a((String) map.get("callback"), NanoHTTPD.Response.Status.OK));
    }

    private static String e(String str) {
        StringBuilder sb = new StringBuilder();
        if (com.qihoo.productdatainfo.b.c.d()) {
            sb.append("http://test1.mobilem.360.cn/LinkCheck/check?url=");
        } else {
            sb.append("https://openbox.mobilem.360.cn/LinkCheck/check?url=");
        }
        try {
            sb.append(URLEncoder.encode(str, "UTF-8"));
        } catch (UnsupportedEncodingException e2) {
        }
        return sb.toString();
    }

    private String f(String str) throws IOException {
        AndroidHttpClient newInstance = AndroidHttpClient.newInstance(System.getProperty("http.agent"));
        HttpParams params = newInstance.getParams();
        HttpProtocolParams.setContentCharset(params, "UTF-8");
        HttpClientParams.setRedirecting(params, true);
        try {
            HttpGet httpGet = new HttpGet(str);
            httpGet.addHeader("Accept-Language", Locale.getDefault().toString());
            String defaultHost = Proxy.getDefaultHost();
            int defaultPort = Proxy.getDefaultPort();
            if (!TextUtils.isEmpty(defaultHost) && defaultPort > 0) {
                ConnRouteParams.setDefaultProxy(httpGet.getParams(), new HttpHost(defaultHost, defaultPort, "http"));
            }
            AndroidHttpClient.modifyRequestToAcceptGzipResponse(httpGet);
            HttpResponse execute = newInstance.execute(httpGet);
            int statusCode = execute.getStatusLine().getStatusCode();
            if (200 != statusCode) {
                throw new ClientProtocolException("The status code of http is not SC_OK(200):" + statusCode + ",\r\n\turl=" + str);
            }
            HttpEntity entity = execute.getEntity();
            if (entity == null) {
                throw new ClientProtocolException("No content be send");
            }
            return a.a(entity, CharEncoding.ISO_8859_1);
        } finally {
            newInstance.close();
        }
    }

    private boolean g(String str) {
        String e2;
        JSONObject jSONObject;
        boolean z;
        try {
            JSONObject jSONObject2 = new JSONObject(f(e(str)));
            if (jSONObject2.optInt("errno", -1) == 0) {
                JSONObject optJSONObject = jSONObject2.optJSONObject("data");
                String optString = optJSONObject.optString(SocialConstants.PARAM_URL);
                z = "1".equals(optJSONObject.optString("result", "0"));
            }
            z = false;
            return z;
        } catch (SSLException e3) {
            e = e3;
            try {
                e2 = e(str);
                if (e2.startsWith("https://")) {
                    e2 = e2.replaceFirst("https", "http");
                }
                jSONObject = new JSONObject(f(e2));
                if (jSONObject.optInt("errno", -1) == 0) {
                    return false;
                }
                JSONObject optJSONObject2 = jSONObject.optJSONObject("data");
                String optString2 = optJSONObject2.optString(SocialConstants.PARAM_URL);
                boolean equals = "1".equals(optJSONObject2.optString("result", "0"));
                if (str.equals(optString2)) {
                    return equals;
                }
                return false;
            } catch (Exception e4) {
                if (!com.qihoo.appstore.h.a.a) {
                    return false;
                }
                e.printStackTrace();
                return false;
            }
        } catch (HttpHostConnectException e5) {
            e = e5;
            e2 = e(str);
            if (e2.startsWith("https://")) {
            }
            jSONObject = new JSONObject(f(e2));
            if (jSONObject.optInt("errno", -1) == 0) {
            }
        } catch (Exception e6) {
            if (!com.qihoo.appstore.h.a.a) {
                return false;
            }
            e6.printStackTrace();
            return false;
        }
    }

    @Override
    public NanoHTTPD.Response a(String str, NanoHTTPD.Method method, Map map, Map map2, Map map3) {
        String str2 = (String) map.get("http-client-ip");
        if (!TextUtils.isEmpty(str) && TextUtils.isEmpty(str2) && str.contains(str2)) {
            com.qihoo.utils.c.a.a().a(new Exception("NanoHTTP get uri Error,contains ip!"));
        }
        if (com.qihoo.appstore.h.a.a) {
            com.qihoo360.mobilesafe.util.f.a(c, "serve.clientIP = " + str2 + ", uri = " + str + ", method = " + method + ", header = " + map + ", parms = " + map2 + ", files = " + map3 + ", WIFI_DISCOVERY_FEATURE = " + ApplicationConfig.getInstance().getBoolean(ApplicationConfig.WIFI_DISCOVERY_FEATURE, true) + ", isOpenWifiFind = " + ApplicationConfig.getInstance().isOpenWifiFind(true), new Object[0]);
        }
        if (!g("http://" + str2 + str + "?" + ((String) map2.get("NanoHttpd.QUERY_STRING")))) {
            com.qihoo360.mobilesafe.util.f.a(c, "Refuse Request:serve.clientIP = " + str2 + ", uri = " + str + ", method = " + method + ", header = " + map + ", parms = " + map2 + ", files = " + map3 + ", WIFI_DISCOVERY_FEATURE = " + ApplicationConfig.getInstance().getBoolean(ApplicationConfig.WIFI_DISCOVERY_FEATURE, true) + ", isOpenWifiFind = " + ApplicationConfig.getInstance().isOpenWifiFind(true), new Object[0]);
            return a(NanoHTTPD.Response.Status.FORBIDDEN, "text/plain", "Forbidden");
        }
        if (ApplicationConfig.getInstance().getBoolean(ApplicationConfig.WIFI_DISCOVERY_FEATURE, true) && ApplicationConfig.getInstance().isOpenWifiFind(true)) {
            char c2 = 65535;
            switch (str.hashCode()) {
                case -2142810206:
                    if (str.equals("/setId0")) {
                        c2 = 2;
                        break;
                    }
                    break;
                case -1174058743:
                    if (str.equals("/downloadConfirm")) {
                        c2 = 5;
                        break;
                    }
                    break;
                case -18984498:
                    if (str.equals("/getModel0")) {
                        c2 = 0;
                        break;
                    }
                    break;
                case 878651658:
                    if (str.equals("/wifiDiscoveryCancel0")) {
                        c2 = 4;
                        break;
                    }
                    break;
                case 1011444700:
                    if (str.equals("/wifiDiscoveryConfirm0")) {
                        c2 = 3;
                        break;
                    }
                    break;
                case 1726034415:
                    if (str.equals("/openBrowser")) {
                        c2 = 6;
                        break;
                    }
                    break;
                case 1808607278:
                    if (str.equals("/getId0")) {
                        c2 = 1;
                        break;
                    }
                    break;
            }
            switch (c2) {
                case 0:
                    return a(map2);
                case 1:
                    return a(str2, map2);
                case 2:
                    return b(str2, map2);
                case 3:
                    return b(map2);
                case 4:
                    return d(map2);
                case 5:
                    return c(map2);
                case 6:
                    return j(map2);
            }
        }
        if (!"127.0.0.1".equals(str2)) {
            return a(NanoHTTPD.Response.Status.FORBIDDEN, "text/plain", "Forbidden");
        }
        if (str.equals("/logo.png")) {
            return j();
        }
        if (str.equals("/getClientInfo")) {
            return m(map2);
        }
        if (str.equals("/in")) {
            return e(map2);
        }
        if (str.equalsIgnoreCase("/opeanApp")) {
            return f(map2);
        }
        if (str.equalsIgnoreCase("/gameunion")) {
            return h(map2);
        }
        if (str.equalsIgnoreCase("/gameuniondesk")) {
            return g(map2);
        }
        if (str.equals("/openPage")) {
            if (this.d.i()) {
                return a(NanoHTTPD.Response.Status.FORBIDDEN, "text/plain", "isAppOnForeground");
            }
            return i(map2);
        }
        if (str.equals("/index/doWirelessLink")) {
            if (this.d.i()) {
                return a(NanoHTTPD.Response.Status.FORBIDDEN, "text/plain", "isAppOnForeground");
            }
            return n(map2);
        }
        if (str.equals("/openActivity")) {
            if (this.d.i()) {
                return a(NanoHTTPD.Response.Status.FORBIDDEN, "text/plain", "isAppOnForeground");
            }
            return k(map2);
        }
        if (str.equals("/isAppInstalled")) {
            return l(map2);
        }
        if (str.equals("/openBrowser")) {
            return j(map2);
        }
        return a(NanoHTTPD.Response.Status.NOT_FOUND, "text/plain", "Not Found: " + str);
    }
}