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

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


package com.qihoo.appstore.LifeHelper;

import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Handler;
import android.os.Looper;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.widget.Toast;
import com.android.volley.toolbox.JsonArrayRequest;
import com.android.volley.toolbox.JsonObjectRequest;
import com.android.volley.toolbox.StringRequest;
import com.android.volleypro.toolbox.VolleyHttpClient;
import com.qihoo.appstore.liteplugin.invokes.location.QHLocationProxy;
import com.qihoo.appstore.rootcommand.xiaomipop.XiaomiMemoryLock;
import com.qihoo.utils.bn;
import com.qihoo.utils.cn;
import com.qihoo.utils.dk;
import com.qihoo.utils.dl;
import com.tencent.connect.common.Constants;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class h {
    private static h a;
    private bb b;
    private bc c;
    private String d;

    public static h a() {
        if (a == null) {
            synchronized (h.class) {
                a = new h();
            }
        }
        return a;
    }

    public void a(Context context, String str, String str2, ba baVar) {
        com.qihoo.utils.thread.j.b(new an(this, new x(this, context, str, new i(this, context, str2, baVar)), baVar, context));
    }

    public Map a(Context context, String str, String str2) {
        HttpURLConnection httpURLConnection;
        HashMap hashMap = new HashMap();
        String format = String.format("https://openapi.360.cn/oauth2/authorize.json?client_id=%1$s&response_type=token&redirect_uri=oob&state=%2$s&scope=basic&version=Qhopensdk-1.1.6&mid=%3$s&DChannel=default&display=mobile.cli_v1&oauth2_login_type=%4$d", str, "ZhushouGetToken", com.qihoo.utils.al.j(context), 2);
        int i = 0;
        while (true) {
            if (i > 2) {
                break;
            }
            HttpURLConnection httpURLConnection2 = null;
            try {
                try {
                    httpURLConnection = (HttpURLConnection) new URL(format).openConnection();
                } catch (Exception e) {
                    e = e;
                }
            } catch (Throwable th) {
                th = th;
            }
            try {
                httpURLConnection.addRequestProperty("Cookie", str2);
                httpURLConnection.setRequestMethod(Constants.HTTP_GET);
                httpURLConnection.setInstanceFollowRedirects(false);
                if (302 == httpURLConnection.getResponseCode()) {
                    String headerField = httpURLConnection.getHeaderField("Location");
                    if (!TextUtils.isEmpty(headerField)) {
                        Matcher matcher = Pattern.compile("[?#]access_token=([0-9a-zA-Z]*)").matcher(headerField);
                        if (matcher.find()) {
                            hashMap.put(Constants.PARAM_ACCESS_TOKEN, matcher.group(1));
                        }
                        Matcher matcher2 = Pattern.compile("[?&]expires_in=([0-9]*)").matcher(headerField);
                        if (matcher2.find()) {
                            hashMap.put(Constants.PARAM_EXPIRES_IN, matcher2.group(1));
                        }
                    }
                } else {
                    hashMap.put("Exception", com.qihoo.utils.ay.a(httpURLConnection.getInputStream(), "UTF-8", true));
                }
                if (httpURLConnection != null) {
                    httpURLConnection.disconnect();
                }
            } catch (Exception e2) {
                httpURLConnection2 = httpURLConnection;
                e = e2;
                if (com.qihoo.appstore.h.a.a) {
                    e.printStackTrace();
                }
                hashMap.put("Exception", e.getMessage());
                if (httpURLConnection2 != null) {
                    httpURLConnection2.disconnect();
                }
                i++;
            } catch (Throwable th2) {
                httpURLConnection2 = httpURLConnection;
                th = th2;
                if (httpURLConnection2 != null) {
                    httpURLConnection2.disconnect();
                }
                throw th;
            }
            i++;
        }
        return hashMap;
    }

    public void a(Context context, String str, ba baVar) {
        com.qihoo.utils.thread.j.b(new aq(this, new ap(this, str, baVar)));
    }

    public JSONObject a(Exception exc) {
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("Exception", exc.getMessage());
        } catch (JSONException e) {
            if (com.qihoo.appstore.h.a.a) {
                e.printStackTrace();
            }
        }
        return jSONObject;
    }

    public boolean b() {
        boolean z;
        try {
            StringRequest stringRequest = new StringRequest(com.qihoo.productdatainfo.b.c.e(com.qihoo.productdatainfo.b.c.P()), null, null);
            stringRequest.setShouldCache(false);
            stringRequest.setTag(this);
            JSONObject jSONObject = (JSONObject) VolleyHttpClient.getInstance().getSyncJsonResponseData(stringRequest);
            if (jSONObject == null) {
                return false;
            }
            bn.b("LifeHelper", "getPhoneInfo-->" + jSONObject.toString());
            JSONObject optJSONObject = jSONObject.optJSONObject("data");
            if (optJSONObject != null) {
                if (optJSONObject.optBoolean("phone", false)) {
                    z = true;
                    return z;
                }
            }
            z = false;
            return z;
        } catch (Exception e) {
            if (!com.qihoo.appstore.h.a.a) {
                return false;
            }
            e.printStackTrace();
            return false;
        }
    }

    public void a(Context context, String str, String str2, String str3, ba baVar) {
        if (TextUtils.isEmpty(str2) || TextUtils.isEmpty(str3)) {
            if (baVar != null) {
                baVar.a(-1, "FAILED", new JSONObject());
            }
        } else {
            IntentFilter intentFilter = new IntentFilter(str2 + "com.qihoopay.result");
            bd bdVar = new bd(this, str, baVar);
            context.registerReceiver(bdVar, intentFilter);
            com.qihoo.utils.thread.j.b(new au(this, new as(this, context, str2, str3, baVar, bdVar), context, baVar));
        }
    }

    public void b(Context context, String str, String str2, ba baVar) {
        String[] strArr = new String[1];
        bn.b("LifeHelper", "pay json:" + str2);
        if (TextUtils.isEmpty(str2)) {
            if (baVar != null) {
                baVar.a(-1, "FAILED", new JSONObject());
            }
        } else {
            aw awVar = new aw(this, strArr, str2, baVar, context, str);
            new ay(this, strArr, awVar, baVar);
            com.qihoo.utils.thread.j.b(new k(this, awVar, context, baVar));
        }
    }

    public void a(ba baVar) {
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest("http://pre.profile.sj.360.cn/live/payment/gettoken", null, new m(this, baVar), new n(this));
        jsonObjectRequest.setTag(Integer.valueOf(hashCode()));
        VolleyHttpClient.getInstance().addToQueue(jsonObjectRequest);
    }

    public void b(Context context, String str, ba baVar) {
        com.qihoo.utils.thread.j.b(new q(this, new o(this, baVar, context), baVar, context));
    }

    public void c(Context context, String str, ba baVar) {
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(com.qihoo.productdatainfo.b.c.Q() + "?mobile=" + str, null, new s(this, baVar), new t(this));
        jsonObjectRequest.setTag(Integer.valueOf(hashCode()));
        VolleyHttpClient.getInstance().addToQueue(jsonObjectRequest);
    }

    public void c(Context context, String str, String str2, ba baVar) {
        JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(com.qihoo.productdatainfo.b.c.R() + "?mobile=" + str + "&vc=" + str2, null, new u(this, baVar), new v(this));
        jsonObjectRequest.setTag(Integer.valueOf(hashCode()));
        VolleyHttpClient.getInstance().addToQueue(jsonObjectRequest);
    }

    public void a(Context context, JSONObject jSONObject, ba baVar) {
        long j;
        if (bn.c()) {
            bn.b("LifeHelper", "getCurrentPosition.option = " + jSONObject);
        }
        Handler handler = new Handler(Looper.getMainLooper());
        AtomicBoolean atomicBoolean = new AtomicBoolean();
        w wVar = new w(this, atomicBoolean, baVar);
        boolean z = jSONObject != null && jSONObject.optBoolean("enableHighAccuracy", false);
        long optLong = jSONObject != null ? jSONObject.optLong("timeout", 15000L) : 15000L;
        if (jSONObject != null) {
            j = jSONObject.optLong("maximumAge", -1L) == 0 ? -1L : jSONObject.optLong("maximumAge", -1L);
        } else {
            j = -1;
        }
        handler.post(new aa(this, context, z, j, handler, atomicBoolean, wVar, baVar, jSONObject != null ? jSONObject.optBoolean("returnGCJ02", false) : false));
        handler.postDelayed(wVar, optLong);
    }

    public void a(QHLocationProxy qHLocationProxy, ba baVar, boolean z, boolean z2) {
        JSONObject jSONObject;
        boolean z3 = qHLocationProxy != null && qHLocationProxy.a() == QHLocationProxy.i;
        if (z3) {
            JSONObject jSONObject2 = new JSONObject();
            try {
                double latitude = qHLocationProxy.getLatitude();
                double longitude = qHLocationProxy.getLongitude();
                if (!z2) {
                    dl b = dk.b(latitude, longitude);
                    latitude = b.a();
                    longitude = b.b();
                }
                JSONObject jSONObject3 = new JSONObject();
                jSONObject3.put("latitude", latitude);
                jSONObject3.put("longitude", longitude);
                jSONObject3.put("accuracy", qHLocationProxy.getAccuracy());
                jSONObject3.put("altitude", qHLocationProxy.getAltitude());
                jSONObject3.put("altitudeAccuracy", 0.0d);
                jSONObject3.put("heading", 0.0d);
                jSONObject3.put("speed", qHLocationProxy.getSpeed());
                jSONObject2.put("coords", jSONObject3);
                jSONObject2.put("timestamp", qHLocationProxy.getTime());
                JSONObject jSONObject4 = new JSONObject();
                jSONObject4.put("province", qHLocationProxy.b());
                jSONObject4.put("city", qHLocationProxy.c());
                jSONObject4.put("district", qHLocationProxy.d());
                jSONObject4.put("street", qHLocationProxy.e());
                jSONObject4.put("adCode", qHLocationProxy.f());
                jSONObject2.put("address", jSONObject4);
                jSONObject2.put("addresses", qHLocationProxy.g());
                jSONObject = jSONObject2;
            } catch (JSONException e) {
                if (com.qihoo.appstore.h.a.a) {
                    bn.a("LifeHelper", "getCurrentPositionResult.JSONException", e);
                }
                jSONObject = jSONObject2;
            }
        } else {
            JSONObject jSONObject5 = new JSONObject();
            try {
                jSONObject5.put("PERMISSION_DENIED", 1);
                jSONObject5.put("POSITION_UNAVAILABLE", 2);
                jSONObject5.put("TIMEOUT", 3);
                jSONObject5.put("UNKNOWN_ERROR", 4);
                if (z) {
                    jSONObject5.put(XiaomiMemoryLock.KEY_CODE, 3);
                    jSONObject5.put("message", "TIMEOUT");
                } else if (qHLocationProxy.a() == QHLocationProxy.j) {
                    jSONObject5.put(XiaomiMemoryLock.KEY_CODE, 2);
                    jSONObject5.put("message", "POSITION_UNAVAILABLE");
                } else {
                    jSONObject5.put(XiaomiMemoryLock.KEY_CODE, 4);
                    jSONObject5.put("message", "UNKNOWN_ERROR");
                }
                jSONObject = jSONObject5;
            } catch (JSONException e2) {
                if (com.qihoo.appstore.h.a.a) {
                    e2.printStackTrace();
                }
                jSONObject = jSONObject5;
            }
        }
        if (baVar != null) {
            if (bn.c()) {
                bn.b("LifeHelper", "getCurrentPositionResult.isSuccess = " + z3 + "   " + jSONObject);
            }
            if (z3) {
                baVar.a(0, "OK", jSONObject);
            } else {
                baVar.a(-1, "FAILED", jSONObject);
            }
        }
    }

    public void d(Context context, String str, ba baVar) {
        bn.b("LifeHelper", "openPaymentMethods jsonStr-->" + str);
        com.qihoo.utils.thread.j.b(new ae(this, new ad(this, baVar, context, str), context, baVar));
    }

    public void e(Context context, String str, ba baVar) {
        try {
            String str2 = "com.paymemts.order.result";
            if (com.morgoo.droidplugin.d.l.e().a("com.qihoo.paymentmethod", 0).versionCode < 25) {
                this.d = "com.paymemts.orderinfo.result";
            } else {
                str2 = (Math.random() * 100.0d) + "com.paymemts.order.result";
            }
            if (this.d != null) {
                Intent intent = new Intent(this.d);
                intent.putExtra("action_pay_result", str2);
                if (!TextUtils.isEmpty(str)) {
                    JSONObject jSONObject = new JSONObject(str);
                    IntentFilter intentFilter = new IntentFilter(str2);
                    this.c = new bc(this, baVar);
                    context.registerReceiver(this.c, intentFilter);
                    intent.putExtra("payType", jSONObject.optString("payType", null));
                    intent.putExtra("orderInfo", jSONObject.optString("orderInfo", null));
                    intent.putExtra("result_code", 0);
                    intent.putExtra("result_msg", "OK");
                } else {
                    intent.putExtra("result_code", -1);
                    intent.putExtra("result_msg", "获取不到订单信息,请稍后再试!");
                }
                context.sendBroadcast(intent);
                return;
            }
            Toast.makeText(context, "orderinfoAction is null", 0).show();
        } catch (Exception e) {
            if (this.c != null) {
                context.unregisterReceiver(this.c);
                this.c = null;
            }
            e.printStackTrace();
        }
    }

    private String a(String str) {
        if (str == null || str.startsWith("javascript:")) {
            return null;
        }
        try {
            return new URL(str).getHost();
        } catch (MalformedURLException e) {
            e.printStackTrace();
            return null;
        }
    }

    public String a(String str, String str2) {
        try {
            JSONArray jSONArray = new JSONArray(str2);
            int i = 0;
            while (true) {
                int i2 = i;
                if (i2 >= jSONArray.length()) {
                    break;
                }
                JSONObject jSONObject = jSONArray.getJSONObject(i2);
                String optString = jSONObject.optString("rule", null);
                String optString2 = jSONObject.optString("js_content", null);
                if (!TextUtils.isEmpty(optString) && !TextUtils.isEmpty(optString2)) {
                    try {
                        if (Pattern.compile(optString).matcher(str).find()) {
                            return optString2;
                        }
                    } catch (Exception e) {
                        com.qihoo.utils.c.a.a().b(e, "getJS");
                    }
                }
                i = i2 + 1;
            }
        } catch (JSONException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    public void b(ba baVar) {
        String a2 = cn.a("LifeHelper", com.qihoo.utils.ad.a(), "key_remove_tips_domain", "");
        long currentTimeMillis = System.currentTimeMillis();
        long a3 = cn.a("LifeHelper", com.qihoo.utils.ad.a(), "key_remove_tips_domain_update_time", 0L);
        if (TextUtils.isEmpty(a2) || currentTimeMillis - a3 > 86400000) {
            JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(com.qihoo.productdatainfo.b.c.e(com.qihoo.productdatainfo.b.c.X()), new ag(this, currentTimeMillis, a2, baVar), new ah(this, baVar, a2));
            jsonArrayRequest.setTag(Integer.valueOf(hashCode()));
            VolleyHttpClient.getInstance().addToQueue(jsonArrayRequest);
        } else if (baVar != null) {
            baVar.a(TextUtils.isEmpty(a2) ? -1 : 0, a2, null);
        }
    }

    public void a(String str, ba baVar) {
        String a2 = a(str);
        if (!TextUtils.isEmpty(a2)) {
            b(new ai(this, a2, baVar, str));
        } else {
            baVar.a(-1, null, null);
        }
    }

    public void c(ba baVar) {
        String str;
        if (com.qihoo.utils.net.f.f()) {
            long currentTimeMillis = System.currentTimeMillis();
            if (currentTimeMillis - cn.a("LifeHelper", com.qihoo.utils.ad.a(), "key_remove_tips_rule_and_js_for_operator_time", 0L) > 86400000) {
                VolleyHttpClient.getInstance().addToQueue(new JsonArrayRequest(com.qihoo.productdatainfo.b.c.e(com.qihoo.productdatainfo.b.c.Y() + "?domain=operator&operator=" + ((TelephonyManager) com.qihoo.utils.ad.a().getSystemService("phone")).getSimOperator()), new al(this, currentTimeMillis, baVar), new am(this, baVar)).setTag(Integer.valueOf(hashCode())));
                return;
            }
            try {
                str = new JSONArray(cn.a("LifeHelper", com.qihoo.utils.ad.a(), "key_remove_tips_rule_and_js_for_operator", "")).getJSONObject(0).optString("js_content", null);
            } catch (JSONException e) {
                e.printStackTrace();
                str = null;
            }
            baVar.a(TextUtils.isEmpty(str) ? -1 : 0, str, null);
            return;
        }
        baVar.a(-1, null, null);
    }
}