360手机助手 v3.3.0版本的 MD5 值为:127c345ad16bbebee6e347381328afd0

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


package com.qihoo.appstore.newroot;

import android.content.Context;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Build;
import android.os.SystemProperties;
import android.text.TextUtils;
import com.qihoo.speedometer.Config;
import com.qihoo360.mobilesafe.telephonyInterface.DM;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class cu {
    private static final List e = new ArrayList();

    private final k f2629a;

    private final Context f2630b;
    private AsyncTask c;
    private AsyncTask d;

    static {
        for (String str : new String[]{"HTC X920e", DM.HTC_802w, "L39u"}) {
            e.add(str);
        }
    }

    public cu(Context context, k kVar) {
        this.f2630b = context.getApplicationContext();
        this.f2629a = kVar;
    }

    private void a(cq cqVar) {
        String str = Config.INVALID_IP;
        if (cq.NONE == cqVar) {
            str = "ROOT_TYPE_NONE";
        }
        if (cq.ONLY_PC == cqVar) {
            str = "ROOT_TYPE_ONLYPC";
        }
        if (cq.TMPROOT == cqVar) {
            str = "ROOT_TYPE_TMPROOT";
        }
        JSONObject jSONObject = new JSONObject();
        try {
            jSONObject.put("root_type", str);
        } catch (JSONException e2) {
            e2.printStackTrace();
        }
        if (!TextUtils.isEmpty(jSONObject.toString())) {
            str = jSONObject.toString();
        }
        a.a(this.f2630b, str, "root_type_cache");
    }

    private void a(JSONObject jSONObject) {
        try {
            String string = jSONObject.getString("mobile");
            String string2 = jSONObject.getString("pc");
            String string3 = jSONObject.getString("url");
            cq cqVar = cq.NONE;
            if (!TextUtils.isEmpty(string2) && "1".equals(string2)) {
                cqVar = cq.ONLY_PC;
            }
            if (!TextUtils.isEmpty(string) && "1".equals(string)) {
                cqVar = cq.TMPROOT;
            }
            if (Build.VERSION.SDK_INT >= 19) {
                cqVar = cq.NONE;
            }
            if (!TextUtils.isEmpty(string3)) {
                b.f2566a = string3;
            }
            if (this.f2629a != null) {
                this.f2629a.a(cqVar);
                a(cqVar);
            }
        } catch (JSONException e2) {
            if (this.f2629a != null) {
                this.f2629a.a(cq.NETWORK_ERROR);
            }
            a(cq.NETWORK_ERROR);
        }
    }

    private boolean a(String str) {
        try {
            JSONArray jSONArray = new JSONArray(str);
            if (jSONArray == null || jSONArray.length() == 0) {
                return false;
            }
            int length = jSONArray.length();
            for (int i = 0; i < length; i++) {
                JSONObject jSONObject = jSONArray.getJSONObject(i);
                if (jSONObject != null && !TextUtils.isEmpty(jSONObject.toString())) {
                    if (Build.MODEL.equals(jSONObject.getString("type"))) {
                        return true;
                    }
                }
            }
            return false;
        } catch (JSONException e2) {
            return false;
        }
    }

    private boolean a(JSONArray jSONArray) {
        if (jSONArray == null || jSONArray.length() == 0) {
            return false;
        }
        int length = jSONArray.length();
        int i = 0;
        for (int i2 = 0; i2 < length; i2++) {
            try {
                JSONObject jSONObject = jSONArray.getJSONObject(i2);
                if (jSONObject == null || TextUtils.isEmpty(jSONObject.toString())) {
                    i++;
                } else {
                    String string = jSONObject.getString("name");
                    String string2 = jSONObject.getString("type");
                    if (TextUtils.isEmpty(string) || TextUtils.isEmpty(string2)) {
                        i++;
                    }
                }
            } catch (JSONException e2) {
                return false;
            }
        }
        return i != length;
    }

    private boolean c() {
        if (System.currentTimeMillis() - a.b(this.f2630b, "black_list_cache") > Config.TASK_EXPIRATION_MSEC) {
            String d = d();
            boolean a2 = TextUtils.isEmpty(d) ? false : a(d);
            e();
            return a2;
        }
        String d2 = d();
        if (!TextUtils.isEmpty(d2)) {
            return a(d2);
        }
        e();
        return false;
    }

    private String d() {
        String c = a.c(this.f2630b, "black_list_cache");
        if (TextUtils.isEmpty(c)) {
            return c;
        }
        try {
            if (a(new JSONArray(c))) {
                return c;
            }
            return null;
        } catch (JSONException e2) {
            return null;
        }
    }

    private void e() {
        if (this.d != null) {
            this.d.cancel(true);
            this.d = null;
        }
        this.d = new cv(this);
        this.d.execute(new Void[0]);
    }

    public void f() {
        try {
            a.a(this.f2630b, com.qihoo.appstore.http.h.a().b(com.qihoo.appstore.utils.dc.t()), "black_list_cache");
        } catch (Exception e2) {
            if (com.qihoo360.mobilesafe.a.a.f5313a) {
                e2.printStackTrace();
            }
        }
    }

    private long g() {
        return a.b(this.f2630b, "root_type_cache");
    }

    private String h() {
        String c = a.c(this.f2630b, "root_type_cache");
        if (TextUtils.isEmpty(c)) {
            return null;
        }
        try {
            return new JSONObject(c).getString("root_type");
        } catch (JSONException e2) {
            e2.printStackTrace();
            return null;
        }
    }

    private boolean i() {
        return cs.a();
    }

    private boolean j() {
        return cs.b();
    }

    private boolean k() {
        return cs.c(this.f2630b);
    }

    private void l() {
        if (this.c != null) {
            this.c.cancel(true);
            this.c = null;
        }
        this.c = new cw(this);
        this.c.execute(new Void[0]);
    }

    public int m() {
        try {
            a(new JSONObject(com.qihoo.appstore.http.h.a().b("http://api.shuaji.360.cn/c/getMobileSupport?req=" + com.qihoo.appstore.utils.h.b(n().getBytes(), 2))));
            return 0;
        } catch (Exception e2) {
            if (this.f2629a != null) {
                this.f2629a.a(cq.NETWORK_ERROR);
            }
            a(cq.NETWORK_ERROR);
            return 0;
        }
    }

    private String n() {
        return String.format("mid=%s&act=10&pkg=1004&vcode=%s&vname=%s&m=%s&v=%s&a=%s&p=%s", com.qihoo.appstore.utils.aw.b(com.qihoo.appstore.utils.dc.L()), o(), p(), q(), r(), Build.VERSION.RELEASE, s());
    }

    private String o() {
        try {
            return Config.INVALID_IP + this.f2630b.getPackageManager().getPackageInfo(this.f2630b.getPackageName(), 0).versionCode;
        } catch (PackageManager.NameNotFoundException e2) {
            e2.printStackTrace();
            return "0";
        }
    }

    private String p() {
        try {
            return this.f2630b.getPackageManager().getPackageInfo(this.f2630b.getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException e2) {
            e2.printStackTrace();
            return Config.INVALID_IP;
        }
    }

    private String q() {
        String str = Build.MODEL;
        return TextUtils.isEmpty(str) ? "unknow" : str;
    }

    private String r() {
        return com.qihoo360.mobilesafe.d.a.a(new File("/"), "cat", "/proc/version").split(" ")[2];
    }

    private String s() {
        String str;
        if (TextUtils.isEmpty(SystemProperties.get("ro.mtk.hardware"))) {
            str = SystemProperties.get("ro.board.platform");
            if (TextUtils.isEmpty(str)) {
                str = SystemProperties.get("ro.hardware");
            }
        } else {
            str = "mtk";
        }
        if (TextUtils.isEmpty(str)) {
            str = "unknow";
        }
        str.trim();
        return str;
    }

    public void a() {
        if (c() || e.contains(Build.MODEL)) {
            if (this.f2629a != null) {
                this.f2629a.a(cq.ONLY_PC);
                return;
            }
            return;
        }
        if (i() || j() || k()) {
            if (this.f2629a != null) {
                this.f2629a.a(cq.CLIENT);
                return;
            }
            return;
        }
        if (System.currentTimeMillis() - g() > Config.TASK_EXPIRATION_MSEC) {
            l();
            return;
        }
        String h = h();
        if (TextUtils.isEmpty(h)) {
            l();
            return;
        }
        if ("ROOT_TYPE_NONE".equals(h)) {
            this.f2629a.a(cq.NONE);
            return;
        }
        if ("ROOT_TYPE_ONLYPC".equals(h)) {
            this.f2629a.a(cq.ONLY_PC);
        } else if ("ROOT_TYPE_TMPROOT".equals(h)) {
            this.f2629a.a(cq.TMPROOT);
        } else {
            l();
        }
    }

    public void b() {
        if (this.c != null) {
            this.c.cancel(true);
            this.c = null;
        }
        if (this.d != null) {
            this.d.cancel(true);
            this.d = null;
        }
    }
}